Method: ActiveShipping::UPS#build_address_validation_request

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

#build_address_validation_request(location, options = {}) ⇒ Object (protected)



984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/active_shipping/carriers/ups.rb', line 984

def build_address_validation_request(location, options = {})
  xml_builder = Nokogiri::XML::Builder.new do |xml|
    xml.AddressValidationRequest do
      xml.Request do
        xml.RequestAction('XAV')
        xml.RequestOption('3')

        if options[:customer_context]
          xml.TransactionReference do
            xml.CustomerContext(options[:customer_context])
            xml.XpciVersion("1.0")
          end
        end
      end

      xml.AddressKeyFormat do
        xml.AddressLine(location.address1)
        if location.address2.present?
          xml.AddressLine(location.address2)
        end
        xml.PoliticalDivision2(location.city)
        xml.PoliticalDivision1(location.state)
        xml.PostcodePrimaryLow(location.postal_code)
        xml.CountryCode(mapped_country_code(location.country_code))
      end
    end
  end

  xml_builder.to_xml
end