Subject: | Cannot get address suggestions |
UPS Tools now seems to support XML based access method ONLY since the
tools were moved to new server(s) a while ago... so I'm trying to make
use of Net::UPS for a e-commerce site.
Problem: I can't get any suggestions for an invalid address via the
validate_address() method. The array that is supposed contain the
suggestions is empty while it should contain (in my case) 3
suggestions.
$address is the UPS address object with the following information:
city: valley
state: ny
zip: 11580
The invalid parameter is the name of the city. The actual city name
is 'Valley Stream' not 'Valley'.
Here is my code:
$ups = Net::UPS->new($my_userid, $my_passwd, $my_access_key);
my $addresses = $ups->validate_address($address);
unless ( defined $addresses ) {
die $ups->errstr;
}
unless ( @$addresses ) {
die "The speciified address is not correct, and there are no
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, $_-
Show quoted text
>postal_code);
}
}
It may be worth noting that if the supplied address is an exact match,
the addresses array contains 3 elements where the 1st is the exact
match and the other 2 are close matches.