Class: Io::Flow::V0::Clients::Serials
- Inherits:
-
Object
- Object
- Io::Flow::V0::Clients::Serials
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Method Summary collapse
- #delete_by_number(organization, number) ⇒ Object
- #get(organization, incoming = {}) ⇒ Object
- #get_by_number(organization, number) ⇒ Object
- #get_prices_by_aggregate(organization, aggregate, incoming = {}) ⇒ Object
-
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion.
-
#initialize(client) ⇒ Serials
constructor
A new instance of Serials.
- #post(organization, serial_form) ⇒ Object
- #put_by_number(organization, number, serial_form) ⇒ Object
Constructor Details
#initialize(client) ⇒ Serials
Returns a new instance of Serials.
4343 4344 4345 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4343 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
4410 4411 4412 4413 4414 4415 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4410 def delete_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/inventory/serials/#{CGI.escape(number)}").delete nil end |
#get(organization, incoming = {}) ⇒ Object
4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4347 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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', v, String) }), :status => (x = opts.delete(:status); x.nil? ? nil : HttpClient::Preconditions.assert_class('status', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::SerialStatus) ? x : ::Io::Flow::V0::Models::SerialStatus.apply(x)).value }), :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? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/inventory/serials").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Serial.new(x) } end |
#get_by_number(organization, number) ⇒ Object
4395 4396 4397 4398 4399 4400 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4395 def get_by_number(organization, number) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) r = @client.request("/#{CGI.escape(organization)}/inventory/serials/#{CGI.escape(number)}").get ::Io::Flow::V0::Models::Serial.new(r) end |
#get_prices_by_aggregate(organization, aggregate, incoming = {}) ⇒ Object
4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4369 def get_prices_by_aggregate(organization, aggregate, incoming={}) HttpClient::Preconditions.assert_class('organization', organization, String) (x = aggregate; x.is_a?(::Io::Flow::V0::Models::Aggregate) ? x : ::Io::Flow::V0::Models::Aggregate.apply(x)) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :item_number => HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), Array).map { |v| HttpClient::Preconditions.assert_class('item_number', v, String) } }.delete_if { |k, v| v.nil? } r = @client.request("/#{CGI.escape(organization)}/inventory/serials/prices/#{aggregate.value}").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Serial.new(x) } end |
#get_versions(organization, incoming = {}) ⇒ Object
Provides visibility into recent changes of each object, including deletion
4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4381 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) }), :number => (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, Array).map { |v| HttpClient::Preconditions.assert_class('number', 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)}/inventory/serials/versions").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::SerialVersion.new(x) } end |
#post(organization, serial_form) ⇒ Object
4362 4363 4364 4365 4366 4367 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4362 def post(organization, serial_form) HttpClient::Preconditions.assert_class('organization', organization, String) (x = serial_form; x.is_a?(::Io::Flow::V0::Models::SerialForm) ? x : ::Io::Flow::V0::Models::SerialForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/inventory/serials").with_json(serial_form.to_json).post ::Io::Flow::V0::Models::Serial.new(r) end |
#put_by_number(organization, number, serial_form) ⇒ Object
4402 4403 4404 4405 4406 4407 4408 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4402 def put_by_number(organization, number, serial_form) HttpClient::Preconditions.assert_class('organization', organization, String) HttpClient::Preconditions.assert_class('number', number, String) (x = serial_form; x.is_a?(::Io::Flow::V0::Models::SerialForm) ? x : ::Io::Flow::V0::Models::SerialForm.new(x)) r = @client.request("/#{CGI.escape(organization)}/inventory/serials/#{CGI.escape(number)}").with_json(serial_form.to_json).put ::Io::Flow::V0::Models::Serial.new(r) end |