Module: Inkdit

Defined in:
lib/inkdit.rb,
lib/inkdit/client.rb,
lib/inkdit/entity.rb,
lib/inkdit/version.rb,
lib/inkdit/contract.rb,
lib/inkdit/resource.rb,
lib/inkdit/signature.rb,
lib/inkdit/form_contract.rb,
lib/inkdit/signature_field.rb

Defined Under Namespace

Classes: Client, Contract, Entity, Error, FormContract, Resource, Signature, SignatureField, Unauthorized

Constant Summary collapse

Config =

global configuration for the client. this has to be set up for anything to work. It must have the keys:

api_key

your application’s API key, obtained from developer.inkdit.com/

secret

your application’s shared secret, obtained from developer.inkdit.com/

It can optionally have the key:

debug

true if you want HTTP requests and responses printed to stdout.

{}
VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.authorization_code_url(scopes, redirect_uri) ⇒ String

Returns the URL that the user should be sent to to obtain an authorization code. (OAuth 2 section 4.1.1).

Parameters:

  • scopes (Array<String,Symbol>)

    an Array of the permissions that your application needs (see developer.inkdit.com/docs/read/Home)

  • redirect_uri (String)

    the URL that the user should be redirected to after the authorization code is obtained (OAuth 2 section 4.1.2)

Returns:

  • (String)

    the URL that the user should be sent to to obtain an authorization code. (OAuth 2 section 4.1.1)



32
33
34
35
# File 'lib/inkdit.rb', line 32

def self.authorization_code_url(scopes, redirect_uri)
  scopes = scopes.join('%20')
  "https://inkdit.com/oauth?response_type=code&client_id=#{Config['api_key']}&scope=#{scopes}&redirect_uri=#{redirect_uri}"
end

.get_token(authorization_code, redirect_uri) ⇒ OAuth2::AccessToken

requests an access token using an authorization code (OAuth 2 section 4.1.3/4.1.4)

Parameters:

  • authorization_code (String)

    the authorization code Inkdit passed to your application

  • redirect_uri (String)

    the redirect URI you used when requesting the authorization code

Returns:

  • (OAuth2::AccessToken)


58
59
60
# File 'lib/inkdit.rb', line 58

def self.get_token(authorization_code, redirect_uri)
 self.oauth_client.auth_code.get_token(authorization_code, :redirect_uri => redirect_uri)
end

.oauth_clientOAuth2::Client

you probably don’t want to call this.

Returns:

  • (OAuth2::Client)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/inkdit.rb', line 40

def self.oauth_client # :nodoc:
  api_key = Inkdit::Config['api_key']
  secret  = Inkdit::Config['secret']

  opts = { :site => 'https://api.inkdit.com/',
           :token_url => '/token',
           :raise_errors => false
         }

  OAuth2::Client.new(api_key, secret, opts)
end