Class: Io::Flow::V0::Clients::ChannelOrganizations

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ChannelOrganizations

Returns a new instance of ChannelOrganizations.



5335
5336
5337
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5335

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_key(channel_id, key) ⇒ Object



5376
5377
5378
5379
5380
5381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5376

def delete_by_key(channel_id, key)
  HttpClient::Preconditions.assert_class('channel_id', channel_id, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/channel/#{CGI.escape(channel_id)}/organizations/#{CGI.escape(key)}").delete
  nil
end

#get(channel_id, incoming = {}) ⇒ Object

Returns the list of organizations in a channel, channel is identified by id



5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5340

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) }),
    :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', 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? ? "name" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/channel/#{CGI.escape(channel_id)}/organizations").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::ChannelOrganization.new(x) }
end

#get_by_key(channel_id, key) ⇒ Object



5361
5362
5363
5364
5365
5366
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5361

def get_by_key(channel_id, key)
  HttpClient::Preconditions.assert_class('channel_id', channel_id, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/channel/#{CGI.escape(channel_id)}/organizations/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::ChannelOrganization.new(r)
end

#post(channel_id, channel_organization_form) ⇒ Object



5354
5355
5356
5357
5358
5359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5354

def post(channel_id, channel_organization_form)
  HttpClient::Preconditions.assert_class('channel_id', channel_id, String)
  (x = channel_organization_form; x.is_a?(::Io::Flow::V0::Models::ChannelOrganizationForm) ? x : ::Io::Flow::V0::Models::ChannelOrganizationForm.new(x))
  r = @client.request("/channel/#{CGI.escape(channel_id)}/organizations").with_json(channel_organization_form.to_json).post
  ::Io::Flow::V0::Models::ChannelOrganization.new(r)
end

#put_by_key(channel_id, key, channel_organization_put_form) ⇒ Object



5368
5369
5370
5371
5372
5373
5374
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5368

def put_by_key(channel_id, key, channel_organization_put_form)
  HttpClient::Preconditions.assert_class('channel_id', channel_id, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  (x = channel_organization_put_form; x.is_a?(::Io::Flow::V0::Models::ChannelOrganizationPutForm) ? x : ::Io::Flow::V0::Models::ChannelOrganizationPutForm.new(x))
  r = @client.request("/channel/#{CGI.escape(channel_id)}/organizations/#{CGI.escape(key)}").with_json(channel_organization_put_form.to_json).put
  ::Io::Flow::V0::Models::ChannelOrganization.new(r)
end