Class: FriendlyShipping::Services::UpsFreight::GenerateFreightShipRequestHash

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/ups_freight/generate_freight_ship_request_hash.rb

Class Method Summary collapse

Class Method Details

.call(shipment:, options:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/friendly_shipping/services/ups_freight/generate_freight_ship_request_hash.rb', line 15

def call(shipment:, options:)
  {
    FreightShipRequest: {
      Shipment: {
        ShipperNumber: options.shipper_number,
        ShipFrom: GenerateLocationHash.call(location: shipment.origin),
        ShipTo: GenerateLocationHash.call(location: shipment.destination),
        PaymentInformation: payment_information(options),
        Service: {
          Code: options.shipping_method.service_code
        },
        Commodity: options.commodity_information_generator.call(shipment: shipment, options: options),
        Documents: {
          Image: options.document_options.map { |doc_opts| GenerateDocumentOptionsHash.call(document_options: doc_opts) }
        },
        ShipmentServiceOptions: shipment_service_options(options),
        HandlingInstructions: options.handling_instructions,
        PickupInstructions: options.pickup_instructions,
        DeliveryInstructions: options.delivery_instructions,
        PickupRequest: GeneratePickupRequestHash.call(pickup_request_options: options.pickup_request_options),
      }.compact.
        merge(handling_units(shipment, options).reduce(&:merge).to_h).
        merge(GenerateReferenceHash.call(reference_numbers: options.reference_numbers))
    }
  }
end