« Shipment/Purolator/WSDLV2/Interfaces/ShippingService/ShippingServiceEndpoint.pm
↑ Summary
Shipment/UPS/WSDL/TrackInterfaces/TrackService/TrackPort.pm »
| 1 | package Shipment::FedEx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | $Shipment::FedEx::VERSION = '3.11'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Shipment::SOAP::WSDL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use DateTime::Format::ISO8601; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | extends 'Shipment::Base'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | has 'meter' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | has 'key' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | has 'password' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | has 'proxy_domain' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | isa => Enum [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | wsbeta.fedex.com:443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ws.fedex.com:443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | default => 'wsbeta.fedex.com:443', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | has 'shipment_special_service_types' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | isa => ArrayRef [Str], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | has 'residential_address' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | has 'label_stock_type' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | isa => Enum [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | STOCK_4X6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | STOCK_4X6.75_LEADING_DOC_TAB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | STOCK_4X6.75_TRAILING_DOC_TAB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | STOCK_4X8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | STOCK_4X9_LEADING_DOC_TAB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | STOCK_4X9_TRAILING_DOC_TAB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | PAPER_4X6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | PAPER_4X8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | PAPER_4X9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | PAPER_7X4.75 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | PAPER_8.5X11_BOTTOM_HALF_LABEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | PAPER_8.5X11_TOP_HALF_LABEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | PAPER_LETTER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | builder => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub _build_label_stock_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_label_stock_type: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | return 'STOCK_4X6' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->printer_type eq "thermal" or $self->printer_type eq "ZPLII" or $self->printer_type eq "EPL2" or $self->printer_type eq "DPL"
$self->printer_type eq "thermal" or $self->printer_type eq "ZPLII" or $self->printer_type eq "EPL2"
$self->printer_type eq "thermal" or $self->printer_type eq "ZPLII"
MC/DC0%0/4
$self->printer_type eq "thermal" or $self->printer_type eq "ZPLII" or $self->printer_type eq "EPL2" or $self->printer_type eq "DPL"
$self->printer_type eq "thermal"
$self->printer_type eq "ZPLII"
$self->printer_type eq "EPL2"
$self->printer_type eq "DPL"
Truth table0%0/5
A or B or C or D
A= $self->printer_type eq "thermal"B= $self->printer_type eq "ZPLII"C= $self->printer_type eq "EPL2"D= $self->printer_type eq "DPL"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | if $self->printer_type eq 'thermal' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | or $self->printer_type eq 'ZPLII' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | or $self->printer_type eq 'EPL2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | or $self->printer_type eq 'DPL'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return 'PAPER_4X6'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | has '+bill_type' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | (isa => Enum [qw( sender recipient third_party collect )],); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | my %bill_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 'sender' => 'SENDER', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'recipient' => 'RECIPIENT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'third_party' => 'THIRD_PARTY', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'collect' => 'COLLECT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | my %signature_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'default' => 'SERVICE_DEFAULT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'required' => 'DIRECT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 'not_required' => 'NO_SIGNATURE_REQUIRED', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 'adult' => 'ADULT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | my %pickup_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 'pickup' => 'REGULAR_PICKUP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 'dropoff' => 'STATION', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | my %package_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 'custom' => 'YOUR_PACKAGING', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 'envelope' => 'FEDEX_ENVELOPE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 'tube' => 'FEDEX_TUBE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 'box' => 'FEDEX_BOX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'pack' => 'FEDEX_PAK', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my %units_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'lb' => 'LB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 'kg' => 'KG', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'in' => 'IN', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 'cm' => 'CM', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | my %printer_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 'pdf' => 'PDF', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'thermal' => 'EPL2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 'image' => 'PNG', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | my %label_content_type_map = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 'pdf' => 'application/pdf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 'thermal' => 'text/fedex-epl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 'ZPLII' => 'text/fedex-zplii', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 'EPL2' => 'text/fedex-epl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 'DPL' => 'text/fedex-dpl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 'image' => 'image/png', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | has '+package_type' => (isa => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Enum [qw( custom envelope tube box pack FEDEX_10KG_BOX FEDEX_25KG_BOX )] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | has '+currency' => (default => 'USD',); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub _build_services { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | use Shipment::Package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | use Shipment::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | use Shipment::FedEx::WSDL::RateInterfaces::RateService::RateServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Shipment::FedEx::WSDL::RateInterfaces::RateService::RateServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | my %services; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | my @to_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | push @to_streetlines, $self->to_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | push @to_streetlines, $self->to_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | if $self->to_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | my @from_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | push @from_streetlines, $self->from_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | push @from_streetlines, $self->from_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if $self->from_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | my $total_weight; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $total_weight += $_->weight for @{$self->packages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | $total_weight ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | my $options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $options->{SpecialServiceTypes} = 'SIGNATURE_OPTION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $options->{SignatureOptionDetail}->{OptionType} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $signature_type_map{$self->signature_type} || $self->signature_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | my @pieces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | if ($self->count_packages) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | my $sequence = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | foreach (@{$self->packages}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | push @pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | { SequenceNumber => $sequence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | InsuredValue => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | Currency => $_->insured_value->code || $self->currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Amount => $_->insured_value->value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | Weight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Value => $_->weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | Dimensions => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | Length => $_->length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | Width => $_->width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | Height => $_->height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | Units => $units_type_map{$self->dim_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | || $self->dim_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | SpecialServicesRequested => $options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | $sequence++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | push @pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | { Weight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | Value => $total_weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | my $shipment_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | my @shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | push @shipment_special_service_types, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | @{$self->shipment_special_service_types}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | $shipment_options->{SpecialServiceTypes} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | \@shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | $response = $interface->getRates( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ServiceId => 'crs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | Major => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | Intermediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ReturnTransitAndCommit => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | RequestedShipment => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ShipTimestamp => $self->pickup_date->datetime, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | DropoffType => $pickup_type_map{$self->pickup_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | || $self->pickup_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | PackagingType => 'YOUR_PACKAGING', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | Shipper => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | StreetLines => \@from_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | City => $self->from_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | $self->from_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | PostalCode => $self->from_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | CountryCode => $self->from_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | Recipient => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | StreetLines => \@to_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | City => $self->to_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | $self->to_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | PostalCode => $self->to_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | CountryCode => $self->to_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | Residential => $self->residential_address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | RateRequestTypes => 'LIST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | PackageCount => $self->count_packages || 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | PackageDetail => 'INDIVIDUAL_PACKAGES', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | RequestedPackageLineItems => \@pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | SpecialServicesRequested => $shipment_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | $self->add_notice($notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | foreach my $service (@{$response->get_RateReplyDetails()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | $services{$service->get_ServiceType()->get_value} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | Shipment::Service->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | id => $service->get_ServiceType()->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | name => $service->get_ServiceType()->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | package => Shipment::Package->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | id => 'YOUR_PACKAGING', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | name => 'Customer Supplied', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | cost => Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | $service->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ->get_ShipmentRateDetail->get_TotalNetCharge->get_Amount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | $service->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ->get_ShipmentRateDetail->get_TotalNetCharge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ->get_Currency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | discount => Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $service->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | ->get_EffectiveNetDiscount->get_Amount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $services{ground} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | $services{'FEDEX_GROUND'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | || $services{'GROUND_HOME_DELIVERY'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | || $services{'INTERNATIONAL_GROUND'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | || Shipment::Service->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | $services{express} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | $services{'FEDEX_2_DAY'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | || $services{'INTERNATIONAL_ECONOMY'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | || Shipment::Service->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | $services{priority} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $services{'PRIORITY_OVERNIGHT'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | || $services{'INTERNATIONAL_PRIORITY'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | || Shipment::Service->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | $response->get_Notifications()->[0]->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | warn $response->get_Notifications()->[0]->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | \%services; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | sub rate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | my ($self, $service_id) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $service_id = $self->services->{$service_id}->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | warn "service ($service_id) not available" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | $self->error("service ($service_id) not available"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | $service_id = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | return unless $service_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | my $total_weight; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | $total_weight += $_->weight for @{$self->packages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | my $total_insured_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | $total_insured_value += $_->insured_value->value for @{$self->packages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | use Shipment::Package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | use Shipment::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | use Shipment::FedEx::WSDL::RateInterfaces::RateService::RateServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | Shipment::FedEx::WSDL::RateInterfaces::RateService::RateServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | my $options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | $options->{SpecialServiceTypes} = 'SIGNATURE_OPTION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $options->{SignatureOptionDetail}->{OptionType} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | $signature_type_map{$self->signature_type} || $self->signature_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | my @pieces; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | my $sequence = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | foreach (@{$self->packages}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | push @pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | { SequenceNumber => $sequence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | InsuredValue => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | Currency => $_->insured_value->code || $self->currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | Amount => $_->insured_value->value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | Weight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Value => $_->weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | Dimensions => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | Length => $_->length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | Width => $_->width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | Height => $_->height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | Units => $units_type_map{$self->dim_unit} || $self->dim_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | SpecialServicesRequested => $options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $sequence++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | my $shipment_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | my @shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | push @shipment_special_service_types, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | @{$self->shipment_special_service_types}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | $shipment_options->{SpecialServiceTypes} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | \@shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | my @to_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | push @to_streetlines, $self->to_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | push @to_streetlines, $self->to_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | if $self->to_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | my @from_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | push @from_streetlines, $self->from_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | push @from_streetlines, $self->from_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | if $self->from_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | my %services; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | $response = $interface->getRates( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ServiceId => 'crs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | Major => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | Intermediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ReturnTransitAndCommit => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | RequestedShipment => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ShipTimestamp => $self->pickup_date->datetime, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ServiceType => $service_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | DropoffType => 'REGULAR_PICKUP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | PackagingType => 'YOUR_PACKAGING', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | TotalWeight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | Value => $total_weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | TotalInsuredValue => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | Currency => $self->currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | Amount => $total_insured_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | Shipper => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | StreetLines => \@from_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | City => $self->from_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | $self->from_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | PostalCode => $self->from_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | CountryCode => $self->from_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | Recipient => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | StreetLines => \@to_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | City => $self->to_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | $self->to_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | PostalCode => $self->to_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | CountryCode => $self->to_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | Residential => $self->residential_address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | RateRequestTypes => 'LIST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | PackageCount => $self->count_packages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | PackageDetail => 'INDIVIDUAL_PACKAGES', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | RequestedPackageLineItems => \@pieces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | SpecialServicesRequested => $shipment_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | $self->add_notice($notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | use Data::Currency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | use Shipment::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | $self->service( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | Shipment::Service->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | id => $service_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | name => $self->services->{$service_id}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | cost => Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | $response->get_RateReplyDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | ->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ->get_ShipmentRateDetail->get_TotalNetCharge->get_Amount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | $response->get_RateReplyDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ->get_ShipmentRateDetail->get_TotalNetCharge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | ->get_Currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | discount => Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | $response->get_RateReplyDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ->get_RatedShipmentDetails->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ->get_EffectiveNetDiscount->get_Amount, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | $response->get_Notifications()->[0]->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | warn $response->get_Notifications()->[0]->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | sub ship { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | my ($self, $service_id) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | $service_id = $self->services->{$service_id}->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | warn "service ($service_id) not available" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | $self->error("service ($service_id) not available"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | $service_id = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | return unless $service_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | my $total_weight; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | $total_weight += $_->weight for @{$self->packages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | my $total_insured_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $total_insured_value += $_->insured_value->value for @{$self->packages}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | my $package_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | $package_options->{SpecialServiceTypes} = 'SIGNATURE_OPTION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | $package_options->{SignatureOptionDetail}->{OptionType} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | $signature_type_map{$self->signature_type} || $self->signature_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | my $shipment_options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | my @shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | push @shipment_special_service_types, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | @{$self->shipment_special_service_types}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | my @email_notifications; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | if ($self->to_address->email) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | push @email_notifications, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | { EMailNotificationRecipientType => 'RECIPIENT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | EMailAddress => $self->to_address->email, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | NotifyOnShipment => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | Format => 'TEXT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | Localization => {LanguageCode => 'EN',}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | push @shipment_special_service_types, 'EMAIL_NOTIFICATION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | $shipment_options->{EMailNotificationDetail}->{Recipients} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | \@email_notifications; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | $shipment_options->{SpecialServiceTypes} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | \@shipment_special_service_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | my @references; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | push @references, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | { CustomerReferenceType => 'CUSTOMER_REFERENCE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | Value => $self->get_reference(0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | if $self->get_reference(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | push @references, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | { CustomerReferenceType => 'INVOICE_NUMBER', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | Value => $self->get_reference(1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | if $self->get_reference(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | push @references, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | { CustomerReferenceType => 'P_O_NUMBER', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | Value => $self->get_reference(2), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | if $self->get_reference(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | my @to_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | push @to_streetlines, $self->to_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | push @to_streetlines, $self->to_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | if $self->to_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | my @from_streetlines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | push @from_streetlines, $self->from_address()->address1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | push @from_streetlines, $self->from_address()->address2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | if $self->from_address()->address2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | my $sequence = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | my $master_tracking_id = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | use Shipment::Label; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | use Data::Currency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | use Shipment::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | use Shipment::FedEx::WSDL::ShipInterfaces::ShipService::ShipServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | Shipment::FedEx::WSDL::ShipInterfaces::ShipService::ShipServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | foreach (@{$self->packages}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | $response = $interface->processShipment( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ServiceId => 'ship', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | Major => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | Intermediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | RequestedShipment => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | ShipTimestamp => $self->pickup_date->datetime, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ServiceType => $service_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | DropoffType => $pickup_type_map{$self->pickup_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | || $self->pickup_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | PackagingType => $package_type_map{$self->package_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | || $self->package_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | TotalWeight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | Value => $total_weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | TotalInsuredValue => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | Currency => $self->currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | Amount => $total_insured_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | Shipper => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | Contact => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | PersonName => $self->from_address()->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | CompanyName => $self->from_address()->company, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | PhoneNumber => $self->from_address()->phone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | StreetLines => \@from_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | City => $self->from_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | $self->from_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | PostalCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | $self->from_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | CountryCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | $self->from_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | Recipient => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | Contact => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | PersonName => $self->to_address()->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | CompanyName => $self->to_address()->company, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | PhoneNumber => $self->to_address()->phone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | Address => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | StreetLines => \@to_streetlines, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | City => $self->to_address()->city, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | StateOrProvinceCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | $self->to_address()->province_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | PostalCode => $self->to_address()->postal_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | CountryCode => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | $self->to_address()->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | Residential => $self->residential_address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | ShippingChargesPayment => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | PaymentType => $bill_type_map{$self->bill_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | || $self->bill_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | Payor => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | AccountNumber => $self->bill_account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | CountryCode => ($self->bill_address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | ? $self->bill_address->country_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | : $self->from_address->country_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | SpecialServicesRequested => $shipment_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | RateRequestTypes => 'ACCOUNT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | PackageCount => $self->count_packages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | PackageDetail => 'INDIVIDUAL_PACKAGES', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | MasterTrackingId => $master_tracking_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | RequestedPackageLineItems => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | SequenceNumber => $sequence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | InsuredValue => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | Currency => $self->currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | Amount => $_->insured_value->value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | Weight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | Value => $_->weight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | Units => $units_type_map{$self->weight_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | || $self->weight_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | Dimensions => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | Length => $_->length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | Width => $_->width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | Height => $_->height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | Units => $units_type_map{$self->dim_unit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | || $self->dim_unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | SpecialServicesRequested => $package_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | CustomerReferences => \@references, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | LabelSpecification => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | LabelFormatType => 'COMMON2D', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ImageType => $printer_type_map{$self->printer_type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | || $self->printer_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | LabelStockType => $self->label_stock_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | $self->add_notice( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | $notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | my $package_details = $response->get_CompletedShipmentDetail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ->get_CompletedPackageDetails; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | if ($self->count_packages > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | my $master_tracking = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | $response->get_CompletedShipmentDetail->get_MasterTrackingId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | $self->tracking_id( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | $master_tracking->get_TrackingNumber->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | $master_tracking_id = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | TrackingIdType => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | $master_tracking->get_TrackingIdType->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | TrackingNumber => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | $master_tracking->get_TrackingNumber->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | $self->tracking_id( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | $package_details->get_TrackingIds->get_TrackingNumber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | ->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | $_->tracking_id( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | $package_details->get_TrackingIds->get_TrackingNumber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | ->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | if ($package_details->get_PackageRating) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | $_->cost( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | $package_details->get_PackageRating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ->get_PackageRateDetails->[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0]->get_NetCharge->get_Amount->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | $package_details->get_PackageRating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | ->get_PackageRateDetails->[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0]->get_NetCharge->get_Currency->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | elsif ($response->get_CompletedShipmentDetail->get_ShipmentRating) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | $_->cost( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | $response->get_CompletedShipmentDetail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | ->get_ShipmentRating->get_ShipmentRateDetails->[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0]->get_TotalNetCharge->get_Amount->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | $response->get_CompletedShipmentDetail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | ->get_ShipmentRating->get_ShipmentRateDetails->[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0]->get_TotalNetCharge->get_Currency->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | $_->label( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | Shipment::Label->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | { tracking_id => $package_details->get_TrackingIds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | ->get_TrackingNumber->get_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | content_type => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | $label_content_type_map{$self->printer_type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | data => decode_base64( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | $package_details->get_Label->get_Parts->get_Image | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | file_name => $package_details->get_TrackingIds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ->get_TrackingNumber->get_value . '.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | . lc $printer_type_map{$self->printer_type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | $self->error($response->get_Notifications()->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | ->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | warn $response->get_Notifications()->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | last if $self->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | $sequence++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | if (!$self->error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | my $total_charge_amount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | my $total_charge_currency = $self->currency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | my $total_charge = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | $response->get_CompletedShipmentDetail->get_ShipmentRating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | ->get_ShipmentRateDetails->[0]->get_TotalNetCharge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | $total_charge_amount = $total_charge->get_Amount->get_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | $total_charge_currency = $total_charge->get_Currency->get_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | # for other billing (recipient/third_party/collect), no rate details are returned, so we ignore the caught error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | #warn $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | $self->service( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | Shipment::Service->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | id => $service_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | name => $self->services->{$service_id}->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | cost => Data::Currency->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | $total_charge_amount, $total_charge_currency, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | sub cancel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | if (!$self->tracking_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | $self->error('no tracking id provided'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | use Shipment::FedEx::WSDL::ShipInterfaces::ShipService::ShipServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | Shipment::FedEx::WSDL::ShipInterfaces::ShipService::ShipServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | my $type = (length $self->tracking_id > 12) ? 'GROUND' : 'EXPRESS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | my $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | $response = $interface->deleteShipment( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | ServiceId => 'ship', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | Major => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | Intermediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | TrackingId => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | TrackingIdType => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | TrackingNumber => $self->tracking_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | DeletionControl => 'DELETE_ONE_PACKAGE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | $self->add_notice($notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | $success = $response->get_HighestSeverity->get_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | $response->get_Notifications()->[0]->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | warn $response->get_Notifications()->[0]->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | return $success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | sub track { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | use Shipment::Activity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | if (!$self->tracking_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | $self->error('no tracking id provided'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | use Shipment::FedEx::WSDL::TrackInterfaces::TrackService::TrackServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | Shipment::FedEx::WSDL::TrackInterfaces::TrackService::TrackServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | $response = $interface->track( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | ServiceId => 'trck', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | Major => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | Intermediate => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | SelectionDetails => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | PackageIdentifier => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | Type => 'TRACKING_NUMBER_OR_DOORTAG', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | Value => $self->tracking_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ProcessingOptions => 'INCLUDE_DETAILED_SCANS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | $self->add_notice($notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | if ($response->get_CompletedTrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | ->get_TrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ->get_Notification() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | ->get_Severity() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | ->get_value() eq 'ERROR') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | $self->error($response->get_CompletedTrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | ->get_TrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | ->get_Notification() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | ->get_Message() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | ->get_value()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | foreach my $event ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | @{ $response->get_CompletedTrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | ->get_TrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | ->get_Events() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | $self->add_activity( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | Shipment::Activity->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | description => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | $event->get_EventDescription()->get_value(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | date => DateTime::Format::ISO8601->parse_datetime( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | $event->get_Timestamp()->get_value() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | location => Shipment::Address->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | city => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | $event->get_Address()->get_City() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | ? $event->get_Address() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ->get_City() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | ->get_value() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | state => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | $event->get_Address() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | ->get_StateOrProvinceCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | ? $event->get_Address() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ->get_StateOrProvinceCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ->get_value() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | country => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | $event->get_Address()->get_CountryCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | ? $event->get_Address() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | ->get_CountryCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | ->get_value() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | : '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | $self->ship_date( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | DateTime::Format::ISO8601->parse_datetime( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | $response->get_CompletedTrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | ->get_TrackDetails() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | ->get_ShipTimestamp->get_value() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | $response->get_Notifications()->[0]->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | warn $response->get_Notifications()->[0]->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | sub end_of_day { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | use Shipment::FedEx::WSDL::CloseInterfaces::CloseService::CloseServicePort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | my $interface = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | Shipment::FedEx::WSDL::CloseInterfaces::CloseService::CloseServicePort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | ->new({proxy_domain => $self->proxy_domain,}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | my $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | $Shipment::SOAP::WSDL::Debug = 1 if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | $response = $interface->groundClose( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | { WebAuthenticationDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | UserCredential => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | Key => $self->key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | Password => $self->password, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | ClientDetail => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | AccountNumber => $self->account, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | MeterNumber => $self->meter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | Version => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | ServiceId => 'clos', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | Major => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | Intermediate => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | Minor => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | TimeUpToWhichShipmentsAreToBeClosed => DateTime->now->datetime, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | $Shipment::SOAP::WSDL::Debug = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | warn "Response\n" . $response if $self->debug > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | $self->notice(''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | foreach my $notification (@{$response->get_Notifications()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | warn $notification->get_Message->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | $self->add_notice($notification->get_Message->get_value . "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | $self->manifest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | Shipment::Label->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | content_type => 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | data => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | decode_base64($response->get_Manifest->get_File->get_value), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | file_name => 'manifest_' . DateTime->now->ymd('_') . '.txt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | warn $_ if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | $response->get_Notifications()->[0]->get_Message->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | warn $response->get_Notifications()->[0]->get_Message->get_value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | $self->error($response->get_faultstring->get_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | warn $response->get_faultstring->get_value if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||