8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/friendly_shipping/services/ups_json/generate_address_hash.rb', line 8
def call(location:, international: false, shipper_number: nil)
snippet = {}
attention_name = location.name if international || location.company_name
snippet[:AttentionName] = attention_name if attention_name
snippet[:Name] = (location.company_name || location.name)&.slice(0..34)
snippet[:ShipperNumber] = shipper_number if shipper_number.present?
snippet[:Phone] = { Number: location.phone } if location.phone
snippet[:Address] = {
AddressLine: [location.address1, location.address2, location.address3].compact,
City: location.city,
PostalCode: location.zip,
StateProvinceCode: location.region&.code,
CountryCode: location.country&.code,
ResidentialAddressIndicator: location.commercial? ? nil : 'X'
}.compact
snippet.compact
end
|