| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ============================================================================ |
|
2
|
|
|
|
|
|
|
package Business::UPS::Tracking::Element::Package; |
|
3
|
|
|
|
|
|
|
# ============================================================================ |
|
4
|
1
|
|
|
1
|
|
6167
|
use utf8; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
1
|
|
|
1
|
|
79
|
use 5.0100; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
42
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
499
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with qw(Business::UPS::Tracking::Role::Print |
|
9
|
|
|
|
|
|
|
Business::UPS::Tracking::Role::Builder); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Business::UPS::Tracking::Utils; |
|
12
|
|
|
|
|
|
|
use Business::UPS::Tracking::Element::Activity; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=encoding utf8 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Business::UPS::Tracking::Element::Package - A small freight package |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This class represents an small freight package. Usually it is created |
|
23
|
|
|
|
|
|
|
automatically from a L<Business::UPS::Tracking::Shipment> object. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 xml |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Original L<XML::LibXML::Node> node. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 Activity |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Arrayref of L<Business::UPS::Tracking::Element::Activity> objects |
|
34
|
|
|
|
|
|
|
ordered by activity date and time. Check the first element in the list for the |
|
35
|
|
|
|
|
|
|
most recent status. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 RescheduledDelivery |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Date and time of rescheduled delivery attempt. Returns a L<DateTime> object. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns a L<Business::UPS::Tracking::Element::Address> object. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 ReturnToAddress |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns a L<Business::UPS::Tracking::Element::Address> object. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 SignatureRequired |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns 'A' (adult signature), 'S' (signature) or undef (no signature |
|
50
|
|
|
|
|
|
|
required). |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 PackageWeight |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Package weight. Returns a L<Business::UPS::Tracking::Element::Weight> object. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 TrackingNumber |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
UPS tracking number. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 RerouteAddress |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns a L<Business::UPS::Tracking::Element::Address> object. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has 'xml' => ( |
|
67
|
|
|
|
|
|
|
is => 'ro', |
|
68
|
|
|
|
|
|
|
isa => 'XML::LibXML::Node', |
|
69
|
|
|
|
|
|
|
required => 1, |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
has 'RerouteAddress' => ( |
|
72
|
|
|
|
|
|
|
is => 'ro', |
|
73
|
|
|
|
|
|
|
isa => 'Maybe[Business::UPS::Tracking::Element::Address]', |
|
74
|
|
|
|
|
|
|
traits => ['Printable'], |
|
75
|
|
|
|
|
|
|
documentation => 'Reroute address', |
|
76
|
|
|
|
|
|
|
lazy_build => 1, |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
has 'ReturnToAddress' => ( |
|
79
|
|
|
|
|
|
|
is => 'ro', |
|
80
|
|
|
|
|
|
|
isa => 'Maybe[Business::UPS::Tracking::Element::Address]', |
|
81
|
|
|
|
|
|
|
traits => ['Printable'], |
|
82
|
|
|
|
|
|
|
documentation => 'Return address', |
|
83
|
|
|
|
|
|
|
lazy_build => 1, |
|
84
|
|
|
|
|
|
|
); |
|
85
|
|
|
|
|
|
|
has 'Activity' => ( |
|
86
|
|
|
|
|
|
|
is => 'ro', |
|
87
|
|
|
|
|
|
|
isa => 'ArrayRef[Business::UPS::Tracking::Element::Activity]', |
|
88
|
|
|
|
|
|
|
traits => ['Printable'], |
|
89
|
|
|
|
|
|
|
lazy_build => 1, |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
has 'SignatureRequired' => ( |
|
92
|
|
|
|
|
|
|
is => 'ro', |
|
93
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
|
94
|
|
|
|
|
|
|
traits => ['Printable'], |
|
95
|
|
|
|
|
|
|
documentation => 'Signature required', |
|
96
|
|
|
|
|
|
|
lazy_build => 1, |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
has 'Message' => ( |
|
99
|
|
|
|
|
|
|
is => 'ro', |
|
100
|
|
|
|
|
|
|
isa => 'ArrayRef[Business::UPS::Tracking::Element::Code]', |
|
101
|
|
|
|
|
|
|
traits => ['Printable'], |
|
102
|
|
|
|
|
|
|
documentation => 'Message', |
|
103
|
|
|
|
|
|
|
lazy_build => 1, |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
has 'PackageWeight' => ( |
|
106
|
|
|
|
|
|
|
is => 'ro', |
|
107
|
|
|
|
|
|
|
isa => 'Maybe[Business::UPS::Tracking::Element::Weight]', |
|
108
|
|
|
|
|
|
|
traits => ['Printable'], |
|
109
|
|
|
|
|
|
|
documentation => 'Weight', |
|
110
|
|
|
|
|
|
|
lazy_build => 1, |
|
111
|
|
|
|
|
|
|
); |
|
112
|
|
|
|
|
|
|
has 'ReferenceNumber' => ( |
|
113
|
|
|
|
|
|
|
is => 'ro', |
|
114
|
|
|
|
|
|
|
isa => 'ArrayRef[Business::UPS::Tracking::Element::ReferenceNumber]', |
|
115
|
|
|
|
|
|
|
traits => ['Printable'], |
|
116
|
|
|
|
|
|
|
documentation => 'Reference number', |
|
117
|
|
|
|
|
|
|
lazy_build => 1, |
|
118
|
|
|
|
|
|
|
); |
|
119
|
|
|
|
|
|
|
has 'ProductType' => ( |
|
120
|
|
|
|
|
|
|
is => 'ro', |
|
121
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
|
122
|
|
|
|
|
|
|
traits => ['Printable'], |
|
123
|
|
|
|
|
|
|
documentation => 'Product type', |
|
124
|
|
|
|
|
|
|
lazy_build => 1, |
|
125
|
|
|
|
|
|
|
); |
|
126
|
|
|
|
|
|
|
has 'TrackingNumber' => ( |
|
127
|
|
|
|
|
|
|
is => 'ro', |
|
128
|
|
|
|
|
|
|
isa => 'Maybe[Business::UPS::Tracking::Type::TrackingNumber]', |
|
129
|
|
|
|
|
|
|
traits => ['Printable'], |
|
130
|
|
|
|
|
|
|
documentation => 'Tracking number', |
|
131
|
|
|
|
|
|
|
lazy_build => 1, |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
has 'RescheduledDelivery' => ( |
|
134
|
|
|
|
|
|
|
is => 'ro', |
|
135
|
|
|
|
|
|
|
isa => 'Maybe[Business::UPS::Tracking::Type::Date]', |
|
136
|
|
|
|
|
|
|
traits => ['Printable'], |
|
137
|
|
|
|
|
|
|
documentation => 'Rescheduled delivery date', |
|
138
|
|
|
|
|
|
|
lazy_build => 1, |
|
139
|
|
|
|
|
|
|
); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _build_RerouteAddress { |
|
142
|
|
|
|
|
|
|
my ($self) = @_; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return $self->build_address( 'Reroute/Address' ); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _build_ReturnToAddress { |
|
148
|
|
|
|
|
|
|
my ($self) = @_; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return $self->build_address( 'ReturnTo/Address' ); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _build_PackageWeight { |
|
154
|
|
|
|
|
|
|
my ($self) = @_; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
return $self->build_weight( 'PackageWeight' ); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub _build_Message { |
|
160
|
|
|
|
|
|
|
my ($self) = @_; |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my @nodes = $self->xml->findnodes('Message'); |
|
163
|
|
|
|
|
|
|
my $return = []; |
|
164
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
165
|
|
|
|
|
|
|
push @$return,Business::UPS::Tracking::Element::Code->new( |
|
166
|
|
|
|
|
|
|
xml => $node, |
|
167
|
|
|
|
|
|
|
); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
return $return; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _build_Activity { |
|
175
|
|
|
|
|
|
|
my ($self) = @_; |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my @nodes = $self->xml->findnodes('Activity'); |
|
178
|
|
|
|
|
|
|
my $return = []; |
|
179
|
|
|
|
|
|
|
my @temp; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
182
|
|
|
|
|
|
|
push @temp,Business::UPS::Tracking::Element::Activity->new( |
|
183
|
|
|
|
|
|
|
xml => $node, |
|
184
|
|
|
|
|
|
|
); |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
return [ sort { $b->DateTime <=> $a->DateTime } @temp ]; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub _build_SignatureRequired { |
|
190
|
|
|
|
|
|
|
my ($self) = @_; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
return $self->xml->findvalue('PackageServiceOptions/SignatureRequired/Code') |
|
193
|
|
|
|
|
|
|
|| undef; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _build_ProductType { |
|
198
|
|
|
|
|
|
|
my ($self) = @_; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
return $self->build_code('ProductType'); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub _build_ReferenceNumber { |
|
204
|
|
|
|
|
|
|
my ($self) = @_; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
my @nodes = $self->xml->findnodes('ReferenceNumber'); |
|
207
|
|
|
|
|
|
|
my $return = []; |
|
208
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
209
|
|
|
|
|
|
|
push @$return,Business::UPS::Tracking::Element::ReferenceNumber->new( |
|
210
|
|
|
|
|
|
|
xml => $node, |
|
211
|
|
|
|
|
|
|
); |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
return $return; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub _build_TrackingNumber { |
|
217
|
|
|
|
|
|
|
my ($self) = @_; |
|
218
|
|
|
|
|
|
|
return $self->xml->findvalue('TrackingNumber'); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub _build_RescheduledDelivery { |
|
223
|
|
|
|
|
|
|
my ($self) = @_; |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
my $datestr = $self->xml->findvalue('RescheduledDeliveryDate'); |
|
226
|
|
|
|
|
|
|
my $date = Business::UPS::Tracking::Utils::parse_date($datestr); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
my $timestr = $self->xml->findvalue('RescheduledDeliveryTime'); |
|
229
|
|
|
|
|
|
|
$date = Business::UPS::Tracking::Utils::parse_time( $timestr, $date ); |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
return $date; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 METHODS |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 CurrentStatus |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Returns the last known status. Can return |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=over |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * In Transit |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * Delivered |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * Exeption |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * Pickup |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item * Manifest Pickup |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * Unknown |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
If you need to obtain more detailed information on the current status use |
|
260
|
|
|
|
|
|
|
C<$pakcage-E<gt>Activity-E<gt>[0]-<gt>StatusTypeDescription>, |
|
261
|
|
|
|
|
|
|
C<$pakcage-E<gt>Activity-E<gt>[0]-<gt>StatusCode> and |
|
262
|
|
|
|
|
|
|
C<$pakcage-E<gt>Activity-E<gt>[0]-<gt>DateTime>. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub CurrentStatus { |
|
267
|
|
|
|
|
|
|
my ($self) = @_; |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my $activities = $self->Activity; |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
if (defined $activities |
|
272
|
|
|
|
|
|
|
&& ref $activities eq 'ARRAY') { |
|
273
|
|
|
|
|
|
|
return $activities->[0]->Status; |
|
274
|
|
|
|
|
|
|
} else { |
|
275
|
|
|
|
|
|
|
return 'Unknown'; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 meta |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Moose meta method |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=cut |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
286
|
|
|
|
|
|
|
no Moose; |
|
287
|
|
|
|
|
|
|
1; |