Class: FriendlyShipping::Services::TForceFreight::GenerateCreateBOLRequestHash

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

Overview

Generates a Bill of Lading (BOL) request hash for JSON serialization.

Class Method Summary collapse

Class Method Details

.call(shipment:, options:) ⇒ Hash

Returns BOL request hash.

Parameters:

  • shipment (Physical::Shipment)

    the shipment for which we want to create a BOL

  • options (BOLOptions)

    options for the BOL

Returns:

  • (Hash)

    BOL request hash



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

def call(shipment:, options:)
  origin = shipment.origin
  destination = shipment.destination
  {
    requestOptions: request_options(options),
    shipFrom: location(origin).merge(isResidential: origin.residential?),
    shipTo: location(destination).merge(isResidential: destination.residential?),
    payment: payment(origin, options),
    commodities: options.commodity_information_generator.call(shipment: shipment, options: options),
    instructions: instructions(options),
    serviceOptions: service_options(options),
    pickupRequest: pickup_request(origin, options),
    documents: { image: documents(options.document_options) }
  }.compact.
    merge(GenerateHandlingUnitsHash.call(shipment: shipment, options: options)).
    merge(GenerateReferenceHash.call(reference_numbers: options.reference_numbers))
end