Class: Io::Flow::V0::Clients::ChannelTokens
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ChannelTokens
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_id(channel_id, id) ⇒ Object
- #get(channel_id, incoming = {}) ⇒ Object
- #get_by_id(channel_id, id) ⇒ Object
-
#initialize(client) ⇒ ChannelTokens
constructor
A new instance of ChannelTokens.
- #put_by_id(channel_id, id, channel_token_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ ChannelTokens
Returns a new instance of ChannelTokens.
6080 6081 6082 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6080 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_id(channel_id, id) ⇒ Object
6112 6113 6114 6115 6116 6117 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6112 def delete_by_id(channel_id, id) HttpClient::Preconditions.assert_class('channel_id', channel_id, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/channel/#{CGI.escape(channel_id)}/tokens/#{CGI.escape(id)}").delete nil end |
#get(channel_id, incoming = {}) ⇒ Object
6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6084 def get(channel_id, incoming={}) HttpClient::Preconditions.assert_class('channel_id', channel_id, 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) }), :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("/channel/#{CGI.escape(channel_id)}/tokens").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::ChannelToken.new(x) } end |
#get_by_id(channel_id, id) ⇒ Object
6097 6098 6099 6100 6101 6102 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6097 def get_by_id(channel_id, id) HttpClient::Preconditions.assert_class('channel_id', channel_id, String) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/channel/#{CGI.escape(channel_id)}/tokens/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::ChannelToken.new(r) end |
#put_by_id(channel_id, id, channel_token_form) ⇒ Object
6104 6105 6106 6107 6108 6109 6110 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6104 def put_by_id(channel_id, id, channel_token_form) HttpClient::Preconditions.assert_class('channel_id', channel_id, String) HttpClient::Preconditions.assert_class('id', id, String) (x = channel_token_form; x.is_a?(::Io::Flow::V0::Models::ChannelTokenForm) ? x : ::Io::Flow::V0::Models::ChannelTokenForm.new(x)) r = @client.request("/channel/#{CGI.escape(channel_id)}/tokens/#{CGI.escape(id)}").with_json(channel_token_form.to_json).put ::Io::Flow::V0::Models::ChannelToken.new(r) end |