class Io::Flow::V0::Models::InventorySnapshot

Inventory snapshot reflects the current quantity and available number of units for a given center / item

Attributes

available[R]
center[R]
id[R]
item[R]
quantity[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 46399
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

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 46413
def copy(incoming={})
  InventorySnapshot.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 46417
def to_hash
  {
    :id => id,
    :available => available,
    :center => center.to_hash,
    :item => item.to_hash,
    :quantity => quantity
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 46409
def to_json
  JSON.dump(to_hash)
end