Class: FriendlyShipping::Services::ShipEngine::SerializeLabelShipment
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::ShipEngine::SerializeLabelShipment
- Defined in:
- lib/friendly_shipping/services/ship_engine/serialize_label_shipment.rb
Overview
Serializes a shipment and options for the label API request.
Class Method Summary collapse
-
.call(shipment:, options:, test:) ⇒ Hash
The serialized request.
Class Method Details
.call(shipment:, options:, test:) ⇒ Hash
13 14 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 41 42 43 |
# File 'lib/friendly_shipping/services/ship_engine/serialize_label_shipment.rb', line 13 def call(shipment:, options:, test:) shipment_hash = { label_format: .label_format, label_download_type: .label_download_type, shipment: { service_code: .shipping_method.service_code, ship_to: serialize_address(shipment.destination), ship_from: serialize_address(shipment.origin), packages: serialize_packages(shipment.packages, ) } } # A carrier might not be necessary if the service code is unique within ShipEngine. if .shipping_method.carrier shipment_hash[:shipment][:carrier_id] = .shipping_method.carrier.id end if international?(shipment) shipment_hash[:shipment][:customs] = serialize_customs(shipment.packages, ) end # Not all carriers support test labels if test shipment_hash[:test_label] = true end if .label_image_id shipment_hash[:label_image_id] = .label_image_id end shipment_hash end |