Class: Io::Flow::V0::Clients::ChannelOrganizations
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::ChannelOrganizations
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(channel_id, key) ⇒ Object
-
#get(channel_id, incoming = {}) ⇒ Object
Returns the list of organizations in a channel, channel is identified by id.
- #get_by_key(channel_id, key) ⇒ Object
-
#initialize(client) ⇒ ChannelOrganizations
constructor
A new instance of ChannelOrganizations.
- #post(channel_id, channel_organization_form) ⇒ Object
- #put_by_key(channel_id, key, channel_organization_put_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ ChannelOrganizations
Returns a new instance of ChannelOrganizations.
5940 5941 5942 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5940 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
5982 5983 5984 5985 5986 5987 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5982 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
5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5945 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) }), :organization_id => (x = opts.delete(:organization_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('organization_id', 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? ? "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
5967 5968 5969 5970 5971 5972 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5967 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
5960 5961 5962 5963 5964 5965 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5960 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
5974 5975 5976 5977 5978 5979 5980 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5974 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 |