Method: ActiveShipping::UPS#location_from_address_node

Defined in:
lib/active_shipping/carriers/ups.rb

#location_from_address_node(address) ⇒ Object (protected)



1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
# File 'lib/active_shipping/carriers/ups.rb', line 1075

def location_from_address_node(address)
  return nil unless address
  country = address.at('CountryCode').try(:text)
  country = 'US' if country == 'ZZ' # Sometimes returned by SUREPOST in the US
  country = 'XK' if country == 'KV' # ActiveUtils now refers to Kosovo by XK
  Location.new(
    :country     => country,
    :postal_code => address.at('PostalCode').try(:text),
    :province    => address.at('StateProvinceCode').try(:text),
    :city        => address.at('City').try(:text),
    :address1    => address.at('AddressLine1').try(:text),
    :address2    => address.at('AddressLine2').try(:text),
    :address3    => address.at('AddressLine3').try(:text)
  )
end