Module: Signnow

Defined in:
lib/signnow.rb,
lib/signnow/base.rb,
lib/signnow/user.rb,
lib/signnow/client.rb,
lib/signnow/version.rb,
lib/signnow/document.rb,
lib/signnow/request/base.rb,
lib/signnow/request/info.rb,
lib/signnow/operations/all.rb,
lib/signnow/operations/find.rb,
lib/signnow/operations/show.rb,
lib/signnow/request/helpers.rb,
lib/signnow/operations/create.rb,
lib/signnow/operations/delete.rb,
lib/signnow/operations/update.rb,
lib/signnow/request/validator.rb,
lib/signnow/request/connection.rb,
lib/signnow/authentications/base.rb,
lib/signnow/authentications/oauth.rb,
lib/signnow/operations/download_link.rb

Defined Under Namespace

Modules: Authentications, Operations, Request Classes: APIError, AuthenticationError, Base, Client, Document, EmptyDocuments, InvalidToken, NotFound, SignnowError, User

Constant Summary collapse

DOMAIN_BASE =
'api'
TEST_DOMAIN_BASE =
'capi-eval'
API_BASE =
'signnow.com'
API_BASE_PATH =
nil
TEST_API_BASE_PATH =
'api'
API_VERSION =
'v1'
ROOT_PATH =
File.dirname(__FILE__)
VERSION =
'0.0.2'
@@configuration =
{}

Class Method Summary collapse

Class Method Details

.base_pathObject

Returns the api base path depending on the env



104
105
106
107
108
109
110
# File 'lib/signnow.rb', line 104

def self.base_path
  if configuration[:use_test_env?]
    TEST_API_BASE_PATH
  else
    API_BASE_PATH
  end
end

.configurationHash

Returns configuration hash

Returns:

  • (Hash)


76
77
78
# File 'lib/signnow.rb', line 76

def self.configuration
  @@configuration
end

.configure {|configuration| ... } ⇒ Object

Use thisfunciotn with a block to add app credentials configuration Example:

Signnow.configure do |config|

config[:app_id] = 'your_app_id'
config[:app_secret] = 'your_app_secret'

end

Yields:



69
70
71
72
# File 'lib/signnow.rb', line 69

def self.configure
  return unless block_given?
  yield(configuration)
end

.domainObject

Returns the domain base of the api depending on the env



94
95
96
97
98
99
100
# File 'lib/signnow.rb', line 94

def self.domain
  if configuration[:use_test_env?]
    TEST_DOMAIN_BASE
  else
    DOMAIN_BASE
  end
end

.encoded_app_credentialsString

Returns the set api key

Returns:

  • (String)

    The api key



56
57
58
59
60
# File 'lib/signnow.rb', line 56

def self.encoded_app_credentials
  return unless configuration[:app_id] && configuration[:app_secret]
  configuration[:encoded_app_credentials] ||=
    Base64.strict_encode64("#{configuration[:app_id]}:#{configuration[:app_secret]}")
end

.request(http_method, domain, api_url, data, options = {}) ⇒ Array

Makes a request against the Signnow API

Parameters:

  • http_method (Symbol)

    The http method to use, must be one of :get, :post, :put and :delete

  • domain (String)

    The API domain to use

  • api_url (String)

    The API url to use

  • data (Hash)

    The data to send, e.g. used when creating new objects.

Returns:

  • (Array)

    The parsed JSON response.



87
88
89
90
# File 'lib/signnow.rb', line 87

def self.request(http_method, domain, api_url, data, options={})
  info = Request::Info.new(http_method, domain, api_url, data, options)
  Request::Base.new(info).perform
end

.uriObject

Returns the api uri



114
115
116
117
118
# File 'lib/signnow.rb', line 114

def self.uri
  uri = "https://#{domain}"
  base_path && uri += "/#{base_path}"
  uri
end