Sha256: f36f4bb7bd38ac2a98a1cb5ef0082896163c3b38b887bc12f7344ffb6e2e6c4c

Contents?: true

Size: 942 Bytes

Versions: 31

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
friendly_shipping-0.8.1 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.8.0 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.5 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.4 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.3 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.2 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.1 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.6.0 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.5.3 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.5.2 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.5.1 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.5 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.4.14 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.4.13 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.4.12 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb
friendly_shipping-0.4.11 lib/friendly_shipping/services/ship_engine/serialize_rate_estimate_request.rb