Class: FriendlyShipping::Services::ShipEngine::CustomsItemsSerializer
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::ShipEngine::CustomsItemsSerializer
- Defined in:
- lib/friendly_shipping/services/ship_engine/customs_items_serializer.rb
Overview
Serializes customs items for international labels.
Class Method Summary collapse
-
.call(packages, options) ⇒ Array<Hash>
The serialized customs items.
Class Method Details
.call(packages, options) ⇒ Array<Hash>
Returns the serialized customs items.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/friendly_shipping/services/ship_engine/customs_items_serializer.rb', line 12 def call(packages, ) packages.map do |package| package.items.group_by(&:sku).map do |sku, items| reference_item = items.first = .(package) = .(reference_item) { sku: sku, description: reference_item.description, quantity: items.count, value: { amount: reference_item.cost.to_d, currency: reference_item.cost.currency.to_s }, harmonized_tariff_code: .commodity_code, country_of_origin: .country_of_origin } end end.flatten end |