Class: Io::Flow::V0::Models::InventoryUpdateForm

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

Overview

Form used to create an update on inventory. If inventory for center/item has not been previously created, a new row is created for the center/item tuple.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ InventoryUpdateForm

Returns a new instance of InventoryUpdateForm.



18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18701

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:center, :idempotency_key, :item_number, :quantity, :type], 'InventoryUpdateForm')
  @center = HttpClient::Preconditions.assert_class('center', opts.delete(:center), String)
  @idempotency_key = HttpClient::Preconditions.assert_class('idempotency_key', opts.delete(:idempotency_key), String)
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @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))
  @notes = (x = opts.delete(:notes); x.nil? ? nil : HttpClient::Preconditions.assert_class('notes', HttpClient::Helper.to_object(x), Hash))
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def center
  @center
end

#idempotency_keyObject (readonly)

Returns the value of attribute idempotency_key.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def idempotency_key
  @idempotency_key
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def item_number
  @item_number
end

#notesObject (readonly)

Returns the value of attribute notes.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def notes
  @notes
end

#quantityObject (readonly)

Returns the value of attribute quantity.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def quantity
  @quantity
end

#typeObject (readonly)

Returns the value of attribute type.



18699
18700
18701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



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

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

#to_hashObject



18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18720

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

#to_jsonObject



18712
18713
18714
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18712

def to_json
  JSON.dump(to_hash)
end