Skip Menu |

This queue is for tickets about the Net-UPS CPAN distribution.

Report information
The Basics
Id: 98219
Status: resolved
Priority: 0/
Queue: Net-UPS

People
Owner: Nobody in particular
Requestors: n9yty [...] n9yty.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.13



Subject: Error when providing a bad address to Net::UPS->validate_street_address
Date: Wed, 20 Aug 2014 23:01:45 -0500
To: bug-Net-UPS [...] rt.cpan.org
From: Steve Palm <n9yty [...] n9yty.com>
When I provide a good address, everything works fine. If I provide a bad one I get an error: Not a HASH reference at /Library/Perl/5.18/Net/UPS.pm line 580. Sample: use Net::UPS; use Net::UPS::Address; Net::UPS->live(1); my $ups = Net::UPS->new($uname, $pword, $akey, { 'ups_account_number' => $acct } ); my $address = Net::UPS::Address->new(); $address->address("123 Smith Dr"); $address->city("Rockford"); $address->state("MI"); $address->postal_code("49341"); $address->country_code("US"); $res = $ups->validate_street_address($address);
Subject: Re: [rt.cpan.org #98219] AutoReply: Error when providing a bad address to Net::UPS->validate_street_address
Date: Thu, 21 Aug 2014 09:03:50 -0500
To: bug-Net-UPS [...] rt.cpan.org
From: Steve Palm <n9yty [...] n9yty.com>
Not a proper solution, but I needed something to get my small project done. :) It seems that when the address is wrong an array of potential matches is returned and the code was expecting to get just a single address back. This is not a solution and probably a horrible workaround, but for now... around line 580 of UPS.pm: elsif ( $response->{ValidAddressIndicator} ) { $quality = 1; } my $akf; if ( ref($response->{AddressKeyFormat}) eq 'ARRAY' ) { $akf = $response->{AddressKeyFormat}->[0]; } else { $akf = $response->{AddressKeyFormat}; } print ref($response->{AddressKeyFormat}); use Data::Dumper; print Dumper($akf); my $response_address; if ($response->{AddressKeyFormat}) { $response_address = Net::UPS::Address->new( quality => $quality, building_name => $akf->{BuildingName}, address => $akf->{AddressLine}->[0], address2 => $akf->{AddressLine}->[1], address3 => $akf->{AddressLine}->[2], postal_code => $akf->{PostcodePrimaryLow}, postal_code_extended => $akf->{PostcodeExtendedLow}, city => $akf->{PoliticalDivision2}, state => $akf->{PoliticalDivision1}, country_code => $akf->{CountryCode}, is_commercial => ( $akf->{Code} eq "1" ) ? 1 : 0, is_residential => ( $akf->{Code} eq "2" ) ? 1 : 0, ); }
Subject: Re: [rt.cpan.org #98219] AutoReply: Error when providing a bad address to Net::UPS->validate_street_address
Date: Thu, 21 Aug 2014 09:12:25 -0500
To: bug-Net-UPS [...] rt.cpan.org
From: Steve Palm <n9yty [...] n9yty.com>
Ooops. That was not my final code, as is plain from looking at it, but it is close enough. I can't remove the comment. Sorry!