Sha256: 9658f096190127598b5d0f68226b980d6f8a8aec3d587a296a8a635da4975b50

Contents?: true

Size: 1.66 KB

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
friendly_shipping-0.4.8 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.7 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.6 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.5 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.4 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.3 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.2 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.1 lib/friendly_shipping/services/ups_freight/rates_package_options.rb
friendly_shipping-0.4.0 lib/friendly_shipping/services/ups_freight/rates_package_options.rb