Busine...bTools(3pm)

πŸ“¦
version 1.125 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’Œ NAME

Business::US::USPS::WebTools β€” your lil gateway to the US Postal Service Web Tools, bestie πŸ’–


✨ SYNOPSIS ✨

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

# see subclasses for API details

That's literally it for the base class β€” the real tea is in the subclasses, iykyk πŸ«–


🌸 DESCRIPTION 🌸

*** THIS IS ALPHA SOFTWARE *** 😭 no cap, it said it, not me

So here's the vibe: this is the base class for the WebTools web service from the US Postal Service πŸ‘‘ The USPS offers a whole bunch of services, and this module handles all the stuff they have in common β€” making the request, getting the response back, parsing error responses, all that plumbing 🚰 The actually 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 πŸŽ€

πŸ¦‹ Methods (the whole roster)

  • new( ANONYMOUS_HASH ) β€” makes the web service object, periodt πŸ’… You pass in 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 goes looking in the environment variables USPS_WEBTOOLS_USERID and USPS_WEBTOOLS_PASSWORD πŸ”

And if new still can't find both the User ID and the Password? It croaks πŸ’€ fr fr, it just dies right there.

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 just not present at all, the object uses the live server details πŸ”₯ (yes, real postal service, main character energy)

  • userid β€” returns the User ID for the web service πŸͺͺ You gotta get this one from the US Postal Service yourself, bestie, I can't manifest it for you.
  • password β€” returns the Password for the web service πŸ” Also a you-get-it-from-the-USPS situation, sorry babe.
  • url β€” returns the URL for the request to the web service 🌐 So far, every single request is a GET request with all of the data shoved into the query string. That's the whole thing.
  • tx β€” returns the transaction from the Mojo::UserAgent request πŸ“¬
  • response β€” returns the response from the web service πŸ’Œ It's the slightly modified response β€” so far it only fixes up line endings and normalizes some error output, because the different physical servers are inconsistent and honestly, same 😭
  • 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}
  • live_server_host β€” this is production.shippingapis.com 🏭 The modules choose this host when you have not set Testing to a true value.
  • test_server_host β€” for most APIs, this is testing.shippingapis.com πŸ§ͺ The modules choose this host when you have set Testing to a true value.

πŸ” SEE ALSO

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

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

Go read the source of truth, bestie πŸ“–


πŸ™ SOURCE AVAILABILITY

This source is in GitHub:

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

πŸ‘‘ AUTHOR

brian d foy

πŸ’œ MAINTAINER

Steve Simms


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.


okay that's the whole page, slay πŸ’… this was documented under perl v5.36.0, dated 2022-08-28, and it lives in the User Contributed Perl Documentation manual β€” Busine...bTools(3pm), yes the title got truncated by the manpage formatter and no, we are not fixing it, it's iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from