Class: Io::Flow::V0::Models::InventoryUpdate

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents a single update on inventory quantity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ InventoryUpdate

Returns a new instance of InventoryUpdate.



18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18705

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :idempotency_key, :center, :item, :notes, :quantity, :type], 'InventoryUpdate')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @idempotency_key = HttpClient::Preconditions.assert_class('idempotency_key', opts.delete(:idempotency_key), String)
  @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))
  @notes = HttpClient::Preconditions.assert_class('notes', HttpClient::Helper.to_object(opts.delete(:notes)), Hash)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::UpdateType) ? x : ::Io::Flow::V0::Models::UpdateType.apply(x))
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def center
  @center
end

#idObject (readonly)

Returns the value of attribute id.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def id
  @id
end

#idempotency_keyObject (readonly)

Returns the value of attribute idempotency_key.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def idempotency_key
  @idempotency_key
end

#itemObject (readonly)

Returns the value of attribute item.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def item
  @item
end

#notesObject (readonly)

Returns the value of attribute notes.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def notes
  @notes
end

#quantityObject (readonly)

Returns the value of attribute quantity.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def quantity
  @quantity
end

#typeObject (readonly)

Returns the value of attribute type.



18703
18704
18705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18703

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18721
18722
18723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18721

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

#to_hashObject



18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18725

def to_hash
  {
    :id => id,
    :idempotency_key => idempotency_key,
    :center => center.to_hash,
    :item => item.to_hash,
    :notes => notes,
    :quantity => quantity,
    :type => type.value
  }
end

#to_jsonObject



18717
18718
18719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18717

def to_json
  JSON.dump(to_hash)
end