For USPS priority service, add another container type.

This commit is contained in:
Colin Kuskie 2009-09-06 20:23:12 -07:00
parent 1e98e34128
commit ff55ab1493
4 changed files with 80 additions and 9 deletions

View file

@ -16,6 +16,7 @@
- fixed #10876: EMS Schedule displaying wrong dates for ticket events
- fixed #10915: StoryManager: Carousel clips content
- fixed #10907: profiles viewable by everybody
- added custom box size to USPS driver, priority service
7.7.19
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread

View file

@ -53,6 +53,9 @@ sub buildXML {
$xmlTop->{Package} = [];
##Do a request for each package.
my $packageIndex;
my $shipType = $self->get('shipType');
my $service = $shipType eq 'PRIORITY VARIABLE' ? 'PRIORITY'
: $shipType;
PACKAGE: for(my $packageIndex = 0; $packageIndex < scalar @packages; $packageIndex++) {
my $package = $packages[$packageIndex];
next PACKAGE unless scalar @{ $package };
@ -73,14 +76,17 @@ sub buildXML {
my $destination = $package->[0]->getShippingAddress;
my $destZipCode = $destination->get('code');
$packageData{ID} = $packageIndex;
$packageData{Service} = [ $self->get('shipType') ];
$packageData{Service} = [ $service ];
$packageData{ZipOrigination} = [ $self->get('sourceZip') ];
$packageData{ZipDestination} = [ $destZipCode ];
$packageData{Pounds} = [ $pounds ];
$packageData{Ounces} = [ $ounces ];
if ($self->get('shipType') eq 'PRIORITY') {
if ($shipType eq 'PRIORITY') {
$packageData{Container} = [ 'FLAT RATE BOX' ];
}
elsif ($shipType eq 'PRIORITY VARIABLE') {
#$packageData{Container} = [ 'VARIABLE' ];
}
$packageData{Size} = [ 'REGULAR' ];
$packageData{Machinable} = [ 'true' ];
push @{ $xmlTop->{Package} }, \%packageData;
@ -218,10 +224,11 @@ sub definition {
my $definition = shift || [];
my $i18n = WebGUI::International->new($session, 'ShipDriver_USPS');
tie my %shippingTypes, 'Tie::IxHash';
##Note, these keys are required XML keywords in the USPS XML API.
$shippingTypes{'PRIORITY'} = $i18n->get('priority');
$shippingTypes{'EXPRESS' } = $i18n->get('express');
$shippingTypes{'PARCEL' } = $i18n->get('parcel post');
##Note, these keys are used by buildXML
$shippingTypes{'PRIORITY VARIABLE'} = $i18n->get('priority variable');
$shippingTypes{'PRIORITY'} = $i18n->get('priority');
$shippingTypes{'EXPRESS' } = $i18n->get('express');
$shippingTypes{'PARCEL' } = $i18n->get('parcel post');
tie my %fields, 'Tie::IxHash';
%fields = (
instructions => {

View file

@ -76,6 +76,12 @@ our $I18N = {
context => q|Label for a type of shipping from the USPS.|,
},
'priority variable' => {
message => q|Priority, Custom box|,
lastUpdated => 1203569511,
context => q|Label for a type of shipping from the USPS.|,
},
'express' => {
message => q|Express, Regular size|,
lastUpdated => 1203569511,

View file

@ -93,6 +93,7 @@ my $nivBible = $bible->setCollateral('variantsJSON', 'variantId', 'new',
);
$versionTag->commit;
WebGUI::Test->tagsToRollback($versionTag);
SKIP: {
@ -699,6 +700,65 @@ SKIP: {
}
$properties = $driver->get();
$properties->{shipType} = 'PRIORITY VARIABLE';
$driver->update($properties);
$xml = $driver->buildXML($cart, @shippableUnits);
my $xmlData = XMLin($xml,
KeepRoot => 1,
ForceArray => ['Package'],
);
cmp_deeply(
$xmlData,
{
RateV3Request => {
USERID => $userId,
Package => [
{
ID => 0,
ZipDestination => '53715', ZipOrigination => '97123',
Pounds => '1', Ounces => '8',
Size => 'REGULAR', Service => 'PRIORITY',
Machinable => 'true',# Container => 'VARIABLE',
},
],
}
},
'buildXML: PRIORITY, VARIABLE service, 1 item in cart'
);
like($xml, qr/RateV3Request USERID.+?Package ID=.+?Service.+?ZipOrigination.+?ZipDestination.+?Pounds.+?Ounces.+?Size.+?Machinable/, '... and tag order');
SKIP: {
skip 'No userId for testing', 2 unless $hasRealUserId;
my $response = $driver->_doXmlRequest($xml);
ok($response->is_success, '... _doXmlRequest to USPS successful');
my $xmlData = XMLin($response->content, ForceArray => [qw/Package/],);
cmp_deeply(
$xmlData,
{
Package => [
{
ID => 0,
ZipOrigination => ignore(), ZipDestination => ignore(),
Ounces => ignore(), Pounds => ignore(),
Size => ignore(), Zone => ignore(),
Postage => {
CLASSID => ignore(),
MailService => ignore(),
Rate => num(8,8), ##A number around 10...
}
},
],
},
'... returned data from USPS in correct format. If this test fails, the driver may need to be updated'
);
}
}
#----------------------------------------------------------------------------
@ -712,7 +772,4 @@ END {
$addressBook->delete if $addressBook;
$cart->delete;
}
if (defined $versionTag) {
$versionTag->rollback;
}
}