Class: FriendlyShipping::Services::Usps::SerializeAddressValidationRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/usps/serialize_address_validation_request.rb

Class Method Summary collapse

Class Method Details

.call(location:, login:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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:  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