Sha256: 64a2a3f764c96e208898990070fd75b2e3d98a43af68e91a6761477d8638a6be
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module FriendlyShipping module Services class ShipEngine # Serializes customs items for international labels. class CustomsItemsSerializer class << self # @param packages [Array<Physical::Package>] the packages to serialize # @param options [LabelOptions] options for the packages # @return [Array<Hash>] the serialized customs items def call(packages, options) packages.map do |package| package.items.group_by(&:sku).map do |sku, items| reference_item = items.first package_options = options.options_for_package(package) item_options = package_options.options_for_item(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: item_options.commodity_code, country_of_origin: item_options.country_of_origin } end end.flatten end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.9.0 | lib/friendly_shipping/services/ship_engine/customs_items_serializer.rb |