Class: FriendlyShipping::Services::ShipEngineLTL::SerializeQuoteRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/ship_engine_ltl/serialize_quote_request.rb

Overview

Serializes a shipment and options for the rate quote API request.

Class Method Summary collapse

Class Method Details

.call(shipment:, options:) ⇒ Hash

Returns the serialized request.

Parameters:

  • shipment (Physical::Shipment)

    the shipment to serialize

  • options (QuoteOptions)

    the options to serialize

Returns:

  • (Hash)

    the serialized request



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

def call(shipment:, options:)
  {
    shipment: {
      service_code: options.service_code,
      pickup_date: options.pickup_date.strftime('%Y-%m-%d'),
      packages: serialize_packages(shipment, options),
      options: serialize_options(options),
      ship_from: serialize_ship_address(shipment.origin),
      ship_to: serialize_ship_address(shipment.destination),
      bill_to: serialize_bill_address(shipment.origin),
      requested_by: serialize_requested_by(shipment.origin),
    }.compact,
    shipment_measurements: serialize_shipment_measurements(shipment, options)
  }
end