Class: SynapsePayments::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_payments/request.rb

Constant Summary collapse

HEADERS =
{
  'User-Agent'      => "SynapsePaymentsRubyGem/#{SynapsePayments::VERSION}",
  'X-Ruby-Version'  => RUBY_VERSION,
  'X-Ruby-Platform' => RUBY_PLATFORM
}

Instance Method Summary collapse

Constructor Details

#initialize(client:, method:, path:, oauth_key: nil, fingerprint: nil, json: nil) ⇒ Request



10
11
12
13
14
15
16
17
# File 'lib/synapse_payments/request.rb', line 10

def initialize(client:, method:, path:, oauth_key: nil, fingerprint: nil, json: nil)
  @client = client
  @method = method
  @path = path
  @oauth_key = oauth_key
  @fingerprint = fingerprint
  @json = json
end

Instance Method Details

#performObject



19
20
21
22
23
24
# File 'lib/synapse_payments/request.rb', line 19

def perform
  options_key = @method == :get ? :params : :json
  response = http_client.public_send(@method, "#{@client.api_base}#{@path}", options_key => @json)
  response_body = @client.symbolize_keys!(response.parse)
  fail_or_return_response_body(response.code, response_body)
end