Sha256: 0977da6b76f39c9ce46049dd73ce7c498928ff6f6a00d34ca4ca6c3aae93efb0

Contents?: true

Size: 1.06 KB

Versions: 31

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class UpsFreight
      class GenerateCommodityInformation
        def self.call(shipment:, options:)
          shipment.packages.flat_map do |package|
            package_options = options.options_for_package(package)
            package.items.map do |item|
              item_options = package_options.options_for_item(item)
              {
                # This is a required field
                Description: item.description || 'Commodities',
                Weight: {
                  UnitOfMeasurement: {
                    Code: 'LBS' # Only Pounds are supported
                  },
                  Value: item.weight.convert_to(:pounds).value.to_f.round(2).to_s
                },
                NumberOfPieces: '1', # We won't support this yet.
                PackagingType: {
                  Code: item_options.packaging_code
                },
                FreightClass: item_options.freight_class
              }
            end
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
friendly_shipping-0.8.1 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.8.0 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.5 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.4 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.3 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.2 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.1 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.6.0 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.5.3 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.5.2 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.5.1 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.5 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.4.14 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.4.13 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.4.12 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb
friendly_shipping-0.4.11 lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb