Sha256: 20b6ddd680ada3a02bc813c4554eea0876fd08617236bdfa38c4cbcd277f6b62

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class TForceFreight
      # Generates a location hash for JSON serialization.
      class GenerateLocationHash
        class << self
          # @param location [Physical::Location] the location
          # @return [Hash] location hash suitable for JSON request
          def call(location:)
            {
              address: {
                city: location.city,
                stateProvinceCode: location.region&.code,
                postalCode: location.zip&.strip&.[](0..4),
                country: location.country&.code
              }.compact
            }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/tforce_freight/generate_location_hash.rb