Class: Io::Flow::V0::Clients::Centers
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Centers
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_key(organization, key) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_key(organization, key) ⇒ Object
- #get_versions(organization, incoming = {}) ⇒ Object
-
#initialize(client) ⇒ Centers
constructor
A new instance of Centers.
- #post(organization, center_form) ⇒ Object
- #post_query(organization, center_query) ⇒ Object
- #put_by_key(organization, key, center_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Centers
Returns a new instance of Centers.
3960 3961 3962 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3960 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_key(organization, key) ⇒ Object
4021 4022 4023 4024 4025 4026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4021 def delete_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/centers/#{CGI.escape(key)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3964 def get(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, 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("/#{CGI.escape(organization)}/centers").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Center.new(x) } end |
#get_by_key(organization, key) ⇒ Object
4006 4007 4008 4009 4010 4011 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4006 def get_by_key(organization, key) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) r = @client.request("/#{CGI.escape(organization)}/centers/#{CGI.escape(key)}").get ::Io::Flow::V0::Models::Center.new(r) end |
#get_versions(organization, incoming = {}) ⇒ Object
3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3992 def get_versions(organization, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, 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? ? "journal_timestamp" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/centers/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::CenterVersion.new(x) } end |
#post(organization, center_form) ⇒ Object
3978 3979 3980 3981 3982 3983 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3978 def post(organization, center_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = center_form; x.is_a?(::Io::Flow::V0::Models::CenterForm) ? x : ::Io::Flow::V0::Models::CenterForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers").with_json(center_form.to_json).post ::Io::Flow::V0::Models::Center.new(r) end |
#post_query(organization, center_query) ⇒ Object
3985 3986 3987 3988 3989 3990 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3985 def post_query(organization, center_query) HttpClient::Preconditions.assert_class('organization', organization, String) (x = center_query; x.is_a?(::Io::Flow::V0::Models::CenterQuery) ? x : ::Io::Flow::V0::Models::CenterQuery.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers/query").with_json(center_query.to_json).post r.map { |x| ::Io::Flow::V0::Models::Center.new(x) } end |
#put_by_key(organization, key, center_form) ⇒ Object
4013 4014 4015 4016 4017 4018 4019 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4013 def put_by_key(organization, key, center_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('key', key, String) (x = center_form; x.is_a?(::Io::Flow::V0::Models::CenterForm) ? x : ::Io::Flow::V0::Models::CenterForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/centers/#{CGI.escape(key)}").with_json(center_form.to_json).put ::Io::Flow::V0::Models::Center.new(r) end |