Class: Io::Flow::V0::Models::InventorySnapshot
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::InventorySnapshot
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Inventory snapshot reflects the current quantity and available number of units for a given center / item
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#center ⇒ Object
readonly
Returns the value of attribute center.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ InventorySnapshot
constructor
A new instance of InventorySnapshot.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ InventorySnapshot
Returns a new instance of InventorySnapshot.
31588 31589 31590 31591 31592 31593 31594 31595 31596 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31588 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :available, :center, :item, :quantity], 'InventorySnapshot') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @available = HttpClient::Preconditions.assert_class('available', opts.delete(:available), Integer) @center = (x = opts.delete(:center); x.is_a?(::Io::Flow::V0::Models::InventoryCenterReference) ? x : ::Io::Flow::V0::Models::InventoryCenterReference.new(x)) @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::InventoryItemReference) ? x : ::Io::Flow::V0::Models::InventoryItemReference.new(x)) @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer) end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
31586 31587 31588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31586 def available @available end |
#center ⇒ Object (readonly)
Returns the value of attribute center.
31586 31587 31588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31586 def center @center end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
31586 31587 31588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31586 def id @id end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
31586 31587 31588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31586 def item @item end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
31586 31587 31588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31586 def quantity @quantity end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
31602 31603 31604 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31602 def copy(incoming={}) InventorySnapshot.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
31606 31607 31608 31609 31610 31611 31612 31613 31614 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31606 def to_hash { :id => id, :available => available, :center => center.to_hash, :item => item.to_hash, :quantity => quantity } end |
#to_json ⇒ Object
31598 31599 31600 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598 def to_json JSON.dump(to_hash) end |