Class: FriendlyShipping::Services::RL::BOLStructuresSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/rl/bol_structures_serializer.rb

Class Method Summary collapse

Class Method Details

.call(structures:, options:) ⇒ Array<Hash>

Parameters:

Returns:

  • (Array<Hash>)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/friendly_shipping/services/rl/bol_structures_serializer.rb', line 10

def self.call(structures:, options:)
  structures.flat_map do |structure|
    structure_options = options.options_for_structure(structure)
    structure.packages.map do |package|
      package_options = structure_options.options_for_package(package)
      {
        IsHazmat: false,
        Pieces: 1,
        PackageType: "BOX",
        NMFCItemNumber: package_options.nmfc_primary_code,
        NMFCSubNumber: package_options.nmfc_sub_code,
        Class: package_options.freight_class,
        Weight: package.weight.convert_to(:pounds).value.ceil,
        Description: package.description.presence || "Commodities"
      }.compact
    end
  end
end