Sha256: 8db2c0649acdbfaa39a6cdaf1c6606a63f2133afab4b222eba73c223aca68e4a

Contents?: true

Size: 942 Bytes

Versions: 6

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class ShipEngine
      class SerializeRateEstimateRequest
        def self.call(shipment:, carriers:)
          {
            carrier_ids: carriers.map(&:id),
            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,
              unit: 'pound'
            },
            confirmation: 'none',
            address_residential_indicator: shipment.destination.residential? ? "yes" : "no"
          }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
friendly_shipping-0.3.4 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.3.3 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.3.0 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.2.6 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.2.5 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.2.4 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb