Class: Signnow::Request::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/signnow/request/info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method, subdomain, api_url, data, options = {}) ⇒ Info

Returns a new instance of Info.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/signnow/request/info.rb', line 6

def initialize(http_method, subdomain, api_url, data, options={})
  @http_method = http_method
  @subdomain   = subdomain || Signnow.domain
  @api_url     = api_url
  @data        = data
  @base_path   = Signnow.base_path
  @authentication = {}
  @authentication[:type] = options.delete(:auth_type)
  @authentication[:token] = options.delete(:auth_token)
  @options = options
end

Instance Attribute Details

#api_urlObject

Returns the value of attribute api_url.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def api_url
  @api_url
end

#authenticationObject

Returns the value of attribute authentication.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def authentication
  @authentication
end

#base_pathObject

Returns the value of attribute base_path.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def base_path
  @base_path
end

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def data
  @data
end

#http_methodObject

Returns the value of attribute http_method.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def http_method
  @http_method
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def options
  @options
end

#subdomainObject

Returns the value of attribute subdomain.



4
5
6
# File 'lib/signnow/request/info.rb', line 4

def subdomain
  @subdomain
end

Instance Method Details

#path_with_params(path, params) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/signnow/request/info.rb', line 30

def path_with_params(path, params)
  unless params.empty?
    encoded_params = URI.encode_www_form(params)
    [path, encoded_params].join("?")
  else
    path
  end
end

#urlObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/signnow/request/info.rb', line 18

def url
  url = ''
  url += "/#{base_path}" if base_path
  url += "/#{api_url}"
  if has_id?
    url += "/#{data[:id]}"
    data.delete(:id)
  end

  url
end

#use_form_data?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/signnow/request/info.rb', line 39

def use_form_data?
  options.fetch(:use_form_data, false)
end