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.



16893
16894
16895
16896
16897
16898
16899
16900
16901
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16893

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.



16891
16892
16893
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16891

def available
  @available
end

#centerObject (readonly)

Returns the value of attribute center.



16891
16892
16893
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16891

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



16891
16892
16893
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16891

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



16891
16892
16893
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16891

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



16891
16892
16893
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16891

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16907
16908
16909
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16907

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

#to_hashObject



16911
16912
16913
16914
16915
16916
16917
16918
16919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16911

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

#to_jsonObject



16903
16904
16905
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16903

def to_json
  JSON.dump(to_hash)
end