Amazon-MWS
view release on metacpan or search on metacpan
lib/Amazon/MWS/XML/Feed.pm view on Meta::CPAN
package Amazon::MWS::XML::Feed;
use strict;
use warnings;
use utf8;
use base 'Amazon::MWS::XML::GenericFeed';
use Data::Dumper;
use Moo;
=head1 NAME
Amazon::MWS::XML::Feed -- module to create XML feeds for Amazon MWS
=head2 DESCRIPTION
Extends Amazon::MWS::XML::GenericFeed and inherits its accessors/methods.
=head1 ACCESSORS
=head2 merchant_id
Required. The merchant id provided by Amazon.
=head2 products
Required. An arrayref with products objects. The objects must respond
to the following methods:
=over 4
=item as_hash
The data structure to populate the Product stanza.
=back
=cut
has products => (is => 'ro',
required => 1,
isa => sub {
die "Not an arrayref" unless ref($_[0]) eq 'ARRAY';
});
sub _create_feed {
my ($self, $operation) = @_;
my %methods = (
Product => 'as_product_hash',
Inventory => 'as_inventory_hash',
Price => 'as_price_hash',
ProductImage => 'as_images_array',
Relationship => 'as_variants_hash',
);
my $method = $methods{$operation} or die "$operation is not supported";
my @messages;
my $message_counter = 1;
my @products = @{ $self->products };
for (my $i = 0; $i < @products; $i++) {
my $data = $products[$i]->$method;
( run in 0.817 second using v1.01-cache-2.11-cpan-39bf76dae61 )