Scroll to navigation

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

NAME

Business::US::USPS::WebTools - Use the US Postal Service Web Tools

SYNOPSIS

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

        # see subclasses for API details

DESCRIPTION

*** THIS IS ALPHA SOFTWARE ***

This is the base class for the WebTools web service from the US Postal Service. The USPS offers several services, and this module handles the parts common to all of them: making the request, getting the response, parsing error responses, and so on. The interesting stuff happens in one of the subclasses which implement a particular service. So far, the only subclass in this distribution is "Business::US::USPS::WebTools::AddressStandardization".

new( ANONYMOUS_HASH )
Make the web service object. Pass is an anonymous hash with these keys:

        UserID          the user id provided by the USPS
        Password        the password provided by the USPS
        Testing         true or false, to select the right server
    

If you don't pass the UserID or Password entries, "new" looks in the environment variables USPS_WEBTOOLS_USERID and USPS_WEBTOOLS_PASSWORD.

If "new" cannot find both the User ID and the Password, it croaks.

If you pass a true value with the Testing key, the object will use the testing server host name and the testing URL path. If the Testing key is false or not present, the object uses the live server details.

userid
Returns the User ID for the web service. You need to get this from the US Postal Service.
password
Returns the Password for the web service. You need to get this from the US Postal Service.
url
Returns the URL for the request to the web service. So far, all requests are GET request with all of the data in the query string.
response
Returns the response from the web service. This is the slightly modified response. So far it only fixes up line endings and normalizes some error output for inconsistent responses from different physical servers.
is_error
Returns true if the response to the last request was an error, and false otherwise.

If the response was an error, this method sets various fields in the object:

        $self->{error}{number}
        $self->{error}{source}
        $self->{error}{description}
        $self->{error}{help_file}
        $self->{error}{help_context}
    

SEE ALSO

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/briandfoy/business-us-usps-webtools

AUTHOR

brian d foy, "<bdfoy@cpan.org>"

COPYRIGHT AND LICENSE

Copyright © 2006-2016, brian d foy <bdfoy@cpan.org>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2021-05-22 perl v5.28.1