Amazon-MWS
view release on metacpan or search on metacpan
examples/print-template.pl view on Meta::CPAN
#!/usr/bin/env perl
use warnings;
use strict;
use XML::Compile::Schema;
my $schema = XML::Compile::Schema->new([glob "schemas/*.xsd"]);
print $schema->template(PERL => 'AmazonEnvelope');
lib/Amazon/MWS/Uploader.pm view on Meta::CPAN
required => 1,
isa => sub {
die "$_[0] is not a directory" unless -d $_[0];
});
has schema => (is => 'lazy');
sub _build_schema {
my $self = shift;
my $files = File::Spec->catfile($self->schema_dir, '*.xsd');
my $schema = XML::Compile::Schema->new([glob $files]);
return $schema;
}
has xml_writer => (is => 'lazy');
sub _build_xml_writer {
my $self = shift;
return $self->schema->compile(WRITER => 'AmazonEnvelope');
}
lib/Amazon/MWS/XML/GenericFeed.pm view on Meta::CPAN
Amazon::MWS::XML::GenericFeed -- base module to create XML feeds for Amazon MWS
=head1 ACCESSORS
=head2 xml_writer
The L<XML::Compile::Schema> writer object. You can pass this to build
this object manually (usually it's the Uploader who builds the writer).
my $writer = XML::Compile::Schema->new([glob '*.xsd'])
->compile(WRITER => 'AmazonEnvelope');
=head2 merchant_id
Required. The merchant id provided by Amazon.
=head2 debug
Whether to enable debugging or not.
use XML::Compile::Schema;
if (-d 'schemas') {
plan tests => 42;
}
else {
plan skip_all => q{Missing "schemas" directory with the xsd from Amazon, skipping feeds tests};
}
my $reader = XML::Compile::Schema->new([glob File::Spec->catfile('schemas',
'*.xsd')])
->compile(READER => 'AmazonEnvelope');
my $xml = <<'XML';
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.02</DocumentVersion>
<MerchantIdentifier>_MERCHANT_ID_</MerchantIdentifier>
</Header>
# testing requires a directory with the schema
if (-d 'schemas') {
plan tests => 51;
}
else {
plan skip_all => q{Missing "schemas" directory with the xsd from Amazon, skipping feeds tests};
}
my $writer = XML::Compile::Schema->new([glob File::Spec->catfile('schemas',
'*.xsd')])
->compile(WRITER => 'AmazonEnvelope');
my @products;
foreach my $product ({
sku => '1234',
ean => '1234123412343',
brand => 'blabla',
title => 'title',
];
my $order = Amazon::MWS::XML::Order->new(order => $order_data,
orderline => $orderline_data);
is($order->subtotal, "119.80");
my @items = $order->items;
is($items[0]->price, "59.90");
ok ($order->order_is_shipped, "It is shipped");
my $global = 0;
my $get_orderline = sub {
diag "Retrieving orderline";
$global++;
return $orderline_data;
};
$order = Amazon::MWS::XML::Order->new(order => $order_data,
retrieve_orderline_sub => $get_orderline);
my $amazon_order_number = $order->amazon_order_number;
is $global, 0, "No get_orderline called yet";
my @newitems = $order->items;
is $global, 1, "get_orderline called";
is_deeply(\@newitems, \@items);
is($items[0]->price, "59.90");
is ($items[0]->amazon_order_item, $items[0]->remote_shop_order_item);
ok ($order->order_is_shipped, "It is shipped");
is ($order->amazon_order_number, $order->remote_shop_order_id, "alias ok");
is ($order->shipping_address->state, $order->shipping_address->region, "state and region are aliases");
is ($order->shipping_address->address1, '');
is ($order->shipping_address->address2, 'Strazze');
is ($order->first_name, 'John U.');
( run in 0.725 second using v1.01-cache-2.11-cpan-49f99fa48dc )