Amazon-MWS

 view release on metacpan or  search on metacpan

lib/Amazon/MWS/Uploader.pm  view on Meta::CPAN


    die "Unrecognized type $type" unless $names{$type};

    # no feed id, it's a new batch
    if (!$feed_id) {
        print "No feed id found, doing a request for $job_id $type\n";
        my $feed_content = $self->_slurp_file($record->{feed_file});
        my $res;
        try {
            $res = $self->client
              ->SubmitFeed(content_type => 'text/xml; charset=utf-8',
                           FeedType => $names{$type},
                           FeedContent => $feed_content,
                           MarketplaceIdList => [$self->marketplace_id],
                          );
        }
        catch {
            warn "Failure to submit $type feed: \n";
            if (ref($_)) {
                if ($_->can('xml')) {
                    warn $_->xml;

t/SubmitFeed.t  view on Meta::CPAN

    marketplace_id => 'goo',
);

my $agent = Test::MockObject->new->mock(
    request => sub {
        my $r = HTTP::Response->new(200);
        $r->content(<<'RESPONSE_XML');
<?xml version="1.0"?>
<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/"><SubmitFeedResult><FeedSubmissionInfo><FeedSubmissionId>11223344</FeedSubmissionId><FeedType>_POST_ORDER_FULFILLMENT_DATA_</FeedType><SubmittedDate>2011-02-08T09:49:35+00:00</Submit...
RESPONSE_XML
        $r->content_type('text/xml; charset=utf-8');
        return $r;
    }
);

$client = Test::MockObject::Extends->new($client)->mock(
    agent => sub { $agent }
);

my $response;
eval {
$response = $client->SubmitFeed(
    content_type    => 'text/xml; charset=utf-8',
    FeedType        => _POST_ORDER_FULFILLMENT_DATA_,
    PurgeAndReplace => 0,
    FeedContent     => <<'FEED_CONTENT',
<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
  </Header>
  <MessageType>Product</MessageType>



( run in 1.095 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )