Scroll to navigation

Business::US::USPS::WebTools::ZipCodeLookup(3pm) User Contributed Perl Documentation Business::US::USPS::WebTools::ZipCodeLookup(3pm)

NAME

Business::US::USPS::WebTools::ZipCodeLookup - lookup a Zip Code using the USPS Web Tools

SYNOPSIS

        use Business::US::USPS::WebTools::ZipCodeLookup;
        my $looker_upper = Business::US::USPS::WebTools::ZipCodeLookup->new( {
                UserID   => $ENV{USPS_WEBTOOLS_USERID},
                Password => $ENV{USPS_WEBTOOLS_PASSWORD},
                Testing  => 1,
                } );
        my $hash = $looker_upper->lookup_zipcode(
                );
        if( $looker_upper->is_error )
                {
                warn "Oh No! $looker_upper->{error}{description}\n";
                }
        else
                {
                print join "\n", map { "$_: $hash->{$_}" }
                        qw(FirmName Address1 Address2 City State Zip5 Zip4);
                }

DESCRIPTION

*** THIS IS ALPHA SOFTWARE ***

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

The "lookup_zipcode" method takes the following keys, which come directly from the USPS web service interface:

        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. 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.

TO DO

SEE ALSO

Business::US::USPS::WebTools

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

        http://www.usps.com/webtools/htm/Address-Information.htm

SOURCE AVAILABILITY

This source is in GitHub:

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

AUTHOR

brian d foy

COPYRIGHT AND LICENSE

Copyright © 2020, Steve Simms. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.

2022-08-28 perl v5.34.0