class FriendlyShipping::Services::Ups::SerializeAddressValidationRequest

Constants

REQUEST_ACTION
REQUEST_OPTIONS

Attributes

location[R]

Public Class Methods

call(location:) click to toggle source
# File lib/friendly_shipping/services/ups/serialize_address_validation_request.rb, line 16
def self.call(location:)
  xml_builder = Nokogiri::XML::Builder.new do |xml|
    xml.AddressValidationRequest do
      xml.Request do
        xml.RequestAction REQUEST_ACTION
        xml.RequestOption REQUEST_OPTIONS[:both]
      end

      xml.AddressKeyFormat do
        xml.ConsigneeName(location.company_name.presence || location.name)
        xml.AddressLine location.address1
        xml.AddressLine location.address2
        xml.PoliticalDivision2 location.city
        xml.PoliticalDivision1 location.region.code
        xml.PostcodePrimaryLow location.zip
        xml.CountryCode location.country.code
      end
    end
  end
  xml_builder.to_xml
end