NAME
Business::Shipping::UPS_XML - UPS XML Rate Requester
SYNOPSIS
use Business::Shipping::UPS_XML;
my $userid = 'jsmith';
my $userid_pass = 'topsecret';
my $access_key = '1DC98F0EB3A13E45';
my $origin_country = 'CA';
my $origin_zip = 'L4J8J2';
my $service_code = '03';
my $ups = new Business::Shipping::UPS_XML($userid,$userid_pass,$access_key,$origin_country);
my $width = 10;
my $height = 10;
my $length = 10;
my $units = 'IN';
my $weight = 2;
$ups->set_dimensions( $width, $height, $length, $unit_of_measure, $weight);
my $width = 15;
my $height = 2;
my $length = 10;
my $units = 'IN';
my $weight = 2.3;
$ups->set_dimensions( $width, $height, $length, $unit_of_measure, $weight);
my $dest_country = 'US';
my $dest_zip = '83711';
($maxcost, $zone, $error) = $ups->getUPS( $service_code, $origin_zip, $dest_zip, $dest_country);
DESCRIPTION
This module uses the XML version of the UPS Rates & Service Selection Tool to get UPS rates for a given package and delivery destination. I wrote this after spending several hours trying to install various XML parsing modules and their dependancies. This module has it's own built in parser so no additional XML modules are needed.
One advantage to this module is it properly calculates shipments to, from and withing Canada. The old cgi UPS rate queries don't allow Canadian zip codes.
REQUIREMENTS
To use this module you need a online tools userid and password along with an access key. See the UPS OnLine Tools section of www.ups.com for details.
COMMON METHODS
The methods described in this section are available for all Business::Shipping::UPS_XML
objects.
- new($userid,$userid_pass,$access_key,$origin_country)
-
The new method is the constructor. The following input parameter are all required and must be provided in the following order:
1. Userid from ups.com web site. 2. Password from ups.com web site. 3. Access key from the ups.com web site. 4. The ISO abreviation for the country the shipment originates. my $ups = new UPS_XML('jsmith', 'topsecret', '1FC98F0EB3F13C45', 'CA');
- $ups->set_dimensions( $width, $height, $length, $unit_of_measure, $weight )
-
Use this method if you need rates based on dimensions for one or more packages. To get rates for multiple packages, execute the method once for each package.
If you only need a rate based on the combined weight of one shipment, you don't need this method.
$ups->set_dimensions( 10, 5, 8, 'IN', 2.3 ); $ups->set_dimensions( 4, 4, 5, 'IN', 1.1 );
- $ups->getUPS( $service_code, $origin_zip, $dest_zip, $dest_country)
-
This method returns the rate for the provided service code, origin zip code, destination zip code, destination country and weight. If you use the set_dimensions method, the weight provided here is ignored.
getUPS returns the rate, zone, error code and currency the rate is in. After this method is executed, the dimensions provided by the set_dimensions method are cleared.
This module understand the following service codes:
UPS Express 01 UPS Next Day Air 01 UPS Expedited 02 UPS 2nd Day Air 02 UPS Ground 03 UPS Worldwide Express 07 UPS Worldwide Expedited 08 UPS Standard 11 UPS 3 Day Select 12 UPS Express Saver 13 UPS Next Day Air Saver 13 UPS Express Early AM 14 UPS Next Day Early AM 14 UPS Worldwide Express Plus 54 UPS 2nd Day Air A.M. 59 UPS Express NAI 64 UPS Express Saver (US) 65 UPS Express Saver (Eur) 65 ($maxcost, $zone, $error, $currency) = $ups->getUPS( '03', 'L4J8J2', '83711', 'US', 3);
AUTHOR
Duane Hinkley, <duane@dhwd.com>
http://www.DownHomeWebDesign.com
Copyright (c) 2003-2004 Down Home Web Design, Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself
If you have any questions, comments or suggestions please feel free to contact me.