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.



31216
31217
31218
31219
31220
31221
31222
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31216

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.



31214
31215
31216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31214

def item_number
  @item_number
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



31214
31215
31216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31214

def line_number
  @line_number
end

#quantitiesObject (readonly)

Returns the value of attribute quantities.



31214
31215
31216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31214

def quantities
  @quantities
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31228
31229
31230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31228

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

#to_hashObject



31232
31233
31234
31235
31236
31237
31238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31232

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

#to_jsonObject



31224
31225
31226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31224

def to_json
  JSON.dump(to_hash)
end