class Io::Flow::V0::Clients::Cards

Public Class Methods

new(client) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 3452
def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Public Instance Methods

delete_by_token(organization, token) click to toggle source

Deletes the specified card

# File lib/flow_commerce/flow_api_v0_client.rb, line 3514
def delete_by_token(organization, token)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('token', token, String)
  r = @client.request("/#{CGI.escape(organization)}/cards/#{CGI.escape(token)}").delete
  nil
end
get(organization, incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 3456
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) }),
    :token => (x = opts.delete(:token); x.nil? ? nil : HttpClient::Preconditions.assert_class('token', x, Array).map { |v| HttpClient::Preconditions.assert_class('token', 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)}/cards").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::Card.new(x) }
end
get_by_token(organization, token) click to toggle source

Returns information about a specific card.

# File lib/flow_commerce/flow_api_v0_client.rb, line 3506
def get_by_token(organization, token)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('token', token, String)
  r = @client.request("/#{CGI.escape(organization)}/cards/#{CGI.escape(token)}").get
  ::Io::Flow::V0::Models::Card.new(r)
end
get_versions(organization, incoming={}) click to toggle source

Provides visibility into recent changes of each object, including deletion

# File lib/flow_commerce/flow_api_v0_client.rb, line 3490
def get_versions(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, Integer) }),
    :card_id => (x = opts.delete(:card_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('card_id', x, Array).map { |v| HttpClient::Preconditions.assert_class('card_id', v, String) }),
    :card_token => (x = opts.delete(:card_token); x.nil? ? nil : HttpClient::Preconditions.assert_class('card_token', x, Array).map { |v| HttpClient::Preconditions.assert_class('card_token', 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? ? "journal_timestamp" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/cards/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::CardVersion.new(x) }
end
post(organization, card_form) click to toggle source

Create a new card. Note that when using JSONP to submit a card, you do not need to authenticate.

# File lib/flow_commerce/flow_api_v0_client.rb, line 3472
def post(organization, card_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = card_form; x.is_a?(::Io::Flow::V0::Models::CardForm) ? x : ::Io::Flow::V0::Models::CardForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/cards").with_json(card_form.to_json).post
  ::Io::Flow::V0::Models::Card.new(r)
end
post_nonces(organization, card_nonce_form) click to toggle source

Creates a card from a one time nonce. Each nonce can be used at most once and you will receive a validation error if the nonce has already been exchanged.

# File lib/flow_commerce/flow_api_v0_client.rb, line 3482
def post_nonces(organization, card_nonce_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = card_nonce_form; x.is_a?(::Io::Flow::V0::Models::CardNonceForm) ? x : ::Io::Flow::V0::Models::CardNonceForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/cards/nonces").with_json(card_nonce_form.to_json).post
  ::Io::Flow::V0::Models::Card.new(r)
end