class Doconomy::Api::Client
Public Instance Methods
It makes HTTP DELETE request
@param endpoint @param headers ({ ‘Content-Type’ => ‘application/json’ }) Custom headers @param options ({}) Additional options like ‘with_authorization’
@return [Hash]
# File lib/doconomy/api/client.rb, line 51 def delete(endpoint, headers = { 'Content-Type' => 'application/json' }, options = {}) request(:delete, endpoint, nil, headers, options) end
It makes HTTP GET request
@param endpoint @param headers ({ ‘Content-Type’ => ‘application/json’ }) Custom headers @param options ({}) Additional options like ‘with_authorization’
@return [Hash]
# File lib/doconomy/api/client.rb, line 15 def get(endpoint, headers = { 'Content-Type' => 'application/json' }, options = {}) request(:get, endpoint, nil, headers, options) end
It makes HTTP HEAD request
@param endpoint @param headers ({ ‘Content-Type’ => ‘application/json’ }) Custom headers @param options ({}) Additional options like ‘with_authorization’
@return [Hash]
# File lib/doconomy/api/client.rb, line 63 def head(endpoint, headers = { 'Content-Type' => 'application/json' }, options = {}) request(:head, endpoint, nil, headers, options) end
It makes HTTP POST request
@param endpoint @param headers ({ ‘Content-Type’ => ‘application/json’ }) Custom headers @param options ({}) Additional options like ‘with_authorization’
@return [Hash]
# File lib/doconomy/api/client.rb, line 27 def post(endpoint, payload = nil, headers = { 'Content-Type' => 'application/json' }, options = {}) request(:post, endpoint, payload, headers, options) end
It makes HTTP PUT request
@param endpoint @param headers ({ ‘Content-Type’ => ‘application/json’ }) Custom headers @param options ({}) Additional options like ‘with_authorization’
@return [Hash]
# File lib/doconomy/api/client.rb, line 39 def put(endpoint, payload = nil, headers = { 'Content-Type' => 'application/json' }, options = {}) request(:put, endpoint, payload, headers, options) end
Private Instance Methods
# File lib/doconomy/api/client.rb, line 95 def prepare_request_params(method, endpoint, payload = nil) { method: method, url: url_for(endpoint), payload: payload, ssl_client_cert: ssl_client_cert, ssl_client_key: ssl_client_key }.reject { |_, value| value.nil? } end
# File lib/doconomy/api/client.rb, line 69 def request(method, endpoint, payload = nil, headers = {}, options = {}) if options[:with_authorization].nil? || options[:with_authorization] return request_with_authorization(method, endpoint, payload, headers, options) end request_without_authorization(method, endpoint, payload, headers) end
# File lib/doconomy/api/client.rb, line 90 def request_execute(params) body = RestClient::Request.execute(params).body JSON.parse(body).deep_transform_keys { |key| key.to_s.underscore.to_sym } end
# File lib/doconomy/api/client.rb, line 130 def ssl_client_cert OpenSSL::X509::Certificate.new(Doconomy::Api.configuration.pem) end
# File lib/doconomy/api/client.rb, line 134 def ssl_client_key OpenSSL::PKey.read(Doconomy::Api.configuration.pem, Doconomy::Api.configuration.pem_password) end
# File lib/doconomy/api/client.rb, line 126 def url_for(endpoint) "#{Doconomy::Api.configuration.url}#{endpoint}" end