11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/friendly_shipping/services/ship_engine_ltl/serialize_structures.rb', line 11
def 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)
{
code: package_options.packaging_code,
freight_class: package_options.freight_class,
nmfc_code: package_options.nmfc_code,
description: package.description || "Commodities",
dimensions: {
width: package.width.convert_to(:inches).value.ceil,
height: package.height.convert_to(:inches).value.ceil,
length: package.length.convert_to(:inches).value.ceil,
unit: "inches"
},
weight: {
value: package.weight.convert_to(:pounds).value.ceil,
unit: "pounds"
},
quantity: 1, stackable: package_options.stackable,
hazardous_materials: package_options.hazardous_materials
}
end
end
end
|