class ShipCompliant::GetInventoryDetailsResult
ShipCompliant::GetInventoryDetailsResult
¶ ↑
Wraps the result of GetInventoryDetails
and provides methods to access locations and products for a location
Public Instance Methods
location(key)
click to toggle source
Finds a location by FulfillmentLocation
.
result.location('WineShipping')[:supplier] #=> 'LOCATION-SUPPLIER'
# File lib/ship_compliant/get_inventory_details_result.rb, line 21 def location(key) location = locations.select { |l| l[:fulfillment_location] == key }.first return {} if location.nil? location end
locations()
click to toggle source
Returns an array of InventoryLocation
nodes.
result.locations[0][:sub_inventory_code] #=> 'SUB-CODE'
# File lib/ship_compliant/get_inventory_details_result.rb, line 12 def locations Array.wrap(response[:inventory_locations]).map do |location| location[:inventory_location] end end
products_for_location(key)
click to toggle source
Returns an array of ShipCompliant::InventoryProduct
.
result.products_for_location('WineShipping').each do |product| puts product.product_key puts "\t#{product.description}" puts "---\n" end
# File lib/ship_compliant/get_inventory_details_result.rb, line 35 def products_for_location(key) Array.wrap(location(key)[:inventory_products]).map do |product| InventoryProduct.new(product[:inventory_product]) end end