Class: Uploadcare::Client::RestClient
Abstract
Overview
General client for signed REST requests
Instance Method Summary
collapse
#handle_throttling
#failure, #wrap
Instance Method Details
#api_root ⇒ Object
51
52
53
|
# File 'lib/uploadcare/client/rest_client.rb', line 51
def api_root
Uploadcare.config.rest_api_root
end
|
#api_struct_delete ⇒ Object
18
|
# File 'lib/uploadcare/client/rest_client.rb', line 18
alias api_struct_delete delete
|
#api_struct_get ⇒ Object
19
|
# File 'lib/uploadcare/client/rest_client.rb', line 19
alias api_struct_get get
|
#api_struct_post ⇒ Object
20
|
# File 'lib/uploadcare/client/rest_client.rb', line 20
alias api_struct_post post
|
#api_struct_put ⇒ Object
21
|
# File 'lib/uploadcare/client/rest_client.rb', line 21
alias api_struct_put put
|
#delete(options = {}) ⇒ Object
47
48
49
|
# File 'lib/uploadcare/client/rest_client.rb', line 47
def delete(options = {})
request(method: 'DELETE', **options)
end
|
#get(options = {}) ⇒ Object
35
36
37
|
# File 'lib/uploadcare/client/rest_client.rb', line 35
def get(options = {})
request(method: 'GET', **options)
end
|
55
56
57
58
59
60
61
|
# File 'lib/uploadcare/client/rest_client.rb', line 55
def
{
'Content-Type': 'application/json',
Accept: 'application/vnd.uploadcare-v0.7+json',
'User-Agent': Uploadcare::Param::UserAgent.call
}
end
|
#post(options = {}) ⇒ Object
39
40
41
|
# File 'lib/uploadcare/client/rest_client.rb', line 39
def post(options = {})
request(method: 'POST', **options)
end
|
#put(options = {}) ⇒ Object
43
44
45
|
# File 'lib/uploadcare/client/rest_client.rb', line 43
def put(options = {})
request(method: 'PUT', **options)
end
|
#request(uri:, method: 'GET', **options) ⇒ Object
Send request with authentication header
Handle throttling as well
26
27
28
29
30
31
32
33
|
# File 'lib/uploadcare/client/rest_client.rb', line 26
def request(uri:, method: 'GET', **options)
= Param::.call(method: method.upcase, uri: uri,
content_type: [:'Content-Type'], **options)
handle_throttling do
send("api_struct_#{method.downcase}", path: remove_trailing_slash(uri),
headers: , body: options[:content])
end
end
|