public function testFetchOrdersToken2() { resetLog(); $this->object->setMock(true, array('fetchOrderListToken.xml', 'fetchOrderListToken2.xml')); //with using token $this->object->setUseToken(); $this->assertNull($this->object->fetchOrders()); $check = parseLog(); $this->assertEquals('Mock files array set.', $check[1]); $this->assertEquals('Fetched Mock File: mock/fetchOrderListToken.xml', $check[2]); $this->assertEquals('Mock Mode set to ON', $check[3]); $this->assertEquals('Mock files array set.', $check[4]); $this->assertEquals('Mock Mode set to ON', $check[5]); $this->assertEquals('Mock files array set.', $check[6]); $this->assertEquals('Recursively fetching more orders', $check[7]); $this->assertEquals('Fetched Mock File: mock/fetchOrderListToken2.xml', $check[8]); $this->assertEquals('Mock Mode set to ON', $check[9]); $this->assertEquals('Mock files array set.', $check[10]); $this->assertFalse($this->object->hasToken()); $o = $this->object->getOptions(); $this->assertEquals('ListOrdersByNextToken', $o['Action']); $this->assertArrayNotHasKey('CreatedAfter', $o); $r = $this->object->getList(); $this->assertArrayHasKey(0, $r); $this->assertArrayHasKey(1, $r); $this->assertArrayHasKey(2, $r); $this->assertInternalType('object', $r[0]); $this->assertInternalType('object', $r[1]); $this->assertInternalType('object', $r[2]); $this->assertEquals(3, count($r)); $this->assertNotEquals($r[0], $r[1]); }
/** * This function will retrieve a list of all unshipped MFN orders made within the past 24 hours. * The entire list of orders is returned, with each order contained in an AmazonOrder object. * Note that the items in the order are not included in the data. * To get the order's items, the "fetchItems" method must be used by the specific order object. */ function getAmazonOrders() { require '../includes/classes.php'; //autoload classes, not needed if composer is being used try { $amz = new AmazonOrderList("myStore"); //store name matches the array key in the config file $amz->setLimits('Modified', "- 24 hours"); //accepts either specific timestamps or relative times $amz->setFulfillmentChannelFilter("MFN"); //no Amazon-fulfilled orders $amz->setOrderStatusFilter(array("Unshipped", "PartiallyShipped", "Canceled", "Unfulfillable")); //no shipped or pending orders $amz->setUseToken(); //tells the object to automatically use tokens right away $amz->fetchOrders(); //this is what actually sends the request return $amz->getList(); } catch (Exception $ex) { echo 'There was a problem with the Amazon library. Error: ' . $ex->getMessage(); } }