Subject: | Patch for Net::UPS::Package to support not-supplied package size |
For an UPS package, the only required field is the weight. However, if
the dimensions are not specified, Net::UPS::Package will still generate
the XML for them with void fields - which causes an error to be returned
by UPS servers.
Attached is the patch to allow to only specify package weight and not
dimensions.
Mik.
BY THE WAY, is this package maintained by the author? I see latest patch
request is 3-years old.
Subject: | Net-UPS-Package_dimensions.diff.txt |
--- /usr/lib64/perl5/vendor_perl/5.12.1/Net/UPS/Package.pm 2010-06-14 10:05:28.000000000 +0200
+++ Package.pm 2010-06-14 11:54:34.000000000 +0200
@@ -90,11 +90,6 @@
PackagingType => {
Code => $self->packaging_type ? sprintf("%02d", $self->_packaging2code($self->packaging_type)) : '02',
},
- Dimensions => {
- UnitOfMeasurement => {
- Code => $length_measure
- }
- },
DimensionalWeight => {
UnitOfMeasurement => {
Code => $weight_measure
@@ -107,15 +102,25 @@
}
}
);
- if ( $self->length ) {
- $data{Package}->{Dimensions}->{Length}= $self->length;
- }
- if ( $self->width ) {
- $data{Package}->{Dimensions}->{Width} = $self->width;
- }
- if ( $self->height ) {
- $data{Package}->{Dimensions}->{Height} = $self->height;
+
+ if ( $self->length || $self->width || $self->height ) {
+ $data{Package}->{Dimensions} = {
+ UnitOfMeasurement => {
+ Code => $length_measure
+ }
+ };
+
+ if ( $self->length ) {
+ $data{Package}->{Dimensions}->{Length}= $self->length;
+ }
+ if ( $self->width ) {
+ $data{Package}->{Dimensions}->{Width} = $self->width;
+ }
+ if ( $self->height ) {
+ $data{Package}->{Dimensions}->{Height} = $self->height;
+ }
}
+
if ( $self->weight ) {
$data{Package}->{PackageWeight}->{Weight} = $self->weight;
}