Class: Io::Flow::V0::Models::InventorySnapshot

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ InventorySnapshot

Returns a new instance of InventorySnapshot.



27903
27904
27905
27906
27907
27908
27909
27910
27911
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27903

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

#availableObject (readonly)

Returns the value of attribute available.



27901
27902
27903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27901

def available
  @available
end

#centerObject (readonly)

Returns the value of attribute center.



27901
27902
27903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27901

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



27901
27902
27903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27901

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



27901
27902
27903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27901

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



27901
27902
27903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27901

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



27917
27918
27919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27917

def copy(incoming={})
  InventorySnapshot.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



27921
27922
27923
27924
27925
27926
27927
27928
27929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27921

def to_hash
  {
    :id => id,
    :available => available,
    :center => center.to_hash,
    :item => item.to_hash,
    :quantity => quantity
  }
end

#to_jsonObject



27913
27914
27915
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27913

def to_json
  JSON.dump(to_hash)
end