class ShipCompliant::InventoryProduct
ShipCompliant::InventoryProduct
¶ ↑
InventoryProduct
is a value object that has methods to access product data from GetInventoryDetails
.
products = @inventory_results.products_for_location('WineShipping') products.each do |product| puts "[%s] %s" % [product.product_key, product.description] product.inventory_levels.each do |type, quantity| puts "%s are %s" % [quantity, type] end end
Public Instance Methods
default_case()
click to toggle source
Returns the DefaultCase
of a product.
# File lib/ship_compliant/inventory_product.rb, line 18 def default_case product[:default_case] end
description()
click to toggle source
Returns the Description
of a product.
# File lib/ship_compliant/inventory_product.rb, line 33 def description product[:description] end
fulfillment_sku()
click to toggle source
Returns the FulfillmentSku
of a product.
# File lib/ship_compliant/inventory_product.rb, line 43 def fulfillment_sku product[:fulfillment_sku] end
inventory_levels()
click to toggle source
Returns a Hash of inventory levels.
-
The key is the
InventoryType
. -
The value is
Quantity
as a float.product.inventory_levels #=> { available: 2, on_hold: 2, back_order: 4 }
# File lib/ship_compliant/inventory_product.rb, line 82 def inventory_levels levels = {} product[:inventory_levels][:inventory_level].each do |level| key = level[:inventory_type].underscore.to_sym value = level[:quantity].to_f levels[key] = value end levels end
percent_alcohol()
click to toggle source
Returns the PercentAlcohol
of a product as a float.
# File lib/ship_compliant/inventory_product.rb, line 48 def percent_alcohol product[:percent_alcohol].to_f end
product_key()
click to toggle source
Returns the ProductKey
of a product.
# File lib/ship_compliant/inventory_product.rb, line 23 def product_key product[:product_key] end
product_type()
click to toggle source
Returns the ProductType
of a product.
# File lib/ship_compliant/inventory_product.rb, line 28 def product_type product[:product_type] end
unit_price()
click to toggle source
Returns the UnitPrice
of a product as a float.
# File lib/ship_compliant/inventory_product.rb, line 38 def unit_price product[:unit_price].to_f end
vintage()
click to toggle source
Returns the Vintage
of a product as an integer.
# File lib/ship_compliant/inventory_product.rb, line 53 def vintage product[:vintage].to_i end
volume_amount()
click to toggle source
Returns the VolumeAmount
of a product as a float.
# File lib/ship_compliant/inventory_product.rb, line 58 def volume_amount product[:volume_amount].to_f end
volume_ml()
click to toggle source
Returns the VolumeML
of a product as a float.
# File lib/ship_compliant/inventory_product.rb, line 63 def volume_ml product[:volume_ml].to_f end
volume_unit()
click to toggle source
Returns the VolumeUnit
of a product.
# File lib/ship_compliant/inventory_product.rb, line 68 def volume_unit product[:volume_unit] end