1
0
mirror of synced 2024-11-22 05:16:07 +03:00

Add method ordersStatuses

This commit is contained in:
Ilyas Salikhov 2014-11-13 09:37:53 +03:00
parent 60db8448d7
commit 4e78faa228
2 changed files with 64 additions and 0 deletions

View File

@ -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
*

View File

@ -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