Class: Clicksign::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/clicksign/base.rb
Class Method Summary
collapse
Class Method Details
.api_url(*path) ⇒ Object
16
17
18
|
# File 'lib/clicksign/base.rb', line 16
def self.api_url(*path)
([Clicksign.endpoint] + path).join("/")
end
|
.build_data(params, model_name, id = '', custom_params = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/clicksign/base.rb', line 25
def self.build_data(params, model_name, id='', custom_params={})
data = {
data: {
attributes: params,
type: model_name
}
}
unless custom_params.empty?
data[:data].merge! custom_params
end
unless id.empty?
data[:data][:id] = id
end
data.to_json
end
|
3
4
5
6
7
8
9
|
# File 'lib/clicksign/base.rb', line 3
def self.
{
accept: 'application/vnd.api+json',
content_type: 'application/vnd.api+json',
authorization: Clicksign.token
}
end
|
.parse(response) ⇒ Object
20
21
22
23
|
# File 'lib/clicksign/base.rb', line 20
def self.parse(response)
response = {} if response.empty?
JSON[response]
end
|
.request(method, *params) ⇒ Object
11
12
13
14
|
# File 'lib/clicksign/base.rb', line 11
def self.request(method, *params)
params.last.merge!()
parse RestClient.public_send(method, *params)
end
|