public function testSubmitFeed() { resetLog(); $this->object->setMock(true, 'submitFeed.xml'); $this->assertFalse($this->object->submitFeed()); //nothing set yet $this->assertFalse($this->object->getResponse()); //no response yet either $this->object->setFeedContent('yes'); $this->assertFalse($this->object->submitFeed()); //no feed type set yet $this->object->setFeedType('_MOCK_FEED_'); $ok = $this->object->submitFeed(); //now it is good $this->assertNull($ok); $check = parseLog(); $this->assertEquals('Single Mock File set: submitFeed.xml', $check[1]); $this->assertEquals('Feed\'s contents must be set in order to submit it!', $check[2]); $this->assertEquals('Feed Type must be set in order to submit a feed!', $check[3]); $this->assertEquals('Fetched Mock File: mock/submitFeed.xml', $check[4]); $this->assertEquals('Successfully submitted feed #1234567890 (_MOCK_FEED_)', $check[5]); $o = $this->object->getOptions(); $this->assertEquals('SubmitFeed', $o['Action']); $r = $this->object->getResponse(); $this->assertInternalType('array', $r); $this->assertArrayHasKey('FeedSubmissionId', $r); $this->assertEquals('1234567890', $r['FeedSubmissionId']); $this->assertArrayHasKey('FeedType', $r); $this->assertEquals('_MOCK_FEED_', $r['FeedType']); $this->assertArrayHasKey('SubmittedDate', $r); $this->assertEquals('2012-12-12T12:12:12+00:00', $r['SubmittedDate']); $this->assertArrayHasKey('FeedProcessingStatus', $r); $this->assertEquals('_SUBMITTED_', $r['FeedProcessingStatus']); }
/** * This function will send a provided Inventory feed to Amazon. * Amazon's response to the feed is returned as an array. * This function is not actively used on this example page as a safety precaution. */ function sendInventoryFeed($feed) { try { $amz = new AmazonFeed("myStore"); //store name matches the array key in the config file $amz->setFeedType("_POST_INVENTORY_AVAILABILITY_DATA_"); //feed types listed in documentation $amz->setFeedContent($feed); //can be either XML or CSV data; a file upload method is available as well $amz->submitFeed(); //this is what actually sends the request return $amz->getResponse(); } catch (Exception $ex) { echo 'There was a problem with the Amazon library. Error: ' . $ex->getMessage(); } }