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
- #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
- #put_by_key(organization, key, center_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Centers
Returns a new instance of Centers.
3261 3262 3263 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3261 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#get(organization, incoming = {}) ⇒ Object
3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3265 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
3286 3287 3288 3289 3290 3291 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3286 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
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3301 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
3279 3280 3281 3282 3283 3284 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3279 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 |
#put_by_key(organization, key, center_form) ⇒ Object
3293 3294 3295 3296 3297 3298 3299 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3293 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 |