Sha256: 2625edab7a1c180292369b651aa597cffee3db863cb26e547668be954ba3170b

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class UpsFreight
      class GenerateLocationHash
        class << self
          def call(location:)
            # We ship freight here, which will mostly be used for businesses.
            # If a personal name is given, treat is as the contact person ("AttentionName")
            {
              Name: location.company_name,
              Address: {
                AddressLine: address_line(location),
                City: location.city,
                StateProvinceCode: location.region.code,
                PostalCode: location.zip,
                CountryCode: location.country.code
              },
              AttentionName: location.name
            }
          end

          private

          def address_line(location)
            [
              location.address1,
              location.address2,
              location.address3
            ].compact.
              reject(&:empty?).
              join(", ")
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
friendly_shipping-0.5.2 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.5.1 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.5 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.14 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.13 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.12 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.11 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.10 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.9 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.8 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.7 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.6 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.5 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.4 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.3 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.2 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.1 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb
friendly_shipping-0.4.0 lib/friendly_shipping/services/ups_freight/generate_location_hash.rb