Amazon-MWS
view release on metacpan or search on metacpan
lib/Amazon/MWS/XML/Response/OrderReport.pm view on Meta::CPAN
sub _build_billing_address {
my $self = shift;
if (my $data = $self->struct->{BillingData}) {
if (my $address = $data->{Address}) {
return Amazon::MWS::XML::Address->new(%$address);
}
}
return undef;
}
has _items_ref => (is => 'lazy');
sub _build__items_ref {
my $self = shift;
my @items;
if (my $list = $self->struct->{Item}) {
foreach my $item (@$list) {
my $obj = Amazon::MWS::XML::Response::OrderReport::Item->new(%$item);
push @items, $obj;
}
}
return \@items;
}
=head1 METHODS
=head2 amazon_order_number
=head2 email
The buyer email.
=head2 order_date
The date when the order processing was complete or when the order was
placed as a L<DateTime> object.
=head2 items
Return a list of L<Amazon::MWS::XML::Response::OrderReport::Item>,
which acts (more or less) like L<Amazon::MWS::XML::OrderlineItem>.
=cut
sub amazon_order_number {
return shift->struct->{AmazonOrderID};
}
sub email {
my $self = shift;
if (my $billing = $self->struct->{BillingData}) {
if (exists $billing->{BuyerEmailAddress}) {
return $billing->{BuyerEmailAddress};
}
};
return;
}
# OrderDate The date the order was placed
# OrderPostedDate The date the buyer's credit card was charged and order processing was completed
sub order_date {
my $self = shift;
my $struct = $self->struct;
# maybe this would need a different method, but we don't know what
# to do with it anyway.
my $date = $struct->{OrderPostedDate} || $struct->{OrderDate};
return DateTime::Format::ISO8601->parse_datetime($date);
}
sub items {
return @{ shift->_items_ref };
}
=head2 as_ack_order_hashref
Return a structure suitable create an the acknowledge feed.
=cut
sub as_ack_order_hashref {
my $self = shift;
my @items;
foreach my $item ($self->items) {
push @items, $item->as_ack_orderline_item_hashref;
}
return {
AmazonOrderID => $self->amazon_order_number,
MerchantOrderID => $self->order_number,
Item => \@items,
};
}
=head2 can_be_imported
Compatibility method with L<Amazon::MWS::XML::Order>. Given that this
is a report, the order can be imported right away without checking.
LFW.
=head2 order_status
Compatibility method.
=cut
sub can_be_imported {
# why not?
return 1;
}
sub order_status {
return 'Report';
}
=head2 currency
We check the items currency.
=head2 shipping_cost
( run in 0.640 second using v1.01-cache-2.11-cpan-39bf76dae61 )