Amazon-MWS

 view release on metacpan or  search on metacpan

t/feeds.t  view on Meta::CPAN

#!perl

use strict;
use warnings;
use utf8;
use Amazon::MWS::XML::Product;
use Amazon::MWS::XML::Feed;
use XML::Compile::Schema;
use File::Spec;
use Test::More;

# 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',
                      price => '10.00',
                      description => 'my desc',
                      images => [ 'http://example.org/pippo.jpg' ],
                      category_code => '111111',
                      product_data => { CE => { ProductType  => { PhoneAccessory => {} } } },
                      manufacturer => 'A manufacturer',
                      manufacturer_part_number => '1234123412343',
                      condition => 'Refurbished',
                      condition_note => 'Looks like new',
                      inventory => 1,
                      search_terms => [qw/a b c d e f g/],
                      features => [qw/f1 f2 f3/, '',  qw/f4 f5 f6 f7/],
                      shipping_weight => '5',
                      shipping_weight_unit => 'GR',
                      package_weight => 290,
                     },
                     {
                      sku => '3333',
                      ean => '4444123412343',
                      brand => 'brand',
                      title => 'title2',
                      price => '12.00',
                      description => 'my desc 2',
                      images => [ 'http://example.org/pluto.jpg' ],
                      category_code => '111111',
                      product_data => { Sports => { ProductType => 'SportingGoods' } },
                      manufacturer_part_number => '4444123412343',
                      inventory => 2,
                      shipping_weight => 0,
                      package_weight => 0,
                     }) {
    push @products, Amazon::MWS::XML::Product->new(%$product);
}



( run in 0.779 second using v1.01-cache-2.11-cpan-39bf76dae61 )