Class: Io::Flow::V0::Clients::ChannelTokens

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ChannelTokens

Returns a new instance of ChannelTokens.



5415
5416
5417
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5415

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



5447
5448
5449
5450
5451
5452
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5447

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



5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5419

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



5432
5433
5434
5435
5436
5437
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5432

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, io_flow_token_internal_v0_models_channel_token_form) ⇒ Object



5439
5440
5441
5442
5443
5444
5445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5439

def put_by_id(channel_id, id, io_flow_token_internal_v0_models_channel_token_form)
  HttpClient::Preconditions.assert_class('channel_id', channel_id, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = io_flow_token_internal_v0_models_channel_token_form; x.is_a?(::Io::Flow::Token::Internal::V0::Models::ChannelTokenForm) ? x : ::Io::Flow::Token::Internal::V0::Models::ChannelTokenForm.new(x))
  r = @client.request("/channel/#{CGI.escape(channel_id)}/tokens/#{CGI.escape(id)}").with_json(io_flow_token_internal_v0_models_channel_token_form.to_json).put
  ::Io::Flow::V0::Models::ChannelToken.new(r)
end