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.
5678 5679 5680 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5678 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
5719 5720 5721 5722 5723 5724 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5719 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
5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5683 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
5704 5705 5706 5707 5708 5709 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5704 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
5697 5698 5699 5700 5701 5702 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5697 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
5711 5712 5713 5714 5715 5716 5717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5711 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 |