Class: Io::Flow::V0::Models::FulfillmentItem

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

Overview

Used to track and manage the fulfillment of quantities of a sku

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ FulfillmentItem

Returns a new instance of FulfillmentItem.



18929
18930
18931
18932
18933
18934
18935
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18929

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item_number, :line_number, :quantities], 'FulfillmentItem')
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @line_number = HttpClient::Preconditions.assert_class('line_number', opts.delete(:line_number), Integer)
  @quantities = HttpClient::Preconditions.assert_class('quantities', opts.delete(:quantities), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FulfillmentItemQuantity) ? x : ::Io::Flow::V0::Models::FulfillmentItemQuantity.new(x)) }
end

Instance Attribute Details

#item_numberObject (readonly)

Returns the value of attribute item_number.



18927
18928
18929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18927

def item_number
  @item_number
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



18927
18928
18929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18927

def line_number
  @line_number
end

#quantitiesObject (readonly)

Returns the value of attribute quantities.



18927
18928
18929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18927

def quantities
  @quantities
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18941
18942
18943
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18941

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

#to_hashObject



18945
18946
18947
18948
18949
18950
18951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18945

def to_hash
  {
    :item_number => item_number,
    :line_number => line_number,
    :quantities => quantities.map { |o| o.to_hash }
  }
end

#to_jsonObject



18937
18938
18939
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18937

def to_json
  JSON.dump(to_hash)
end