Class: Io::Flow::V0::Clients::PartnerTokens
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::PartnerTokens
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
-
#get(partner, incoming = {}) ⇒ Object
Get all tokens for the specified partner.
-
#initialize(client) ⇒ PartnerTokens
constructor
A new instance of PartnerTokens.
-
#post(partner, partner_token_form) ⇒ Object
Create a new partner.
Constructor Details
#initialize(client) ⇒ PartnerTokens
Returns a new instance of PartnerTokens.
7821 7822 7823 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7821 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(partner, incoming = {}) ⇒ Object
Get all tokens for the specified partner
7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7826 def get(partner, incoming={}) HttpClient::Preconditions.assert_class('partner', partner, 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) }), :mine => (x = opts.delete(:mine); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('mine', x)), :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("/partners/#{CGI.escape(partner)}/tokens").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::PartnerToken.new(x) } end |
#post(partner, partner_token_form) ⇒ Object
Create a new partner
7841 7842 7843 7844 7845 7846 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7841 def post(partner, partner_token_form) HttpClient::Preconditions.assert_class('partner', partner, String) (x = partner_token_form; x.is_a?(::Io::Flow::V0::Models::PartnerTokenForm) ? x : ::Io::Flow::V0::Models::PartnerTokenForm.new(x)) r = @client.request("/partners/#{CGI.escape(partner)}/tokens").with_json(partner_token_form.to_json).post ::Io::Flow::V0::Models::PartnerToken.new(r) end |