Class: FriendlyShipping::Services::ShipEngine::SerializeRateEstimateRequest
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::ShipEngine::SerializeRateEstimateRequest
- Defined in:
- lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
Overview
Serializes a shipment and options for the rate estimates 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 |
# File 'lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb', line 12 def call(shipment:, options:) { carrier_ids: .carrier_ids, from_country_code: shipment.origin.country.alpha_2_code, from_postal_code: shipment.origin.zip, to_country_code: shipment.destination.country.alpha_2_code, to_postal_code: shipment.destination.zip, to_city_locality: shipment.destination.city, to_state_province: shipment.destination.region.code, weight: { value: shipment.packages.map { |p| p.weight.convert_to(:pound).value.to_f }.sum.round(2), unit: 'pound' }, dimensions: dimensions(shipment.packages), confirmation: 'none', ship_date: .ship_date.strftime('%Y-%m-%d'), }.merge(SerializeAddressResidentialIndicator.call(shipment.destination)).compact_blank end |