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.
4206 4207 4208 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4206 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end |
Instance Method Details
#delete_by_number(organization, number) ⇒ Object
4273 4274 4275 4276 4277 4278 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4273 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
4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4210 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
4258 4259 4260 4261 4262 4263 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4258 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
4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4232 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
4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4244 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
4225 4226 4227 4228 4229 4230 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4225 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
4265 4266 4267 4268 4269 4270 4271 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4265 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 |