Class: FriendlyShipping::Services::UpsFreight::GenerateLocationHash

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/ups_freight/generate_location_hash.rb

Class Method Summary collapse

Class Method Details

.call(location:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/friendly_shipping/services/ups_freight/generate_location_hash.rb', line 8

def call(location:)
  {
    Name: truncate(location.company_name.presence || location.name),
    Address: {
      AddressLine: address_line(location),
      City: truncate(location.city, length: 29),
      StateProvinceCode: location.region&.code,
      PostalCode: location.zip,
      CountryCode: location.country&.code
    },
    AttentionName: truncate(location.name),
    Phone: {
      Number: truncate(location.phone, length: 14)
    }.compact.presence
  }.compact
end