Sha256: 85d5aff13f2bda18e764f291cdfd6c5f511b49e64d695618ca697678b18fbce3

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class RL
      class BOLStructuresSerializer
        # @param [Array<Physical::Structure>] structures
        # @param [FriendlyShipping::Services::RL::BOLOptions] options
        # @return [Array<Hash>]
        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/rl/bol_structures_serializer.rb