logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Business::US::USPS::WebTools::AddressStandardization - canonicalize a US address

Author

       brian d foy

Description

       *** THIS IS ALPHA SOFTWARE ***

       This module implements the Address Standardization web service from the US Postal Service. It is a
       subclass of Business::US::USPS::WebTools.

       verify_address( KEY, VALUE, ... )
           The  "verify_address"  method takes the following keys, which come directly from the USPS web service
           interface:

                   FirmName        The name of the company
                   Address1        The suite or apartment
                   Address2        The street address
                   City            The name of the city
                   State           The two letter state abbreviation
                   Zip5            The 5 digit ZIP code
                   Zip4            The 4 digit extension to the ZIP code

           It returns an anonymous hash with the same keys, but the values are the USPS's canonicalized address,
           plus three additional keys:

                   DeliveryPoint   The 2 digit extension to the ZIP+4 code
                   CarrierRoute    The 4 character postal carrier route
                   ReturnText      An error message when multiple addresses are found

           If there is an error, the hash values will be the empty string, and the error flag is set.  Check  is
           with "is_error":

                   $verifier->is_error;

           See   the  "is_error"  documentation  in  Business::US::USPS::WebTools  for  more  details  on  error
           information.

Maintainer

       Steve Simms

Name

       Business::US::USPS::WebTools::AddressStandardization - canonicalize a US address

See Also

       Business::US::USPS::WebTools

       The WebTools API is documented on the US Postal Service's website:

               https://www.usps.com/business/web-tools-apis/address-information-api.pdf

Source Availability

       This source is in GitHub:

               https://github.com/ssimms/business-us-usps-webtools

Synopsis

               use Business::US::USPS::WebTools::AddressStandardization;

               my $verifier = Business::US::USPS::WebTools::AddressStandardization->new( {
                       UserID   => $ENV{USPS_WEBTOOLS_USERID},
                       Password => $ENV{USPS_WEBTOOLS_PASSWORD},
                       Testing  => 1,
                       } );

               my $hash = $verifier->verify_address(
                       FirmName => '',
                       Address1 => '',
                       Address2 => '6406 Ivy Lane',
                       City     => 'Greenbelt',
                       State    => 'MD',
                       Zip5     => '',
                       Zip4     => '',
                       );

               if( $verifier->is_error )
                       {
                       warn "Oh No! $verifier->{error}{description}\n";
                       }
               else
                       {
                       print join "\n", map { "$_: $hash->{$_}" }
                               qw(FirmName Address1 Address2 City State Zip5 Zip4 DeliveryPoint CarrierRoute ReturnText);
                       }

To Do

See Also