Class: ClickSign::Service
- Inherits:
-
Object
- Object
- ClickSign::Service
show all
- Defined in:
- lib/click_sign/service.rb
Defined Under Namespace
Classes: ErrorResponse, Response
Class Method Summary
collapse
Class Method Details
64
65
66
|
# File 'lib/click_sign/service.rb', line 64
def self.
{ Accept: 'application/json' }
end
|
.content_type ⇒ Object
68
69
70
|
# File 'lib/click_sign/service.rb', line 68
def self.content_type
{ 'Content-Type': 'application/json'}
end
|
.delete(url: nil, payload: nil) ⇒ Object
92
93
94
|
# File 'lib/click_sign/service.rb', line 92
def self.delete url: nil, payload: nil
request method: :delete, url: url, payload: payload
end
|
.get(url: nil, payload: nil) ⇒ Object
80
81
82
|
# File 'lib/click_sign/service.rb', line 80
def self.get url: nil, payload: nil
request method: :get, url: url, payload: payload
end
|
.patch(url: nil, payload: nil) ⇒ Object
88
89
90
|
# File 'lib/click_sign/service.rb', line 88
def self.patch url: nil, payload: nil
request method: :patch, url: url, payload: payload
end
|
.post(url: nil, payload: nil) ⇒ Object
84
85
86
|
# File 'lib/click_sign/service.rb', line 84
def self.post url: nil, payload: nil
request method: :post, url: url, payload: payload
end
|
.request(method: nil, url: nil, payload: nil) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/click_sign/service.rb', line 96
def self.request method: nil, url: nil, payload: nil
begin
response = RestClient::Request.execute(
method: method,
url: api_url(url),
payload: payload,
headers: ,
content_type: content_type
)
ClickSign::Service::Response.new(status_code: response.code, body: response.body)
rescue RestClient::ExceptionWithResponse => _e
ClickSign::Servive::ErrorResponse.new(status_code: _e.response.code, body: _e.response.body)
rescue RestClient::ServerBrokeConnection => _e
ap _e
rescue RestClient::SSLCertificateNotVerified => _e
ap _e
end
end
|