Class: Io::Flow::V0::Clients::PaymentPaymentMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PaymentPaymentMethods

Returns a new instance of PaymentPaymentMethods.



7446
7447
7448
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7446

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get(organization, incoming = {}) ⇒ Object

Returns available payment methods.



7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7451

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :currency => (x = opts.delete(:currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('currency', x, String)),
    :country => (x = opts.delete(:country); x.nil? ? nil : HttpClient::Preconditions.assert_class('country', x, String)),
    :merchant_of_record => (x = opts.delete(:merchant_of_record); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::MerchantOfRecord) ? x : ::Io::Flow::V0::Models::MerchantOfRecord.apply(x)).value)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/payment/methods").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::PaymentPaymentMethod.new(x) }
end