class Io::Flow::V0::Clients::CustomerTokens
Public Class Methods
new(client)
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 6553 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end
Public Instance Methods
delete_by_id(organization, id)
click to toggle source
Delete the token for this id.
# File lib/flow_commerce/flow_api_v0_client.rb, line 6583 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)}/customer/tokens/#{CGI.escape(id)}").delete nil end
get(organization, incoming={})
click to toggle source
Search tokens.
# File lib/flow_commerce/flow_api_v0_client.rb, line 6558 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, String)), :customer_number => (x = opts.delete(:customer_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('customer_number', 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)}/customer/tokens").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CustomerToken.new(x) } end
get_by_token(organization, token)
click to toggle source
Returns
a token if it exists.
# File lib/flow_commerce/flow_api_v0_client.rb, line 6591 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)}/customer/tokens/#{CGI.escape(token)}").get ::Io::Flow::V0::Models::CustomerToken.new(r) end
post_latest_by_customer_number(organization, customer_number)
click to toggle source
If there exists at least one token for this customer number, returns the latest. Otherwise creates a new token and returns that
# File lib/flow_commerce/flow_api_v0_client.rb, line 6575 def post_latest_by_customer_number(organization, customer_number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('customer_number', customer_number, String) r = @client.request("/#{CGI.escape(organization)}/customer/tokens/latest/#{CGI.escape(customer_number)}").post ::Io::Flow::V0::Models::CustomerToken.new(r) end