Class: FriendlyShipping::Services::TForceFreight::GenerateCommodityInformation

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

Overview

Generates a commodity information hash for JSON serialization.

Class Method Summary collapse

Class Method Details

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

Returns commodities hash suitable for JSON request.

Parameters:

  • shipment (Physical::Shipment)

    the shipment with commodities to serialize

  • options (#options_for_structure, #options_for_package)

    the options to serialize

Returns:

  • (Array<Hash>)

    commodities hash suitable for JSON request



12
13
14
15
16
17
18
19
# File 'lib/friendly_shipping/services/tforce_freight/generate_commodity_information.rb', line 12

def call(shipment:, options:)
  if shipment.structures.any?
    serialize_structures(shipment.structures, options)
  else
    warn "[DEPRECATION] `packages` is deprecated.  Please use `structures` instead."
    serialize_packages(shipment.packages, options)
  end
end