class Scrub::Order
Public Class Methods
new(order_data)
click to toggle source
# File lib/scrubdeku.rb, line 136 def initialize(order_data) @data = order_data[:orders_get_data_response][:orders_get_data_result] end
Public Instance Methods
kit_listing()
click to toggle source
# File lib/scrubdeku.rb, line 154 def kit_listing productTable = {} orderData = @data[:order][:items][:order_item] if orderData.kind_of? Array orderData.each do |item| begin buildout = {} item[:bundle_items][:order_bundle_item].each do |bundleItem| buildout.merge!("#{bundleItem[:product_id]}" => {'qtyEach' => bundleItem[:qty], 'qtyTotal' => bundleItem[:total_qty]}) end productTable[item[:product_id]] = {"qty" => item[:qty], "description" => item[:display_name], 'components' => buildout} rescue NoMethodError next end end elsif orderData.kind_of? Hash buildout = {} orderData[:bundle_items][:order_bundle_item].each do |bundleItem| buildout.merge!("#{bundleItem[:product_id]}" => {'qtyEach' => bundleItem[:qty], 'qtyTotal' => bundleItem[:total_qty]}) end productTable[orderData[:product_id]] = {"qty" => orderData[:qty], "description" => orderData[:display_name], 'components' => buildout} end return productTable end
order_subtotal()
click to toggle source
# File lib/scrubdeku.rb, line 179 def order_subtotal return @data[:order][:sub_total] end
products()
click to toggle source
# File lib/scrubdeku.rb, line 140 def products productTable = {} orderData = @data[:order][:items][:order_item] if orderData.kind_of? Array orderData.each do |item| productTable[item[:product_id]] = {"qty" => item[:qty], "description" => item[:display_name]} end elsif orderData.kind_of? Hash productTable[orderData[:product_id]] = {"qty" => orderData[:qty], "description" => orderData[:display_name]} end return productTable end
raw()
click to toggle source
# File lib/scrubdeku.rb, line 200 def raw @data end
warehouse_dollar_totals()
click to toggle source
# File lib/scrubdeku.rb, line 183 def warehouse_dollar_totals warehouse_totals = {} order_items = @data[:order][:items][:order_item] if order_items.kind_of? Array order_items.each do |item| if warehouse_totals["#{item[:ship_from_ware_house_id]}"] warehouse_totals["#{item[:ship_from_ware_house_id]}"] += item[:line_total].to_f else warehouse_totals["#{item[:ship_from_ware_house_id]}"] = item[:line_total].to_f end end else warehouse_totals["#{order_items[:ship_from_ware_house_id]}"] = order_items[:line_total].to_f end return warehouse_totals end