Class: Io::Flow::V0::Clients::VirtualCards
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::VirtualCards
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(organization, incoming = {}) ⇒ Object
Retrieve all the virtual credit cards that have been created matching selected criteria.
-
#get_by_key(organization, key) ⇒ Object
Retrieves a virtual credit card using your unique key used when creating the card.
-
#initialize(client) ⇒ VirtualCards
constructor
A new instance of VirtualCards.
-
#put_authorizations_by_key_and_authorization_key(organization, key, authorization_key, virtual_card_form) ⇒ Object
Creates a new virtual credit card.
Constructor Details
#initialize(client) ⇒ VirtualCards
Returns a new instance of VirtualCards.
3767 3768 3769 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3767 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
Retrieve all the virtual credit cards that have been created matching selected criteria.
3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3773 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) }), :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, 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)}/virtual/cards").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::VirtualCard.new(x) } end |
#get_by_key(organization, key) ⇒ Object
Retrieves a virtual credit card using your unique key used when creating the card. Note that the card number and cvv will not be returned by this request to maintain PCI compliance. If you have lost these details you will need to create a new card.
3791 3792 3793 3794 3795 3796 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3791 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/virtual/cards/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::VirtualCard.new(r) end |
#put_authorizations_by_key_and_authorization_key(organization, key, authorization_key, virtual_card_form) ⇒ Object
Creates a new virtual credit card. The card number and cvv will only be returned once when creating the card to maintain PCI compliance. This end point is idempotent and subsequent calls with same key will return details for the previously created card.
3802 3803 3804 3805 3806 3807 3808 3809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3802 def (organization, key, , virtual_card_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) HttpClient::Preconditions.assert_class('authorization_key', , String) (x = virtual_card_form; x.is_a?(::Io::Flow::V0::Models::VirtualCardForm) ? x : ::Io::Flow::V0::Models::VirtualCardForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/virtual/cards/#{CGI.escape(key)}/authorizations/#{CGI.escape()}").with_json(virtual_card_form.to_json).put ::Io::Flow::V0::Models::VirtualCard.new(r) end |