No commit activity in last 3 years
No release in over 3 years
Sign requests call to SageOne API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
>= 0
>= 0
>= 0
>= 0
~> 10.0
>= 0

Runtime

 Project Readme

Sageone Api Request Signer

This gem do the signing process needed to make every request to a SageOne API.

The signing proccess is described here: https://developers.sageone.com/docs#signing_your_requests

Installation

Add this line to your application's Gemfile:

gem 'sageone_api_request_signer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sageone_api_request_signer

Usage

To create the signature string, you need to provide these data:

  @signer = SageoneApiRequestSigner.new({
    request_method: 'post',
    url: 'https://api.sageone.com/test/accounts/v1/contacts?config_setting=foo',
    body_params: {
      'contact[contact_type_id]' => 1,
      'contact[name]' => 'My Customer'
    },
    signing_secret: 'TestSigningSecret',
    access_token: 'TestToken',
  })

With the @signer you can get the request headers related to the signature part:

  @signer.request_headers
  => {
  =>   'Authorization' => "Bearer #{@signer.access_token}",
  =>   'X-Nonce' => @signer.nonce,
  =>   'X-Signature' => @signer.signature,
  => }

You can see a real example here: Integration test making a real api call to a test endpoint

Contributing

  1. Fork it ( https://github.com/[my-github-username]/sageone_api_request_signer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request