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, idempotency_key: nil) ⇒ Request

Returns a new instance of Request.



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

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

Instance Method Details

#performObject



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

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