Add customer classification field to the driver, i18n, tests.

This commit is contained in:
Colin Kuskie 2009-07-08 21:11:15 -07:00
parent fbd7ba6532
commit cc7b28ecce
3 changed files with 65 additions and 15 deletions

View file

@ -88,6 +88,9 @@ sub buildXML {
$xmlRate->{PickupType} = {
Code => [ $self->get('pickupType') ],
};
$xmlRate->{CustomerClassification} = {
Code => [ $self->get('customerClassification') ],
};
$xmlRate->{Shipment} = {
Shipper => {
Address => [ {
@ -286,6 +289,12 @@ sub definition {
$pickupTypes{'19'} = $i18n->get('pickup code 19');
$pickupTypes{'20'} = $i18n->get('pickup code 20');
tie my %customerClassification, 'Tie::IxHash';
##Note, these keys are required XML keywords in the UPS XML API.
$customerClassification{'01'} = $i18n->get('customer classification 01');
$customerClassification{'03'} = $i18n->get('customer classification 03');
$customerClassification{'04'} = $i18n->get('customer classification 04');
my $localizedCountries = Locales::Country->new('en'); ##Note, for future i18n change the locale
tie my %localizedCountries, 'Tie::IxHash';
%localizedCountries = map { $_ => $_ } grep { !ref $_ } $localizedCountries->all_country_names();
@ -351,6 +360,13 @@ sub definition {
options => \%pickupTypes,
defaultValue => '01',
},
customerClassification => {
fieldType => 'selectBox',
label => $i18n->get('customer classification'),
hoverHelp => $i18n->get('customer classification help'),
options => \%customerClassification,
defaultValue => '01',
},
##Note, if a flat fee is added to this driver, then according to the license
##terms the website must display a note to the user (shop customer) that additional
##fees have been added.

View file

@ -92,6 +92,32 @@ our $I18N = {
lastUpdated => 1242945844,
},
'customer classification' => {
message => q|Customer Classification|,
lastUpdated => 1241214572,
context => q|What kind or type of customer are you?|,
},
'customer classification help' => {
message => q|The kind or type of customer you are.|,
lastUpdated => 1247110533,
},
'customer classification 01' => {
message => q|Wholesale|,
lastUpdated => 1247110533,
},
'customer classification 03' => {
message => q|Occasional|,
lastUpdated => 1247110533,
},
'customer classification 04' => {
message => q|Retail|,
lastUpdated => 1247110533,
},
'flatFee' => {
message => q|Flat Fee|,
lastUpdated => 1241214572,
@ -206,8 +232,8 @@ our $I18N = {
},
'ship type help' => {
message => q|Pick a type of shipping that will be used. The different types have different services available. Not all services are available in all types, or in all countries.|,
lastUpdated => 1242166045,
message => q|Pick a type of shipping that will be used. The different types have different services available. Not all services are available in all types, or in all countries. Changing the service will change the Ship Service options below.|,
lastUpdated => 1247111015,
context => q|Label for a type of shipping from the UPS.|,
},

View file

@ -340,13 +340,14 @@ if (! $license) {
}
$properties = $driver->get();
$properties->{userId} = $userId;
$properties->{password} = $password;
$properties->{licenseNo} = $license;
$properties->{sourceZip} = '97123';
$properties->{sourceCountry} = 'United States';
$properties->{shipService} = '03';
$properties->{pickupType} = '01';
$properties->{userId} = $userId;
$properties->{password} = $password;
$properties->{licenseNo} = $license;
$properties->{sourceZip} = '97123';
$properties->{sourceCountry} = 'United States';
$properties->{shipService} = '03';
$properties->{pickupType} = '01';
$properties->{customerClassification} = '04';
$driver->update($properties);
$driver->testMode(1);
@ -378,6 +379,8 @@ cmp_deeply(
'... correct access request data structure for 1 package'
);
diag $xmlR;
my $xmlRate = XMLin($xmlR,
KeepRoot => 1,
);
@ -386,9 +389,10 @@ cmp_deeply(
$xmlRate, {
RatingServiceSelectionRequest => {
'xml:lang' => 'en-US',
PickupType => { Code => '01', },
Request => { RequestAction => 'Rate', },
Shipment => {
PickupType => { Code => '01', },
CustomerClassification => { Code => '04', },
Request => { RequestAction => 'Rate', },
Shipment => {
Shipper => {
Address => { PostalCode => 97123, CountryCode => 'us', },
},
@ -430,6 +434,8 @@ $xml = $driver->buildXML($cart, @shippableUnits);
($xmlA, $xmlR) = split /\n(?=<\?xml)/, $xml;
diag $xmlR;
$xmlRate = XMLin( $xmlR,
KeepRoot => 1,
ForceArray => ['Package'],
@ -439,9 +445,10 @@ cmp_deeply(
$xmlRate, {
RatingServiceSelectionRequest => {
'xml:lang' => 'en-US',
PickupType => { Code => '01', },
Request => { RequestAction => 'Rate', },
Shipment => {
PickupType => { Code => '01', },
CustomerClassification => { Code => '04', },
Request => { RequestAction => 'Rate', },
Shipment => {
Shipper => {
Address => { PostalCode => 97123, CountryCode => 'us', },
},
@ -474,6 +481,7 @@ SKIP: {
my $xmlData = XMLin($response->content, ForceArray => [qw/RatedPackage/],);
ok($xmlData->{Response}->{ResponseStatusCode}, '... responseCode is successful');
ok($xmlData->{RatedShipment}->{TotalCharges}->{MonetaryValue}, '... total charges returned');
diag $xmlData->{RatedShipment}->{TotalCharges}->{MonetaryValue};
}