Class: FriendlyShipping::Services::Ups::SerializeAddressSnippet
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::Ups::SerializeAddressSnippet
show all
- Defined in:
- lib/friendly_shipping/services/ups/serialize_address_snippet.rb
Class Method Summary
collapse
Class Method Details
.call(xml:, location:, international: false) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/friendly_shipping/services/ups/serialize_address_snippet.rb', line 8
def call(xml:, location:, international: false)
if international
name = (location.company_name || location.name)[0..34]
attention_name = location.name
elsif location.company_name name = location.company_name[0..34]
attention_name = location.name
else
name = location.name
attention_name = nil
end
if xml.parent.name == "Shipper"
xml.Name(name)
else
xml.CompanyName(name)
end
if attention_name
xml.AttentionName(attention_name)
end
xml.PhoneNumber(location.phone) if location.phone
xml.Address do
xml.AddressLine1(location.address1) if location.address1
xml.AddressLine2(location.address2) if location.address2
xml.City(location.city) if location.city
xml.PostalCode(location.zip) if location.zip
xml.StateProvinceCode(location.region.code) if location.region
xml.CountryCode(location.country.code) if location.country
residential_address_indicator(xml, location)
end
end
|