class FriendlyShipping::Services::Usps::SerializeAddressValidationRequest

Public Class Methods

call(location:, login:) click to toggle source
# File lib/friendly_shipping/services/usps/serialize_address_validation_request.rb, line 7
def self.call(location:, login:)
  xml_builder = Nokogiri::XML::Builder.new do |xml|
    xml.AddressValidateRequest USERID: login do
      xml.Address do
        xml.Address1 location.address2 # USPS swaps Address1 and Address2 in the request
        xml.Address2 location.address1
        xml.City location.city
        xml.State location.region.code
        xml.Zip5 location.zip
        xml.Zip4
      end
    end
  end
  xml_builder.to_xml
end