Class: Clicksign::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/clicksign/base.rb

Direct Known Subclasses

Batch, Document, Hook

Class Method Summary collapse

Class Method Details

.accept_headerObject



3
4
5
# File 'lib/clicksign/base.rb', line 3

def self.accept_header
  { accept: 'json' }
end

.api_url(*path) ⇒ Object



12
13
14
15
# File 'lib/clicksign/base.rb', line 12

def self.api_url(*path)
  ([Clicksign.endpoint, Clicksign.api_version] + path).join("/") +
    "?access_token=#{Clicksign.token}"
end

.parse(response) ⇒ Object



17
18
19
20
# File 'lib/clicksign/base.rb', line 17

def self.parse(response)
  response = {} if response.empty?
  JSON[response]
end

.request(method, *params) ⇒ Object



7
8
9
10
# File 'lib/clicksign/base.rb', line 7

def self.request(method, *params)
  params.last.merge! accept_header
  parse RestClient.public_send(method, *params)
end