File: //usr/local/ssl/local/share/man/man3/Business::UPS.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Business::UPS 3"
.TH Business::UPS 3 "2010-05-04" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
Business::UPS \- A UPS Interface Module
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Business::UPS;
.Ve
.PP
.Vb 4
\& my ($shipping,$ups_zone,$error) = getUPS(qw/GNDCOM 23606 23607 50/);
\& $error and die "ERROR: $error\en";
\& print "Shipping is \e$$shipping\en";
\& print "UPS Zone is $ups_zone\en";
.Ve
.PP
.Vb 2
\& %track = UPStrack("z10192ixj29j39");
\& $track{error} and die "ERROR: $track{error}";
.Ve
.PP
.Vb 2
\& # 'Delivered' or 'In-transit'
\& print "This package is $track{Current Status}\en";
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
A way of sending four arguments to a module to get shipping charges
that can be used in, say, a \s-1CGI\s0.
.SH "REQUIREMENTS"
.IX Header "REQUIREMENTS"
I've tried to keep this package to a minimum, so you'll need:
.IP "\(bu" 4
Perl 5.003 or higher
.IP "\(bu" 4
LWP::UserAgent Module
.SH "ARGUMENTS for \fIgetUPS()\fP"
.IX Header "ARGUMENTS for getUPS()"
Call the subroutine with the following values:
.PP
.Vb 4
\& 1. Product code (see product-codes.txt)
\& 2. Origin Zip Code
\& 3. Destination Zip Code
\& 4. Weight of Package
.Ve
.PP
and optionally:
.PP
.Vb 7
\& 5. Country Code, (see country-codes.txt)
\& 6. Rate Chart (drop-off, pick-up, etc - see below)
\& 6. Length,
\& 7. Width,
\& 8. Height,
\& 9. Oversized (defined if oversized), and
\& 10. COD (defined if C.O.D.)
.Ve
.IP "1" 4
.IX Item "1"
Product Codes:
.Sp
.Vb 18
\& 1DM Next Day Air Early AM
\& 1DML Next Day Air Early AM Letter
\& 1DA Next Day Air
\& 1DAL Next Day Air Letter
\& 1DP Next Day Air Saver
\& 1DPL Next Day Air Saver Letter
\& 2DM 2nd Day Air A.M.
\& 2DA 2nd Day Air
\& 2DML 2nd Day Air A.M. Letter
\& 2DAL 2nd Day Air Letter
\& 3DS 3 Day Select
\& GNDCOM Ground Commercial
\& GNDRES Ground Residential
\& XPR Worldwide Express
\& XDM Worldwide Express Plus
\& XPRL Worldwide Express Letter
\& XDML Worldwide Express Plus Letter
\& XPD Worldwide Expedited
.Ve
.Sp
In an \s-1HTML\s0 \*(L"option\*(R" input it might look like this:
.Sp
.Vb 13
\& <OPTION VALUE="1DM">Next Day Air Early AM
\& <OPTION VALUE="1DML">Next Day Air Early AM Letter
\& <OPTION SELECTED VALUE="1DA">Next Day Air
\& <OPTION VALUE="1DAL">Next Day Air Letter
\& <OPTION VALUE="1DP">Next Day Air Saver
\& <OPTION VALUE="1DPL">Next Day Air Saver Letter
\& <OPTION VALUE="2DM">2nd Day Air A.M.
\& <OPTION VALUE="2DA">2nd Day Air
\& <OPTION VALUE="2DML">2nd Day Air A.M. Letter
\& <OPTION VALUE="2DAL">2nd Day Air Letter
\& <OPTION VALUE="3DS">3 Day Select
\& <OPTION VALUE="GNDCOM">Ground Commercial
\& <OPTION VALUE="GNDRES">Ground Residential
.Ve
.IP "2" 4
.IX Item "2"
Origin Zip(tm) Code
.Sp
Origin Zip Code as a number or string (\s-1NOT\s0 +4 Format)
.IP "3" 4
.IX Item "3"
Destination Zip(tm) Code
.Sp
Destination Zip Code as a number or string (\s-1NOT\s0 +4 Format)
.IP "4" 4
.IX Item "4"
Weight
.Sp
Weight of the package in pounds
.IP "5" 4
.IX Item "5"
Country
.Sp
Defaults to \s-1US\s0
.IP "6" 4
.IX Item "6"
Rate Chart
.Sp
How does the package get to \s-1UPS:\s0
.Sp
Can be one of the following:
.Sp
.Vb 5
\& Regular Daily Pickup
\& On Call Air
\& One Time Pickup
\& Letter Center
\& Customer Counter
.Ve
.SH "ARGUMENTS for \fIUPStrack()\fP"
.IX Header "ARGUMENTS for UPStrack()"
The tracking number.
.PP
.Vb 3
\& use Business::UPS;
\& %t = UPStrack("1ZX29W290250xxxxxx");
\& print "This package is $track{'Current Status'}\en";
.Ve
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
.IP "\fIgetUPS()\fR" 4
.IX Item "getUPS()"
.Vb 1
\& The raw LWP::UserAgent get returns a list with the following values:
.Ve
.Sp
.Vb 13
\& ## Desc Typical Value
\& -- --------------- -------------
\& 0. Name of server: UPSOnLine3
\& 1. Product code: GNDCOM
\& 2. Orig Postal: 23606
\& 3. Country: US
\& 4. Dest Postal: 23607
\& 5. Country: US
\& 6. Shipping Zone: 002
\& 7. Weight (lbs): 50
\& 8. Sub-total Cost: 7.75
\& 9. Addt'l Chrgs: 0.00
\& 10. Total Cost: 7.75
.Ve
.IP "\fIUPStrack()\fR" 4
.IX Item "UPStrack()"
The hash that's returned is like the following:
.Sp
.Vb 10
\& 'Last Updated' => 'Jun 10 2003 12:28 P.M.'
\& 'Shipped On' => 'June 9, 2003'
\& 'Signed By' => 'SIGNATURE'
\& 'Shipped To' => 'LOS ANGELES,CA,US'
\& 'Scanning' => HASH(0x146e0c) (more later...)
\& 'Activity Count' => 5
\& 'Weight' => '16.00 Lbs'
\& 'Current Status' => 'Delivered'
\& 'Location' => 'RESIDENTIAL'
\& 'Service Type' => 'STANDARD'
.Ve
.Sp
Notice the key 'Scanning' is a reference to a hash.
(Which is a reference to another hash.)
.Sp
Scanning will contain a hash with keys 1 .. (Activity Count)
Each of those values is another hash, holding a reference to
an activity that's happened to an item. (See example for
details)
.Sp
.Vb 9
\& %hash{Scanning}{1}{'location'} = 'MESQUITE,TX,US';
\& %hash{Scanning}{1}{'date'} = 'Jun 10, 2003';
\& %hash{Scanning}{1}{'time'} = '12:55 A.M.';
\& %hash{Scanning}{1}{'activity'} = 'ARRIVAL SCAN';
\& %hash{Scanning}{2}{'location'} = 'MESQUITE,TX,US';
\& .
\& .
\& .
\& %hash{Scanning}{x}{'activity'} = 'DELIVERED';
.Ve
.Sp
\&\s-1NOTE:\s0 The items generally go in reverse chronological order.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
.IP "\fIgetUPS()\fR" 4
.IX Item "getUPS()"
To retreive the shipping of a 'Ground Commercial' Package
weighing 25lbs. sent from 23001 to 24002 this package would
be called like this:
.Sp
.Vb 2
\& #!/usr/local/bin/perl
\& use Business::UPS;
.Ve
.Sp
.Vb 4
\& my ($shipping,$ups_zone,$error) = getUPS(qw/GNDCOM 23001 23002 25/);
\& $error and die "ERROR: $error\en";
\& print "Shipping is \e$$shipping\en";
\& print "UPS Zone is $ups_zone\en";
.Ve
.IP "\fIUPStrack()\fR" 4
.IX Item "UPStrack()"
.Vb 1
\& #!/usr/local/bin/perl
.Ve
.Sp
.Vb 1
\& use Business::UPS;
.Ve
.Sp
.Vb 2
\& %t = UPStrack("z10192ixj29j39");
\& $t{error} and die "ERROR: $t{error}";
.Ve
.Sp
.Vb 6
\& print "This package is $t{'Current Status'}\en"; # 'Delivered' or
\& # 'In-transit'
\& print "More info:\en";
\& foreach $key (keys %t) {
\& print "KEY: $key = $t{$key}\en";
\& }
.Ve
.Sp
.Vb 1
\& %activities = %{$t{'Scanning'}};
.Ve
.Sp
.Vb 9
\& print "Package activity:\en";
\& for (my $num = $t{'Activity Count'}; $num > 0; $num--)
\& {
\& print "-- ITEM $num --\en";
\& foreach $newkey (keys %{$activities{$num}})
\& {
\& print "$newkey: $activities{$num}{$newkey}\en";
\& }
\& }
.Ve
.SH "BUGS"
.IX Header "BUGS"
Probably lots. Contact me if you find them.
.SH "AUTHOR"
.IX Header "AUTHOR"
Justin Wheeler <upsmodule@datademons.com>
.PP
mailto:upsmodule@datademons.com
.PP
This software was originally written by Mark Solomon <mailto:msoloman@seva.net> (http://www.seva.net/~msolomon/)
.PP
\&\s-1NOTE:\s0 \s-1UPS\s0 is a registered trademark of United Parcel Service. Due to \s-1UPS\s0 licensing, using this software is not
be endorsed by \s-1UPS\s0, and may not be allowed. Use at your own risk.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIperl\fR\|(1).