Class: FriendlyShipping::Services::ShipEngine::SerializeRatesRequest
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::ShipEngine::SerializeRatesRequest
- Defined in:
- lib/friendly_shipping/services/ship_engine/serialize_rates_request.rb
Overview
Serializes a shipment and options for the rates API request.
Class Method Summary collapse
-
.call(shipment:, options:) ⇒ Hash
The serialized request.
Class Method Details
.call(shipment:, options:) ⇒ Hash
Returns the serialized request.
12 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 |
# File 'lib/friendly_shipping/services/ship_engine/serialize_rates_request.rb', line 12 def call(shipment:, options:) rates_hash = { shipment: { carrier_ids: .carrier_ids, service_code: .service_code, ship_date: .ship_date.strftime('%Y-%m-%d'), ship_to: serialize_address(shipment.destination), ship_from: serialize_address(shipment.origin), items: serialize_items(shipment.packages.first), packages: serialize_packages(shipment, ), comparison_rate_type: .comparison_rate_type, confirmation: 'none' }.merge(SerializeAddressResidentialIndicator.call(shipment.destination)).compact_blank, rate_options: { carrier_ids: .carrier_ids, service_codes: [.service_code], } } if international?(shipment) rates_hash[:shipment][:customs] = { contents: "merchandise", non_delivery: "return_to_sender", } end rates_hash end |