Sha256: df11490058f4992a48a5fc59677182d24a3f6ca33727d083224c2a80ca8a1dc3

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'friendly_shipping/services/ups_freight/rates_item_options'

module FriendlyShipping
  module Services
    class UpsFreight
      # Options for packages/pallets within a UPS Freight shipment
      #
      # @attribute [Symbol] handling _unit How this shipment is divided. Any of the keys in `HANDLING_UNIT_TYPES`
      # @attribute [RatesItemOptions] item_options Options for each of the items on the pallet/in the carboy/etc.
      class RatesPackageOptions < FriendlyShipping::PackageOptions
        HANDLING_UNIT_TYPES = {
          pallet: { code: "PLT", description: "Pallet", handling_unit_tag: 'One' },
          skid: { code: "SKD", description: "Skid", handling_unit_tag: 'One' },
          carboy: { code: "CBY", description: "Carboy", handling_unit_tag: 'One' },
          totes: { code: "TOT", description: "Totes", handling_unit_tag: 'One' },
          other: { code: "OTH", description: "Other", handling_unit_tag: 'Two' },
          loose: { code: "LOO", description: "Loose", handling_unit_tag: 'Two' }
        }.freeze

        attr_reader :handling_unit_description,
                    :handling_unit_tag,
                    :handling_unit_code

        def initialize(
          handling_unit: :pallet,
          **kwargs
        )
          @handling_unit_code = HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:code)
          @handling_unit_description = HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:description)
          @handling_unit_tag = "HandlingUnit#{HANDLING_UNIT_TYPES.fetch(handling_unit).fetch(:handling_unit_tag)}"
          super(**kwargs.merge(item_options_class: RatesItemOptions))
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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