class Uploadcare::Client::RestClient
@abstract General client for signed REST requests
Public Instance Methods
api_root()
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 50 def api_root Uploadcare.config.rest_api_root end
delete(**options)
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 46 def delete(**options) request(method: 'DELETE', **options) end
Also aliased as: api_struct_delete
get(**options)
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 34 def get(**options) request(method: 'GET', **options) end
Also aliased as: api_struct_get
headers()
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 54 def headers { 'Content-type': 'application/json', 'Accept': 'application/vnd.uploadcare-v0.5+json', 'User-Agent': Uploadcare::Param::UserAgent.call } end
post(**options)
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 38 def post(**options) request(method: 'POST', **options) end
Also aliased as: api_struct_post
put(**options)
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 42 def put(**options) request(method: 'PUT', **options) end
Also aliased as: api_struct_put
request(method: 'GET', uri:, **options)
click to toggle source
Send request with authentication header
Handle throttling as well
# File lib/uploadcare/client/rest_client.rb, line 25 def request(method: 'GET', uri:, **options) request_headers = Param::AuthenticationHeader.call(method: method.upcase, uri: uri, content_type: headers[:'Content-type'], **options) handle_throttling do send('api_struct_' + method.downcase, path: remove_trailing_slash(uri), headers: request_headers, body: options[:content]) end end
Private Instance Methods
default_params()
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 68 def default_params {} end
remove_trailing_slash(str)
click to toggle source
# File lib/uploadcare/client/rest_client.rb, line 64 def remove_trailing_slash(str) str.gsub(%r{^\/}, '') end