Added reference and statistic methods
This commit is contained in:
parent
de8514fe14
commit
ca2b480a26
@ -289,6 +289,266 @@ class ApiClient
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns deliveryServices list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliveryServicesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/delivery-services', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns deliveryTypes list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliveryTypesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/delivery-types', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns orderMethods list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function orderMethodsList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/order-methods', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns orderTypes list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function orderTypesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/order-types', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns paymentStatuses list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function paymentStatusesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/payment-statuses', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns paymentTypes list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function paymentTypesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/payment-types', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns productStatuses list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function productStatusesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/product-statuses', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns statusGroups list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function statusGroupsList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/status-groups', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns statuses list
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function statusesList()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/reference/statuses', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit deliveryService
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliveryServicesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/delivery-services/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'deliveryService' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit deliveryType
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliveryTypesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/delivery-types/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'deliveryType' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit orderMethod
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function orderMethodsEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/order-methods/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'orderMethod' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit orderType
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function orderTypesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/order-types/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'orderType' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit paymentStatus
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function paymentStatusesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/payment-statuses/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'paymentStatus' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit paymentType
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function paymentTypesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/payment-types/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'paymentType' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit productStatus
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function productStatusesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/product-statuses/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'productStatus' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit order status
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function statusesEdit(array $data)
|
||||||
|
{
|
||||||
|
if (!isset($data['code'])) {
|
||||||
|
throw new \InvalidArgumentException('Data must contain "code" parameter.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/reference/statuses/' . $data['code'] . '/edit',
|
||||||
|
Client::METHOD_POST,
|
||||||
|
array(
|
||||||
|
'status' => json_encode($data)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update CRM basic statistic
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function statisticUpdate()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest('/statistic/update', Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check ID parameter
|
* Check ID parameter
|
||||||
*
|
*
|
||||||
|
@ -151,6 +151,10 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
isset($response['orders']),
|
isset($response['orders']),
|
||||||
'API returns orders history'
|
'API returns orders history'
|
||||||
);
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
isset($response['generatedAt']),
|
||||||
|
'API returns generatedAt in orders history'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
98
tests/RetailCrm/Tests/ApiClientReferenceTest.php
Normal file
98
tests/RetailCrm/Tests/ApiClientReferenceTest.php
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
class ApiClientReferenceTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
* @dataProvider getListDictionaries
|
||||||
|
*/
|
||||||
|
public function testList($name)
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$method = $name . 'List';
|
||||||
|
$response = $client->$method();
|
||||||
|
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
$this->assertTrue(isset($response[$name]));
|
||||||
|
$this->assertTrue(is_array($response[$name]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
* @dataProvider getEditDictionaries
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testEditingException($name)
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$method = $name . 'Edit';
|
||||||
|
$response = $client->$method(array());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
* @dataProvider getEditDictionaries
|
||||||
|
*/
|
||||||
|
public function testEditing($name)
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$code = 'dict-' . strtolower($name) . '-' . time();
|
||||||
|
$method = $name . 'Edit';
|
||||||
|
$params = array(
|
||||||
|
'code' => $code,
|
||||||
|
'name' => 'Aaa',
|
||||||
|
);
|
||||||
|
if ($name == 'statuses') {
|
||||||
|
$params['group'] = 'new';
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->$method($params);
|
||||||
|
$this->assertEquals(201, $response->getStatusCode());
|
||||||
|
|
||||||
|
$response = $client->$method(array(
|
||||||
|
'code' => $code,
|
||||||
|
'name' => 'Bbb',
|
||||||
|
));
|
||||||
|
if ($response->getStatusCode() > 201) {
|
||||||
|
print_r($response);
|
||||||
|
}
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListDictionaries()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('deliveryServices'),
|
||||||
|
array('deliveryTypes'),
|
||||||
|
array('orderMethods'),
|
||||||
|
array('orderTypes'),
|
||||||
|
array('paymentStatuses'),
|
||||||
|
array('paymentTypes'),
|
||||||
|
array('productStatuses'),
|
||||||
|
array('statusGroups'),
|
||||||
|
array('statuses'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditDictionaries()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('deliveryServices'),
|
||||||
|
array('deliveryTypes'),
|
||||||
|
array('orderMethods'),
|
||||||
|
array('orderTypes'),
|
||||||
|
array('paymentStatuses'),
|
||||||
|
array('paymentTypes'),
|
||||||
|
array('productStatuses'),
|
||||||
|
array('statuses'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -15,4 +15,15 @@ class ApiClientTest extends TestCase
|
|||||||
|
|
||||||
$this->assertInstanceOf('RetailCrm\ApiClient', $client);
|
$this->assertInstanceOf('RetailCrm\ApiClient', $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
public function testStatisticUpdate()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->statisticUpdate();
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user