Marketplace-Ebay
view release on metacpan or search on metacpan
lib/Marketplace/Ebay/Order.pm view on Meta::CPAN
package Marketplace::Ebay::Order;
use strict;
use warnings;
use DateTime;
use DateTime::Format::ISO8601;
use Data::Dumper;
use Moo;
use MooX::Types::MooseLike::Base qw(Str HashRef Int Object Bool);
use Marketplace::Ebay::Order::Address;
use Marketplace::Ebay::Order::Item;
use namespace::clean;
=head1 NAME
Marketplace::Ebay::Order
=head1 DESCRIPTION
Class to handle the xml structures found in the GetOrders call.
L<http://developer.ebay.com/devzone/xml/docs/Reference/ebay/GetOrders.html>
The aim is to have a consistent interface with
L<Amazon::MWS::XML::Order> so importing the orders can happens almost
transparently.
=cut
=head1 ACCESSORS/METHODS
=head2 order
The raw structure got from the XML parsing
=head2 shop_type
Always returns C<ebay>
=cut
has order => (is => 'ro', isa => HashRef, required => 1);
sub shop_type {
return 'ebay';
}
=head2 name_from_shipping_address
By default, lookup the name from the shipping address. Defaults to
true. Otherwise look it up from the first item. Prior to version 0.19,
the name was looked up from the first item only.
=cut
has name_from_shipping_address => (is => 'ro', isa => Bool, default => sub { 1 });
=head2 order_number
read-write accessor for the (shop) order number so you can set this
while importing it.
=head2 payment_status
read-write accessor for the payment status, so the shop can set it
while importing it.
=cut
has order_number => (is => 'rw', isa => Str);
has payment_status => (is => 'rw', isa => Str);
=head2 can_be_imported
Return true if both orderstatus and checkout status are completed
=cut
sub can_be_imported {
my ($self) = @_;
my $order = $self->order;
if ($order->{OrderStatus} eq 'Completed' and
$order->{CheckoutStatus}->{Status} eq 'Complete') {
return 1;
}
else {
return 0;
}
}
=head2 order_status
Return the order status and the payment status, separated by a colon.
=cut
sub order_status {
my ($self) = @_;
my $order = $self->order;
my $order_status = $order->{OrderStatus} || 'Unknown';
my $payment_status = $order->{CheckoutStatus}->{Status} || 'Unknown';
( run in 2.059 seconds using v1.01-cache-2.11-cpan-7f9471e7e0a )