Class: Io::Flow::V0::Clients::CardPaymentSources

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CardPaymentSources

Returns a new instance of CardPaymentSources.



3421
3422
3423
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3421

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object

Deletes the specified card payment source



3465
3466
3467
3468
3469
3470
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3465

def delete_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/sources/payments/cards/#{CGI.escape(id)}").delete
  nil
end

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



3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3425

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :customer_number => (x = opts.delete(:customer_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('customer_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('customer_number', v, String) }),
    :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
    :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
    :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/sources/payments/cards").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::CardPaymentSource.new(x) }
end

#get_by_id(organization, id) ⇒ Object

Returns information about a specific card payment source.



3448
3449
3450
3451
3452
3453
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3448

def get_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/sources/payments/cards/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::CardPaymentSource.new(r)
end

#post(organization, card_payment_source_form) ⇒ Object

Create a new card payment source.



3440
3441
3442
3443
3444
3445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3440

def post(organization, card_payment_source_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = card_payment_source_form; x.is_a?(::Io::Flow::V0::Models::CardPaymentSourceForm) ? x : ::Io::Flow::V0::Models::CardPaymentSourceForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/sources/payments/cards").with_json(card_payment_source_form.to_json).post
  ::Io::Flow::V0::Models::CardPaymentSource.new(r)
end

#put_by_id(organization, id, card_payment_source_form) ⇒ Object

Update a card payment source.



3456
3457
3458
3459
3460
3461
3462
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3456

def put_by_id(organization, id, card_payment_source_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = card_payment_source_form; x.is_a?(::Io::Flow::V0::Models::CardPaymentSourceForm) ? x : ::Io::Flow::V0::Models::CardPaymentSourceForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/sources/payments/cards/#{CGI.escape(id)}").with_json(card_payment_source_form.to_json).put
  ::Io::Flow::V0::Models::CardPaymentSource.new(r)
end