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.



3525
3526
3527
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3525

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



3569
3570
3571
3572
3573
3574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3569

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



3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3529

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.



3552
3553
3554
3555
3556
3557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3552

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.



3544
3545
3546
3547
3548
3549
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3544

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.



3560
3561
3562
3563
3564
3565
3566
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3560

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