| 1 | package Net::Async::Webservice::UPS::Response::QV::Exception; | ||
| 2 | $Net::Async::Webservice::UPS::Response::QV::Exception::VERSION = '1.1.4'; | ||
| 3 | { | ||
| 4 | $Net::Async::Webservice::UPS::Response::QV::Exception::DIST = 'Net-Async-Webservice-UPS'; | ||
| 5 | } | ||
| 6 | use Moo; | ||
| 7 | use 5.010; | ||
| 8 | use Types::Standard qw(Str ArrayRef HashRef); | ||
| 9 | use Net::Async::Webservice::UPS::Types qw(:types); | ||
| 10 | use Net::Async::Webservice::UPS::Response::Utils qw(:all); | ||
| 11 | use Types::DateTime DateTime => { -as => 'DateTimeT' }; | ||
| 12 | use DateTime::Format::Strptime; | ||
| 13 | use List::AllUtils 'any'; | ||
| 14 | use namespace::autoclean; | ||
| 15 | |||
| 16 | # ABSTRACT: a Quantum View "exception" event | ||
| 17 | |||
| 18 | |||
| 19 | has package_reference => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => ArrayRef[QVReference], | ||
| 22 | ); | ||
| 23 | |||
| 24 | |||
| 25 | has shipment_reference => ( | ||
| 26 | is => 'ro', | ||
| 27 | isa => ArrayRef[QVReference], | ||
| 28 | ); | ||
| 29 | |||
| 30 | |||
| 31 | has shipper_number => ( | ||
| 32 | is => 'ro', | ||
| 33 | isa => Str, | ||
| 34 | ); | ||
| 35 | |||
| 36 | |||
| 37 | has tracking_number => ( | ||
| 38 | is => 'ro', | ||
| 39 | isa => Str, | ||
| 40 | ); | ||
| 41 | |||
| 42 | |||
| 43 | has date_time => ( | ||
| 44 | is => 'ro', | ||
| 45 | isa => DateTimeT, | ||
| 46 | ); | ||
| 47 | |||
| 48 | |||
| 49 | has updated_address => ( | ||
| 50 | is => 'ro', | ||
| 51 | isa => Address, | ||
| 52 | ); | ||
| 53 | |||
| 54 | |||
| 55 | has status_code => ( | ||
| 56 | is => 'ro', | ||
| 57 | isa => Str, | ||
| 58 | ); | ||
| 59 | |||
| 60 | |||
| 61 | has status_description => ( | ||
| 62 | is => 'ro', | ||
| 63 | isa => Str, | ||
| 64 | ); | ||
| 65 | |||
| 66 | |||
| 67 | has reason_code => ( | ||
| 68 | is => 'ro', | ||
| 69 | isa => Str, | ||
| 70 | ); | ||
| 71 | |||
| 72 | |||
| 73 | has reason_description => ( | ||
| 74 | is => 'ro', | ||
| 75 | isa => Str, | ||
| 76 | ); | ||
| 77 | |||
| 78 | |||
| 79 | has resolution_code => ( | ||
| 80 | is => 'ro', | ||
| 81 | isa => Str, | ||
| 82 | ); | ||
| 83 | |||
| 84 | |||
| 85 | has resolution_description => ( | ||
| 86 | is => 'ro', | ||
| 87 | isa => Str, | ||
| 88 | ); | ||
| 89 | |||
| 90 | |||
| 91 | has rescheduled_delivery_date => ( | ||
| 92 | is => 'ro', | ||
| 93 | isa => DateTimeT, | ||
| 94 | ); | ||
| 95 | |||
| 96 | |||
| 97 | has activity_location => ( | ||
| 98 | is => 'ro', | ||
| 99 | isa => Address, | ||
| 100 | ); | ||
| 101 | |||
| 102 | |||
| 103 | has bill_to_account_number => ( | ||
| 104 | is => 'ro', | ||
| 105 | isa => Str, | ||
| 106 | ); | ||
| 107 | |||
| 108 | |||
| 109 | has bill_to_account_option => ( | ||
| 110 | is => 'ro', | ||
| 111 | isa => Str, | ||
| 112 | ); | ||
| 113 | |||
| 114 | |||
| 115 | has access_point_location_id => ( | ||
| 116 | is => 'ro', | ||
| 117 | isa => Str, | ||
| 118 | ); | ||
| 119 | |||
| 120 | sub BUILDARGS { | ||
| 121 | my ($class,$hashref) = @_; | ||
| 122 | if (@_>2) { shift; $hashref={@_} }; | ||
| 123 | |||
| 124 | if (any { /^[A-Z]/ } keys %$hashref) { | ||
| 125 | state $date_parser = DateTime::Format::Strptime->new( | ||
| 126 | pattern => '%Y%m%d%H%M%S', | ||
| 127 | ); | ||
| 128 | set_implied_argument($hashref); | ||
| 129 | |||
| 130 | return { | ||
| 131 | in_if(tracking_number=>'TrackingNumber'), | ||
| 132 | in_if(shipper_number=>'ShipperNumber'), | ||
| 133 | in_object_array_if(shipment_reference => 'ShipmentReferenceNumber', 'Net::Async::Webservice::UPS::Response::QV::Reference'), | ||
| 134 | in_object_array_if(package_reference => 'PackageReferenceNumber', 'Net::Async::Webservice::UPS::Response::QV::Reference'), | ||
| 135 | ( $hashref->{Date} ? ( date_time => $date_parser->parse_datetime($hashref->{Date}.$hashref->{Time}) ) : () ), | ||
| 136 | in_object_if(updated_address => 'UpdatedAddress', 'Net::Async::Webservice::UPS::Address'), | ||
| 137 | pair_if(bill_to_account_number => $hashref->{BillToAccount}{Number}), | ||
| 138 | pair_if(bill_to_account_option => $hashref->{BillToAccount}{Option}), | ||
| 139 | in_if(status_code => 'StatusCode'), | ||
| 140 | ( $hashref->{RescheduledDeliveryDate} ? ( rescheduled_delivery_date => $date_parser->parse_datetime($hashref->{RescheduledDeliveryDate}.$hashref->{RescheduledDeliveryTime}) ) : () ), | ||
| 141 | in_if(status_code => 'StatusCode'), | ||
| 142 | in_if(status_description => 'StatusDescription'), | ||
| 143 | in_if(reason_code => 'ReasonCode'), | ||
| 144 | in_if(reason_description => 'ReasonDescription'), | ||
| 145 | pair_if(resolution_code => $hashref->{Resolution}{Code}), | ||
| 146 | pair_if(resolution_description => $hashref->{Resolution}{Description}), | ||
| 147 | in_object_if(activity_location => 'ActivityLocation', 'Net::Async::Webservice::UPS::Address'), | ||
| 148 | in_if(access_point_location_id => 'AccessPointLocationID'), | ||
| 149 | }; | ||
| 150 | } | ||
| 151 | return $hashref; | ||
| 152 | } | ||
| 153 | |||
| 154 | |||
| 155 | 1; | ||
| 156 | |||
| 157 | __END__ |