Add method ordersStatuses
This commit is contained in:
parent
60db8448d7
commit
4e78faa228
@ -167,6 +167,27 @@ class ApiClient
|
||||
return $this->client->makeRequest('/orders', Client::METHOD_GET, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns statuses of the orders
|
||||
*
|
||||
* @param array $ids (default: array())
|
||||
* @param array $externalIds (default: array())
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function ordersStatuses(array $ids = array(), array $externalIds = array())
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if (sizeof($ids)) {
|
||||
$parameters['ids'] = $ids;
|
||||
}
|
||||
if (sizeof($externalIds)) {
|
||||
$parameters['externalIds'] = $externalIds;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest('/orders/statuses', Client::METHOD_GET, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save order IDs' (id and externalId) association in the CRM
|
||||
*
|
||||
|
@ -42,6 +42,49 @@ class ApiClientOrdersTest extends TestCase
|
||||
$response = $client->ordersCreate(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @depends testOrdersCreate
|
||||
*/
|
||||
public function testOrdersStatuses(array $ids)
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
|
||||
$response = $client->ordersStatuses();
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertFalse($response->success);
|
||||
|
||||
$response = $client->ordersStatuses(array(), array('asdf'));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(0, sizeof($orders));
|
||||
|
||||
$response = $client->ordersStatuses(array(), array($ids['externalId']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
$this->assertEquals('new', $orders[0]['status']);
|
||||
|
||||
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
|
||||
$response = $client->ordersStatuses(array($ids['id']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @depends testOrdersCreate
|
||||
|
Loading…
Reference in New Issue
Block a user