[interchange-cvs] [SCM] Interchange branch, master, updated. 51cf14b38e268405a02db1d664898256f1fc57b7
Jon Jensen
interchange-cvs at icdevgroup.org
Tue Sep 1 21:45:40 UTC 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange".
The branch, master has been updated
via 51cf14b38e268405a02db1d664898256f1fc57b7 (commit)
from 1d9dbfb4e42ecf7e1fcf81cf931d7d4794f46f73 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 51cf14b38e268405a02db1d664898256f1fc57b7
Author: Jon Jensen <jon at endpoint.com>
Date: Tue Sep 1 15:43:29 2009 -0600
Update USPS international rate names and add script that fetches them
Also cleaned up some POD errors.
Thanks to Josh Lavin and Mat Jones.
-----------------------------------------------------------------------
Summary of changes and diff:
code/UserTag/usps_query.tag | 42 +++++++++++++++----------
eg/usps/get-intl-rate-names | 70 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 17 deletions(-)
create mode 100755 eg/usps/get-intl-rate-names
diff --git a/code/UserTag/usps_query.tag b/code/UserTag/usps_query.tag
index a355666..a9a249f 100644
--- a/code/UserTag/usps_query.tag
+++ b/code/UserTag/usps_query.tag
@@ -1,15 +1,13 @@
-# Copyright 2002-2007 Interchange Development Group and others
+# Copyright 2002-2009 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
-#
-# $Id: usps_query.tag,v 1.9 2009-03-06 01:38:25 markj Exp $
UserTag usps-query Order service weight
UserTag usps-query addAttr
-UserTag usps-query Version $Revision: 1.9 $
+UserTag usps-query Version 1.10
UserTag usps-query Routine <<EOR
sub {
@@ -26,12 +24,16 @@ sub {
'GLOBAL EXPRESS GUARANTEED' => 1,
'GLOBAL EXPRESS GUARANTEED NON-DOCUMENT RECTANGULAR' => 1,
'GLOBAL EXPRESS GUARANTEED NON-DOCUMENT NON-RECTANGULAR' => 1,
+ 'USPS GXG ENVELOPES' => 1,
'EXPRESS MAIL INTERNATIONAL (EMS)' => 1,
- 'EXPRESS MAIL INTERNATIONAL (EMS) FLAT RATE ENVELOPE' => 1,
+ 'EXPRESS MAIL INTERNATIONAL (EMS) FLAT-RATE ENVELOPE' => 1,
'PRIORITY MAIL INTERNATIONAL' => 1,
- 'PRIORITY MAIL INTERNATIONAL FLAT RATE ENVELOPE' => 1,
- 'PRIORITY MAIL INTERNATIONAL FLAT RATE BOX' => 1,
- 'FIRST-CLASS MAIL INTERNATIONAL' => 1,
+ 'PRIORITY MAIL INTERNATIONAL FLAT-RATE ENVELOPE' => 1,
+ 'PRIORITY MAIL INTERNATIONAL REGULAR FLAT-RATE BOXES' => 1,
+ 'PRIORITY MAIL INTERNATIONAL LARGE FLAT-RATE BOX' => 1,
+ 'PRIORITY MAIL INTERNATIONAL SMALL FLAT-RATE BOX' => 1,
+ 'FIRST CLASS MAIL INTERNATIONAL LARGE ENVELOPE' => 1,
+ 'FIRST CLASS MAIL INTERNATIONAL PACKAGE' => 1,
'MATTER FOR THE BLIND - ECONOMY MAIL' => 1,
);
my %package_sizes = (
@@ -262,12 +264,16 @@ The USPS service you wish to get a rate quote for. Services currently supported:
GLOBAL EXPRESS GUARANTEED
GLOBAL EXPRESS GUARANTEED NON-DOCUMENT RECTANGULAR
GLOBAL EXPRESS GUARANTEED NON-DOCUMENT NON-RECTANGULAR
+ USPS GXG ENVELOPES
EXPRESS MAIL INTERNATIONAL (EMS)
- EXPRESS MAIL INTERNATIONAL (EMS) FLAT RATE ENVELOPE
+ EXPRESS MAIL INTERNATIONAL (EMS) FLAT-RATE ENVELOPE
PRIORITY MAIL INTERNATIONAL
- PRIORITY MAIL INTERNATIONAL FLAT RATE ENVELOPE
- PRIORITY MAIL INTERNATIONAL FLAT RATE BOX
- FIRST-CLASS MAIL INTERNATIONAL
+ PRIORITY MAIL INTERNATIONAL FLAT-RATE ENVELOPE
+ PRIORITY MAIL INTERNATIONAL REGULAR FLAT-RATE BOXES
+ PRIORITY MAIL INTERNATIONAL LARGE FLAT-RATE BOX
+ PRIORITY MAIL INTERNATIONAL SMALL FLAT-RATE BOX
+ FIRST CLASS MAIL INTERNATIONAL LARGE ENVELOPE
+ FIRST CLASS MAIL INTERNATIONAL PACKAGE
MATTER FOR THE BLIND - ECONOMY MAIL
@@ -287,7 +293,7 @@ Your USPS webtools passwd, which was obtained by registering.
This will default to $Variable->{USPS_PASSWORD}, which is the
preferred way to set this parameter.
-=back 4
+=back
=head2 Extended Parameters (domestic and international services)
@@ -309,7 +315,7 @@ the whole shipment, and the total rate will be calculated accordingly.
Example: with modulo = 10, a 34.5lbs. shipment will be calculated as 3 parcels
weighing 10lbs. each, plus one parcel weighing 4lbs. 8oz.
-=back 4
+=back
=head2 Extended Parameters for domestic (U.S.) services only
@@ -344,7 +350,7 @@ Possible value are 'True' and 'False'. Indicates whether or not the shipment
qualifies for machine processing by UPS. Default is $Variable->{USPS_MACHINABLE}
or 'False". Consult the USPS service guides for more info on this subject.
-=back 4
+=back
=head2 Extended parameters for International services only
@@ -372,7 +378,7 @@ table which is distributed with the standard demo, so modifications may be neede
if you intend to use USPS international services. Consult the USPS International
Services guide for more information.
-=back 4
+=back
=head1 BUGS
@@ -380,7 +386,9 @@ We shall see....
=head1 AUTHORS
-Ed LaFrance <edl at newmediaems.com>.
+ Ed LaFrance <edl at newmediaems.com>
+ Josh Lavin <josh at perusion.com>
+ Mathew Jones <mat at bibliopolis.com>
=cut
EOD
diff --git a/eg/usps/get-intl-rate-names b/eg/usps/get-intl-rate-names
new file mode 100755
index 0000000..4558993
--- /dev/null
+++ b/eg/usps/get-intl-rate-names
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+=for docs
+
+from http://www.icdevgroup.org/pipermail/interchange-users/2009-May/050480.html
+
+Date: Wed, 6 May 2009 09:14:45 -0500
+From: Josh Lavin <josh-ic at att.net>
+To: interchange-users at icdevgroup.org
+Subject: Re: [ic] Updated usps_query.tag
+
+[...]
+
+Note that I do not use this tag any longer, due to USPS WebTools being
+offline for over a week a few months ago. I made the switch to rate
+tables, which I update when new prices are posted.
+
+Below is a Perl script I wrote to grab service names from the XML
+response to a rate request. Add your WebTools user and password, then
+you can use the output of this script to update the tag. USPS seems to
+change service names often, sometimes just adding or removing a hyphen,
+and the only documentation of valid service names is found via a rate
+request.
+
+=cut
+
+require LWP::UserAgent;
+
+$userid = 'your id here';
+$passwd = 'your pass here';
+$url = 'http://Production.ShippingAPIs.com/ShippingAPI.dll';
+
+$weight = '0';
+$ounces = '10';
+$mailtype = 'Package';
+$country = 'Canada';
+
+$xml = qq{API=IntlRate\&XML=<IntlRateRequest USERID="$userid" PASSWORD="$passwd">};
+$xml .= <<EOXML;
+<Package ID="0">
+ <Pounds>$weight</Pounds>
+ <Ounces>$ounces</Ounces>
+ <MailType>$mailtype</MailType>
+ <Country>$country</Country>
+</Package>
+</IntlRateRequest>
+EOXML
+
+my $ua = new LWP::UserAgent;
+my $req = new HTTP::Request 'POST', "$url";
+$req->content_type('application/x-www-form-urlencoded');
+$req->content($xml);
+my $response = $ua->request($req);
+
+$error_msg = 'USPS: ';
+if ($response->is_success) {
+ $resp = $response->content;
+}
+else {
+ $error_msg .= 'Error obtaining rate quote from usps.com.';
+}
+
+ at intl = split /<Service/, $resp;
+foreach (@intl) {
+ m|<SvcDescription>(.+)</SvcDescription>|;
+ $svc = uc $1;
+ print "$svc\n";
+}
+
+#print $resp
hooks/post-receive
--
Interchange
More information about the interchange-cvs
mailing list