Class: FriendlyShipping::Services::TForceFreight::PackageOptions

Inherits:
PackageOptions
  • Object
show all
Defined in:
lib/friendly_shipping/services/tforce_freight/package_options.rb

Overview

Options for packages/pallets in a shipment.

Constant Summary collapse

PACKAGING_TYPES =

Maps friendly names to packaging types.

{
  bag: { code: "BAG", description: "Bag" },
  bale: { code: "BAL", description: "Bale" },
  barrel: { code: "BAR", description: "Barrel" },
  bundle: { code: "BDL", description: "Bundle" },
  bin: { code: "BIN", description: "Bin" },
  box: { code: "BOX", description: "Box" },
  basket: { code: "BSK", description: "Basket" },
  bunch: { code: "BUN", description: "Bunch" },
  cabinet: { code: "CAB", description: "Cabinet" },
  can: { code: "CAN", description: "Can" },
  carrier: { code: "CAR", description: "Carrier" },
  case: { code: "CAS", description: "Case" },
  carboy: { code: "CBY", description: "Carboy" },
  container: { code: "CON", description: "Container" },
  crate: { code: "CRT", description: "Crate" },
  cask: { code: "CSK", description: "Cask" },
  carton: { code: "CTN", description: "Carton" },
  cylinder: { code: "CYL", description: "Cylinder" },
  drum: { code: "DRM", description: "Drum" },
  loose: { code: "LOO", description: "Loose" },
  other: { code: "OTH", description: "Other" },
  pail: { code: "PAL", description: "Pail" },
  pieces: { code: "PCS", description: "Pieces" },
  package: { code: "PKG", description: "Package" },
  pipe_line: { code: "PLN", description: "Pipe Line" },
  pallet: { code: "PLT", description: "Pallet" },
  rack: { code: "RCK", description: "Rack" },
  reel: { code: "REL", description: "Reel" },
  roll: { code: "ROL", description: "Roll" },
  skid: { code: "SKD", description: "Skid" },
  spool: { code: "SPL", description: "Spool" },
  tube: { code: "TBE", description: "Tube" },
  tank: { code: "TNK", description: "Tank" },
  totes: { code: "TOT", description: "Totes" },
  unit: { code: "UNT", description: "Unit" },
  van_pack: { code: "VPK", description: "Van Pack" },
  wrapped: { code: "WRP", description: "Wrapped" }
}.freeze
HANDLING_UNIT_TYPES =

Maps friendly names to 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(packaging: :carton, freight_class: nil, nmfc_primary_code: nil, nmfc_sub_code: nil, hazardous: false, handling_unit: :pallet, **kwargs) ⇒ PackageOptions

Returns a new instance of PackageOptions.

Parameters:

  • packaging (Symbol) (defaults to: :carton)

    this item's packaging

  • freight_class (String) (defaults to: nil)

    the freight class

  • nmfc_primary_code (String) (defaults to: nil)

    the NMFC primary code

  • nmfc_sub_code (String) (defaults to: nil)

    the NMFC sub code

  • hazardous (Boolean) (defaults to: false)

    whether or not the item is hazardous

  • handling_unit (Symbol) (defaults to: :pallet)

    the handling unit for this package/pallet

  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_id (String)

    the ID for the package that belongs to these options

  • :item_options (Array<ItemOptions>)

    the options for items in this package

  • :item_options_class (Class)

    the class to use for item options when none are provided



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 98

def initialize(
  packaging: :carton,
  freight_class: nil,
  nmfc_primary_code: nil,
  nmfc_sub_code: nil,
  hazardous: false,
  handling_unit: :pallet,
  **kwargs
)
  @packaging_code = PACKAGING_TYPES.fetch(packaging).fetch(:code)
  @packaging_description = PACKAGING_TYPES.fetch(packaging).fetch(:description)
  @freight_class = freight_class
  @nmfc_primary_code = nmfc_primary_code
  @nmfc_sub_code = nmfc_sub_code
  @hazardous = hazardous
  @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.reverse_merge(item_options_class: ItemOptions))
end

Instance Attribute Details

#freight_classString (readonly)

Returns the freight class.

Returns:

  • (String)

    the freight class



68
69
70
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 68

def freight_class
  @freight_class
end

#handling_unit_codeString (readonly)

Returns the handling unit code.

Returns:

  • (String)

    the handling unit code



86
87
88
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 86

def handling_unit_code
  @handling_unit_code
end

#handling_unit_descriptionString (readonly)

Returns the handling unit description.

Returns:

  • (String)

    the handling unit description



80
81
82
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 80

def handling_unit_description
  @handling_unit_description
end

#handling_unit_tagString (readonly)

Returns the handling unit tag.

Returns:

  • (String)

    the handling unit tag



83
84
85
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 83

def handling_unit_tag
  @handling_unit_tag
end

#hazardousBoolean (readonly)

Returns whether or not the item is hazardous.

Returns:

  • (Boolean)

    whether or not the item is hazardous



77
78
79
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 77

def hazardous
  @hazardous
end

#nmfc_primary_codeString (readonly)

Returns the NMFC primary code.

Returns:

  • (String)

    the NMFC primary code



71
72
73
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 71

def nmfc_primary_code
  @nmfc_primary_code
end

#nmfc_sub_codeString (readonly)

Returns the NMFC sub code.

Returns:

  • (String)

    the NMFC sub code



74
75
76
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 74

def nmfc_sub_code
  @nmfc_sub_code
end

#packaging_codeSymbol (readonly)

Returns the code for this item's packaging.

Returns:

  • (Symbol)

    the code for this item's packaging



62
63
64
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 62

def packaging_code
  @packaging_code
end

#packaging_descriptionString (readonly)

Returns the description for this item's packaging.

Returns:

  • (String)

    the description for this item's packaging



65
66
67
# File 'lib/friendly_shipping/services/tforce_freight/package_options.rb', line 65

def packaging_description
  @packaging_description
end