|
NAMENet::UPS - Implementation of UPS Online Tools API in Perl SYNOPSIS use Net::UPS;
$ups = Net::UPS->new($userid, $password, $accesskey);
$rate = $ups->rate($from_zip, $to_zip, $package);
printf("Shipping this package $from_zip => $to_zip will cost you \$.2f\n", $rate->total_charges);
DESCRIPTIONPLEASE NOTE: this distribution is considered "old". Only critical fixes will be released here. All new work is done in Net::Async::Webservice::UPS, which can be used even without any async library. Net::UPS implements UPS' Online Tools API in Perl. In a nutshell, Net::UPS knows how to retrieve rates and service information for shipping packages using UPS, as well as for validating U.S. addresses. This manual is optimized to be used as a quick reference. If you're knew to Net::UPS, and this manual doesn't seem to help, you're encouraged to read Net::UPS::Tutorial first. METHODSFollowing are the list and description of methods available through Net::UPS. Provided examples may also use other Net::UPS::* libraries and their methods. For the details of those please read their respective manuals. (See SEE ALSO)
All the %args (apart from "user_agent" and "ssl_options", where it would not make sense) can also be defined in the $config_file. %args can be used to overwrite the default arguments. See CONFIGURATION FILE
%args, if present, contains arguments that effect validation results. As of this release the only supported argument is tolerance, which defines threshold for address matches. tolerance is a floating point number between 0 and 1, inclusively. The higher the tolerance threshold, the more loose the address match is, thus more address suggestions are returned. Default tolerance value is 0.05, which only returns very close matches. my $addresses = $ups->validate_address($address);
unless ( defined $addresses ) {
die $ups->errstr;
}
unless ( @$addresses ) {
die "Address is not correct, nor are there any suggestions\n";
}
if ( $addresses->[0]->is_match ) {
print "Address Matches Exactly!\n";
} else {
print "Your address didn't match exactly. Following are some valid suggestions\n";
for (@$addresses ) {
printf("%s, %s %s\n", $_->city, $_->state, $_->postal_code);
}
}
BUGS AND KNOWN ISSUESNo bugs are known of as of this release. If you think you found a bug, document it at http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-UPS. It's more likely to get noticed in there than in my busy inbox. TODOThere are still a lot of features UPS.com offers in its Online Tools API that Net::UPS doesn't handle. This is the list of features that need to be supported before Net::UPS can claim full compliance. PACKAGE OPTIONSFollowing features needs to be supported by Net::UPS::Package class to define additional package options: SERVICE OPTIONSFollowing featureds need to be supported by Net::UPS::Service as well as in form of arguments to rate() and shop_for_rates() methods:
AUTHORSherzod B. Ruzmetov <sherzodr@cpan.org>, http://author.handalak.com/ CREDITSThanks to Christian - <cpan [AT] pickledbrain.com> for locating and fixing a bug in Net::UPS::Package::is_oversized(). See the source for details. COPYRIGHTCopyright (C) 2005 Sherzod Ruzmetov. All rights reserved. This library is free software. You can modify and/or distribute it under the same terms as Perl itself. DISCLAIMERTHIS LIBRARY IS PROVIDED WITH USEFULNES IN MIND, BUT WITHOUT ANY GUARANTEE (NEITHER IMPLIED NOR EXPRESSED) OF ITS FITNES FOR A PARTICUALR PURPOSE. USE IT AT YOUR OWN RISK. SEE ALSONet::UPS::Address, Net::UPS::Rate, Net::UPS::Service, Net::UPS::Package, Net::UPS::Tutorial APPENDIXESSome options need to be provided to UPS in the form of codes. These two-digit numbers are not ideal for mortals to work with. That's why Net::UPS decided to assign them symbolic names, constants, if you wish. SERVICE TYPESFollowing is the table of SERVICE TYPE codes, and their symbolic names assigned by Net::UPS. One of these options can be passed as service argument to rate(), as in: $rates = $ups->rate($from, $to, $package, {service=>'2ND_DAY_AIR'});
+------------------------+-----------+
| SYMBOLIC NAMES | UPS CODES |
+------------------------+-----------+
| NEXT_DAY_AIR | 01 |
| 2ND_DAY_AIR | 02 |
| GROUND | 03 |
| WORLDWIDE_EXPRESS | 07 |
| WORLDWIDE_EXPEDITED | 08 |
| STANDARD | 11 |
| 3_DAY_SELECT | 12 |
| NEXT_DAY_AIR_SAVER | 13 |
| NEXT_DAY_AIR_EARLY_AM | 14 |
| WORLDWIDE_EXPRESS_PLUS | 54 |
| 2ND_DAY_AIR_AM' | 59 |
+------------------------+-----------+
CUSTOMER CLASSIFICATIONFollowing are the possible customer classifications. Can be passed to new() as part of the argument list, as in: $ups = Net::UPS->new($userid, $password, $accesskey, {customer_classification=>'WHOLESALE'});
+----------------+-----------+
| SYMBOLIC NAMES | UPS CODES |
+----------------+-----------+
| WHOLESALE | 01 |
| OCCASIONAL | 03 |
| RETAIL | 04 |
+----------------+-----------+
PACKAGE CODESFollowing are all valid packaging types that can be set through packaging_type attribute of Net::UPS::Package, as in: $package = Net::UPS::Package->new(weight=>10, packaging_type=>'TUBE');
+-----------------+-----------+
| SYMBOLIC NAMES | UPS CODES |
+-----------------+-----------+
| LETTER | 01 |
| PACKAGE | 02 |
| TUBE | 03 |
| UPS_PAK | 04 |
| UPS_EXPRESS_BOX | 21 |
| UPS_25KG_BOX | 24 |
| UPS_10KG_BOX | 25 |
+-----------------+-----------+
CONFIGURATION FILENet::UPS object can also be instantiated using a configuration file. Example: $ups = Net::UPS->new("/home/sherzodr/.upsrc");
# or
$ups = Net::UPS->new("/home/sherzodr/.upsrc", \%args);
All the directives in the configuration file intended for use by Net::UPS will be prefixed with UPS. All other directives that Net::UPS does not recognize will be conveniently ignored. Configuration file uses the following format: DirectiveName DirectiveValue Where "DirectiveName" is one of the keywords documented below. SUPPORTED DIRECTIVES
UPS SSL/TLS notesIn December 2014, UPS notified all its users that it would stop supporting SSLv3 in March 2015. This library has no problems with that, since LWP has supported TLS for years. Another, unrelated, issue cropped up at rougly the same time, to confuse the situation: Mozilla::CA, which is used to get the root certificates to verify connections, dropped a top-level Verisign certificate that Verisign stopped using in 2010, but the UPS servers' certificate was signed with it, so LWP stopped recognising the servers' certificate. Net::UPS 0.14 works around the problem by always including the root certificate in the default "ssl_options". If you set a custom user agent, you may want to set its SSL options appropriately. See also https://rt.cpan.org/Ticket/Display.html?id=101908
|