| Business-UPS-Tracking documentation | Contained in the Business-UPS-Tracking distribution. |
Business::UPS::Tracking::Element::Package - A small freight package
This class represents an small freight package. Usually it is created automatically from a Business::UPS::Tracking::Shipment object.
Original XML::LibXML::Node node.
Arrayref of Business::UPS::Tracking::Element::Activity objects ordered by activity date and time. Check the first element in the list for the most recent status.
Date and time of rescheduled delivery attempt. Returns a DateTime object.
Returns a Business::UPS::Tracking::Element::Address object.
Returns a Business::UPS::Tracking::Element::Address object.
Returns 'A' (adult signature), 'S' (signature) or undef (no signature required).
Package weight. Returns a Business::UPS::Tracking::Element::Weight object.
UPS tracking number.
Returns a Business::UPS::Tracking::Element::Address object.
Returns the last known status. Can return
If you need to obtain more detailed information on the current status use
$pakcage->Activity->[0]-<gtStatusTypeDescription>,
$pakcage->Activity->[0]-<gtStatusCode> and
$pakcage->Activity->[0]-<gtDateTime>.
Moose meta method
| Business-UPS-Tracking documentation | Contained in the Business-UPS-Tracking distribution. |
# ============================================================================ package Business::UPS::Tracking::Element::Package; # ============================================================================ use utf8; use 5.0100; use Moose; with qw(Business::UPS::Tracking::Role::Serialize Business::UPS::Tracking::Role::Builder); __PACKAGE__->meta->error_class("Business::UPS::Tracking::Exception"); use Business::UPS::Tracking::Utils; use Business::UPS::Tracking::Element::Activity; our $VERSION = $Business::UPS::Tracking::VERISON;
has 'xml' => ( is => 'ro', isa => 'XML::LibXML::Node', required => 1, ); has 'RerouteAddress' => ( is => 'ro', isa => 'Maybe[Business::UPS::Tracking::Element::Address]', traits => ['Serializable'], documentation => 'Reroute address', lazy_build => 1, ); has 'ReturnToAddress' => ( is => 'ro', isa => 'Maybe[Business::UPS::Tracking::Element::Address]', traits => ['Serializable'], documentation => 'Return address', lazy_build => 1, ); has 'Activity' => ( is => 'ro', isa => 'ArrayRef[Business::UPS::Tracking::Element::Activity]', traits => ['Serializable'], lazy_build => 1, ); has 'SignatureRequired' => ( is => 'ro', isa => 'Maybe[Str]', traits => ['Serializable'], documentation => 'Signature required', lazy_build => 1, ); has 'Message' => ( is => 'ro', isa => 'ArrayRef[Business::UPS::Tracking::Element::Code]', traits => ['Serializable'], documentation => 'Message', lazy_build => 1, ); has 'PackageWeight' => ( is => 'ro', isa => 'Maybe[Business::UPS::Tracking::Element::Weight]', traits => ['Serializable'], documentation => 'Weight', lazy_build => 1, ); has 'ReferenceNumber' => ( is => 'ro', isa => 'ArrayRef[Business::UPS::Tracking::Element::ReferenceNumber]', traits => ['Serializable'], documentation => 'Reference number', lazy_build => 1, ); has 'ProductType' => ( is => 'ro', isa => 'Maybe[Str]', traits => ['Serializable'], documentation => 'Product type', lazy_build => 1, ); has 'TrackingNumber' => ( is => 'ro', isa => 'Maybe[Business::UPS::Tracking::Type::TrackingNumber]', traits => ['Serializable'], documentation => 'Tracking number', lazy_build => 1, ); has 'RescheduledDelivery' => ( is => 'ro', isa => 'Maybe[Business::UPS::Tracking::Type::Date]', traits => ['Serializable'], documentation => 'Rescheduled delivery date', lazy_build => 1, ); sub _build_RerouteAddress { my ($self) = @_; return $self->build_address( 'Reroute/Address' ); } sub _build_ReturnToAddress { my ($self) = @_; return $self->build_address( 'ReturnTo/Address' ); } sub _build_PackageWeight { my ($self) = @_; return $self->build_weight( 'PackageWeight' ); } sub _build_Message { my ($self) = @_; my @nodes = $self->xml->findnodes('Message'); my $return = []; foreach my $node (@nodes) { push @$return,Business::UPS::Tracking::Element::Code->new( xml => $node, ); } return $return; } sub _build_Activity { my ($self) = @_; my @nodes = $self->xml->findnodes('Activity'); my $return = []; my @temp; foreach my $node (@nodes) { push @temp,Business::UPS::Tracking::Element::Activity->new( xml => $node, ); } return [ sort { $b->DateTime <=> $a->DateTime } @temp ]; } sub _build_SignatureRequired { my ($self) = @_; return $self->xml->findvalue('PackageServiceOptions/SignatureRequired/Code') || undef; } sub _build_ProductType { my ($self) = @_; return $self->build_code('ProductType'); } sub _build_ReferenceNumber { my ($self) = @_; my @nodes = $self->xml->findnodes('ReferenceNumber'); my $return = []; foreach my $node (@nodes) { push @$return,Business::UPS::Tracking::Element::ReferenceNumber->new( xml => $node, ); } return $return; } sub _build_TrackingNumber { my ($self) = @_; return $self->xml->findvalue('TrackingNumber'); } sub _build_RescheduledDelivery { my ($self) = @_; my $datestr = $self->xml->findvalue('RescheduledDeliveryDate'); my $date = Business::UPS::Tracking::Utils::parse_date($datestr); my $timestr = $self->xml->findvalue('RescheduledDeliveryTime'); $date = Business::UPS::Tracking::Utils::parse_time( $timestr, $date ); return $date; }
sub CurrentStatus { my ($self) = @_; my $activities = $self->Activity; if (defined $activities && ref $activities eq 'ARRAY') { return $activities->[0]->Status; } else { return 'Unknown'; } }
__PACKAGE__->meta->make_immutable; no Moose; 1;