Class: FriendlyShipping::Services::RL::RateQuoteStructuresSerializer

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

Class Method Summary collapse

Class Method Details

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

Parameters:

Returns:

  • (Array<Hash>)


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

def call(structures:, options:)
  item_hashes = 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)
      {
        Class: package_options.freight_class,
        Height: package.height.convert_to(:inches),
        Length: package.length.convert_to(:inches),
        Weight: package.weight.convert_to(:pounds),
        Width: package.width.convert_to(:inches)
      }
    end
  end
  group_items(item_hashes)
end