Amazon-MWS
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Amazon/MWS/XML/Response/OrderReport.pm view on Meta::CPAN
package Amazon::MWS::XML::Response::OrderReport;
use utf8;
use strict;
use warnings;
use DateTime;
use DateTime::Format::ISO8601;
use Data::Dumper;
use Amazon::MWS::XML::Response::OrderReport::Item;
use Amazon::MWS::XML::Address;
use Moo;
use MooX::Types::MooseLike::Base qw(HashRef ArrayRef Str Int);
use namespace::clean;
=head1 NAME
Amazon::MWS::XML::Response::OrderReport
=head1 DESCRIPTION
Class to handle the xml structures returned by the C<GetReport> with type
C<OrderReport>.
The constructor is meant to be called by L<Amazon::MWS::Uploader> when
C<get_order_reports> is called. A list of objects of this class will be
returned.
=head1 SYNOPSIS
my $order = Amazon::MWS::XML::Response::OrderReport->new(struct => $struct);
my @items = $order->items;
=head1 ACCESSORS
=head2 struct
Mandatory. Must be an hashref.
=head2 order_number
Our order ID. Read-write.
=head2 shipping_address
An L<Amazon::MWS::XML::Address> instance, lazily built.
=head2 billing_address
An L<Amazon::MWS::XML::Address> instance, lazily built.
=cut
has struct => (is => 'ro', isa => HashRef, required => 1);
has order_number => (is => 'rw');
has shipping_address => (is => 'lazy');
has billing_address => (is => 'lazy');
sub _build_shipping_address {
my $self = shift;
if (my $data = $self->struct->{FulfillmentData}) {
# unclear if we want to check the FulfillmentMethod
if (my $address = $data->{Address}) {
return Amazon::MWS::XML::Address->new(%$address);
}
}
return undef;
}
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 {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.018 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )