Class: FriendlyShipping::Services::UpsFreight::RatesPackageOptions

Inherits:
PackageOptions
  • Object
show all
Defined in:
lib/friendly_shipping/services/ups_freight/rates_package_options.rb

Overview

Options for packages/pallets within a UPS Freight shipment

Direct Known Subclasses

LabelPackageOptions

Constant Summary collapse

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

Instance Attribute Summary collapse

Attributes inherited from PackageOptions

#package_id

Instance Method Summary collapse

Methods inherited from PackageOptions

#options_for_item

Constructor Details

#initialize(handling_unit: :pallet, **kwargs) ⇒ RatesPackageOptions

Returns a new instance of RatesPackageOptions.



26
27
28
29
30
31
32
33
34
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 26

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

Instance Attribute Details

#handling_unit_codeObject (readonly)

Returns the value of attribute handling_unit_code.



22
23
24
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 22

def handling_unit_code
  @handling_unit_code
end

#handling_unit_descriptionObject (readonly)

Returns the value of attribute handling_unit_description.



22
23
24
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 22

def handling_unit_description
  @handling_unit_description
end

#handling_unit_tagObject (readonly)

Returns the value of attribute handling_unit_tag.



22
23
24
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 22

def handling_unit_tag
  @handling_unit_tag
end

Instance Method Details

#handling _unit How this shipment is divided. Any of the keys in `HANDLING_UNIT_TYPES`=(_unitHowthisshipmentisdivided.Anyofthekeys) ⇒ Object

Options for packages/pallets within a UPS Freight shipment



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 12

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

#item_options Options for each of the items on the pallet/in the carboy/etc.=(Options) ⇒ Object

Options for packages/pallets within a UPS Freight shipment



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/friendly_shipping/services/ups_freight/rates_package_options.rb', line 12

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