Class: DuffelAPI::Services::PaymentsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/duffel_api/services/payments_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::DEFAULT_ALL_PARAMS

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from DuffelAPI::Services::BaseService

Instance Method Details

#create(options = {}) ⇒ Resources::Payment

Creates an payment

Parameters:

  • [required, (Hash)

    a customizable set of options

Returns:

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/duffel_api/services/payments_service.rb', line 11

def create(options = {})
  path = "/air/payments"

  params = options.delete(:params) || {}
  options[:params] = {}
  options[:params]["data"] = params

  begin
    response = make_request(:post, path, options)

    # Response doesn't raise any errors until #body is called
    response.tap(&:raw_body)
  end

  return if response.raw_body.nil?

  Resources::Payment.new(unenvelope_body(response.parsed_body), response)
end