Class: Api::Esignatures
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #options, #process, #tagged_logger
Constructor Details
Returns a new instance of Esignatures.
7
8
9
10
|
# File 'app/services/api/esignatures.rb', line 7
def initialize
@headers = {content_type: 'application/json'}
@client = HTTPClient.new { self.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE }
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'app/services/api/esignatures.rb', line 5
def client
@client
end
|
Class Method Details
.client ⇒ Object
12
13
14
|
# File 'app/services/api/esignatures.rb', line 12
def self.client
instance.client
end
|
.contract_status(contract_id) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/services/api/esignatures.rb', line 41
def self.contract_status(contract_id)
res = retrieve_contract(contract_id)
contract = JSON.parse(res.body).deep_symbolize_keys[:data]
if contract.present?
return contract[:status]
else
'not found'
end
end
|
.hostname ⇒ Object
16
17
18
|
# File 'app/services/api/esignatures.rb', line 16
def self.hostname
Heatwave::Configuration.fetch(:esignatures, :hostname)
end
|
.new_contract(options) ⇒ Object
29
30
31
|
# File 'app/services/api/esignatures.rb', line 29
def self.new_contract(options)
client.post("#{hostname}/contracts?token=#{token}", options.to_json, @headers)
end
|
.retrieve_contract(contract_id) ⇒ Object
33
34
35
|
# File 'app/services/api/esignatures.rb', line 33
def self.retrieve_contract(contract_id)
client.get("#{hostname}/contracts/#{contract_id}?token=#{token}")
end
|
.templates ⇒ Object
24
25
26
27
|
# File 'app/services/api/esignatures.rb', line 24
def self.templates
client.get("#{hostname}/templates/?token=#{token}")
end
|
.token ⇒ Object
20
21
22
|
# File 'app/services/api/esignatures.rb', line 20
def self.token
Heatwave::Configuration.fetch(:esignatures, :token)
end
|
.withdraw_contract(contract_id) ⇒ Object
37
38
39
|
# File 'app/services/api/esignatures.rb', line 37
def self.withdraw_contract(contract_id)
client.post("#{hostname}/contracts/#{contract_id}/withdraw/?token=#{token}")
end
|