Class: Io::Flow::V0::Clients::CardPaymentSources
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::CardPaymentSources
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#delete_by_id(organization, id) ⇒ Object
Deletes the specified card payment source.
- #get(organization, incoming = {}) ⇒ Object
-
#get_by_id(organization, id) ⇒ Object
Returns information about a specific card payment source.
-
#initialize(client) ⇒ CardPaymentSources
constructor
A new instance of CardPaymentSources.
-
#post(organization, card_payment_source_form) ⇒ Object
Create a new card payment source.
-
#put_by_id(organization, id, card_payment_source_form) ⇒ Object
Update a card payment source.
Constructor Details
#initialize(client) ⇒ CardPaymentSources
Returns a new instance of CardPaymentSources.
3122 3123 3124 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3122 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
3166 3167 3168 3169 3170 3171 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3166 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
3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3126 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.
3149 3150 3151 3152 3153 3154 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3149 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.
3141 3142 3143 3144 3145 3146 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3141 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.
3157 3158 3159 3160 3161 3162 3163 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3157 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 |