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

Add ordersList method

This commit is contained in:
Ilyas Salikhov 2014-11-06 03:50:15 +03:00
parent be29e86d73
commit a1aa7da86d
2 changed files with 46 additions and 0 deletions

View File

@ -108,6 +108,31 @@ class ApiClient
return $this->client->makeRequest('/orders/history', Client::METHOD_GET, $parameters); return $this->client->makeRequest('/orders/history', Client::METHOD_GET, $parameters);
} }
/**
* Returns filtered orders list
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
* @return void
*/
public function ordersList(array $filter = array(), $page = null, $limit = null)
{
$parameters = array();
if (sizeof($filter)) {
$parameters['filter'] = $filter;
}
if (null !== $page) {
$parameters['page'] = (int) $page;
}
if (null !== $limit) {
$parameters['limit'] = (int) $limit;
}
return $this->client->makeRequest('/orders', Client::METHOD_GET, $parameters);
}
/** /**
* Check ID parameter * Check ID parameter
* *

View File

@ -137,4 +137,25 @@ class ApiClientTest extends TestCase
$this->assertTrue($response->success); $this->assertTrue($response->success);
$this->assertTrue(isset($response['orders'])); $this->assertTrue(isset($response['orders']));
} }
/**
* @group integration
*/
public function testOrdersList()
{
$client = static::getApiClient();
$response = $client->ordersList();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue($response->isSuccessful());
$this->assertTrue(isset($response['orders']));
$response = $client->ordersList(array(), 1, 300);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertFalse($response->isSuccessful());
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue($response->isSuccessful());
}
} }