Add ordersList method
This commit is contained in:
parent
be29e86d73
commit
a1aa7da86d
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user