diff --git a/README.md b/README.md index d4d3877..9c16498 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Use [API documentation](http://retailcrm.github.io/api-client-php) 2) Run into your project directory: ```bash -composer require retailcrm/api-client-php 5.* --no-dev +composer require retailcrm/api-client-php ~5.0 ``` If you have not used `composer` before, include autoloader into your project. @@ -30,7 +30,7 @@ require 'path/to/vendor/autoload.php'; $client = new \RetailCrm\ApiClient( 'https://demo.retailcrm.ru', 'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH', - 'v5' + \RetailCrm\ApiClient::V5 ); try { @@ -65,7 +65,7 @@ if ($response->isSuccessful()) { $client = new \RetailCrm\ApiClient( 'https://demo.retailcrm.ru', 'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH', - 'v4' + \RetailCrm\ApiClient::V4 ); try { diff --git a/README.ru.md b/README.ru.md index 6b5d1ea..c17989b 100644 --- a/README.ru.md +++ b/README.ru.md @@ -15,7 +15,7 @@ PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/ 2) Выполните в папке проекта: ```bash -composer require retailcrm/api-client-php 5.* --no-dev +composer require retailcrm/api-client-php ~5.0 ``` В конфиг `composer.json` вашего проекта будет добавлена библиотека `retailcrm/api-client-php`, которая установится в папку `vendor/`. При отсутствии файла конфига или папки с вендорами они будут созданы. @@ -32,7 +32,7 @@ require 'path/to/vendor/autoload.php'; $client = new \RetailCrm\ApiClient( 'https://demo.retailcrm.ru', 'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH', - 'v5' + \RetailCrm\ApiClient::V5 ); try { @@ -67,7 +67,7 @@ if ($response->isSuccessful()) { $client = new \RetailCrm\ApiClient( 'https://demo.retailcrm.ru', 'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH', - 'v4' + \RetailCrm\ApiClient::V4 ); try { diff --git a/lib/RetailCrm/ApiClient.php b/lib/RetailCrm/ApiClient.php index b589f15..a1f531e 100644 --- a/lib/RetailCrm/ApiClient.php +++ b/lib/RetailCrm/ApiClient.php @@ -34,6 +34,10 @@ class ApiClient public $request; public $version; + const V3 = 'v3'; + const V4 = 'v4'; + const V5 = 'v5'; + /** * Init version based client * @@ -43,18 +47,18 @@ class ApiClient * @param string $site site code * */ - public function __construct($url, $apiKey, $version = 'v5', $site = null) + public function __construct($url, $apiKey, $version = self::V5, $site = null) { $this->version = $version; switch ($version) { - case 'v5': + case self::V5: $this->request = new ApiVersion5($url, $apiKey, $version, $site); break; - case 'v4': + case self::V4: $this->request = new ApiVersion4($url, $apiKey, $version, $site); break; - case 'v3': + case self::V3: $this->request = new ApiVersion3($url, $apiKey, $version, $site); break; } diff --git a/lib/RetailCrm/Client/ApiVersion4.php b/lib/RetailCrm/Client/ApiVersion4.php index 27f686a..3321e5d 100644 --- a/lib/RetailCrm/Client/ApiVersion4.php +++ b/lib/RetailCrm/Client/ApiVersion4.php @@ -49,6 +49,7 @@ class ApiVersion4 extends AbstractLoader use V4\Orders; use V4\Packs; use V4\References; + use V4\Settings; use V4\Statistic; use V4\Stores; use V4\Telephony; diff --git a/lib/RetailCrm/Methods/V4/Delivery.php b/lib/RetailCrm/Methods/V4/Delivery.php index 6c15a01..c266630 100644 --- a/lib/RetailCrm/Methods/V4/Delivery.php +++ b/lib/RetailCrm/Methods/V4/Delivery.php @@ -50,32 +50,6 @@ trait Delivery ); } - /** - * Edit delivery configuration - * - * @param array $configuration - * - * @throws \RetailCrm\Exception\InvalidJsonException - * @throws \RetailCrm\Exception\CurlException - * @throws \InvalidArgumentException - * - * @return \RetailCrm\Response\ApiResponse - */ - public function deliverySettingsEdit(array $configuration) - { - if (!count($configuration) || empty($configuration['code'])) { - throw new \InvalidArgumentException( - 'Parameter `configuration` must contains a data & configuration `code` must be set' - ); - } - - return $this->client->makeRequest( - sprintf('/delivery/generic/setting/%s/edit', $configuration['code']), - "POST", - ['configuration' => json_encode($configuration)] - ); - } - /** * Delivery tracking update * diff --git a/lib/RetailCrm/Methods/V4/Settings.php b/lib/RetailCrm/Methods/V4/Settings.php new file mode 100644 index 0000000..f663a7e --- /dev/null +++ b/lib/RetailCrm/Methods/V4/Settings.php @@ -0,0 +1,186 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ + +namespace RetailCrm\Methods\V4; + +/** + * PHP version 5.4 + * + * TaskTrait class + * + * @category RetailCrm + * @package RetailCrm + * @author RetailCrm + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ +trait Settings +{ + + /** + * Edit store configuration + * + * @param array $configuration + * + * @throws \RetailCrm\Exception\InvalidJsonException + * @throws \RetailCrm\Exception\CurlException + * @throws \InvalidArgumentException + * + * @return \RetailCrm\Response\ApiResponse + */ + public function storeSettingsEdit(array $configuration) + { + if (!count($configuration) || empty($configuration['code'])) { + throw new \InvalidArgumentException( + 'Parameter `configuration` must contains a data & configuration `code` must be set' + ); + } + + return $this->client->makeRequest( + sprintf('/store/setting/%s/edit', $configuration['code']), + "POST", + ['configuration' => json_encode($configuration)] + ); + } + + /** + * Edit telephony settings + * + * @param string $code symbolic code + * @param string $clientId client id + * @param boolean $active telephony activity + * @param mixed $name service name + * @param mixed $makeCallUrl service init url + * @param mixed $image service logo url(svg file) + * + * @param array $additionalCodes + * @param array $externalPhones + * @param bool $allowEdit + * @param bool $inputEventSupported + * @param bool $outputEventSupported + * @param bool $hangupEventSupported + * @param bool $changeUserStatusUrl + * + * @return \RetailCrm\Response\ApiResponse + */ + public function telephonySettingsEdit( + $code, + $clientId, + $active = false, + $name = false, + $makeCallUrl = false, + $image = false, + $additionalCodes = [], + $externalPhones = [], + $allowEdit = false, + $inputEventSupported = false, + $outputEventSupported = false, + $hangupEventSupported = false, + $changeUserStatusUrl = false + ) { + if (!isset($code)) { + throw new \InvalidArgumentException('Code must be set'); + } + + $parameters['code'] = $code; + + if (!isset($clientId)) { + throw new \InvalidArgumentException('client id must be set'); + } + + $parameters['clientId'] = $clientId; + + if (!isset($active)) { + $parameters['active'] = false; + } else { + $parameters['active'] = $active; + } + + if (!isset($name)) { + throw new \InvalidArgumentException('name must be set'); + } + + if (isset($name)) { + $parameters['name'] = $name; + } + + if (isset($makeCallUrl)) { + $parameters['makeCallUrl'] = $makeCallUrl; + } + + if (isset($image)) { + $parameters['image'] = $image; + } + + if (isset($additionalCodes)) { + $parameters['additionalCodes'] = $additionalCodes; + } + + if (isset($externalPhones)) { + $parameters['externalPhones'] = $externalPhones; + } + + if (isset($allowEdit)) { + $parameters['allowEdit'] = $allowEdit; + } + + if (isset($inputEventSupported)) { + $parameters['inputEventSupported'] = $inputEventSupported; + } + + if (isset($outputEventSupported)) { + $parameters['outputEventSupported'] = $outputEventSupported; + } + + if (isset($hangupEventSupported)) { + $parameters['hangupEventSupported'] = $hangupEventSupported; + } + + if (isset($changeUserStatusUrl)) { + $parameters['changeUserStatusUrl'] = $changeUserStatusUrl; + } + + return $this->client->makeRequest( + "/telephony/setting/$code/edit", + "POST", + ['configuration' => json_encode($parameters)] + ); + } + + /** + * Edit delivery configuration + * + * @param array $configuration + * + * @throws \RetailCrm\Exception\InvalidJsonException + * @throws \RetailCrm\Exception\CurlException + * @throws \InvalidArgumentException + * + * @return \RetailCrm\Response\ApiResponse + */ + public function deliverySettingsEdit(array $configuration) + { + if (!count($configuration) || empty($configuration['code'])) { + throw new \InvalidArgumentException( + 'Parameter `configuration` must contains a data & configuration `code` must be set' + ); + } + + return $this->client->makeRequest( + sprintf('/delivery/generic/setting/%s/edit', $configuration['code']), + "POST", + ['configuration' => json_encode($configuration)] + ); + } +} diff --git a/lib/RetailCrm/Methods/V4/Stores.php b/lib/RetailCrm/Methods/V4/Stores.php index 69e8515..b624edb 100644 --- a/lib/RetailCrm/Methods/V4/Stores.php +++ b/lib/RetailCrm/Methods/V4/Stores.php @@ -55,31 +55,6 @@ trait Stores ); } - /** - * Edit store configuration - * - * @param array $configuration - * - * @throws \RetailCrm\Exception\InvalidJsonException - * @throws \RetailCrm\Exception\CurlException - * @throws \InvalidArgumentException - * - * @return \RetailCrm\Response\ApiResponse - */ - public function storeSettingsEdit(array $configuration) - { - if (!count($configuration) || empty($configuration['code'])) { - throw new \InvalidArgumentException( - 'Parameter `configuration` must contains a data & configuration `code` must be set' - ); - } - - return $this->client->makeRequest( - sprintf('/store/setting/%s/edit', $configuration['code']), - "POST", - ['configuration' => json_encode($configuration)] - ); - } /** * Upload store prices diff --git a/lib/RetailCrm/Methods/V4/Telephony.php b/lib/RetailCrm/Methods/V4/Telephony.php index c9bac37..d5ccb15 100644 --- a/lib/RetailCrm/Methods/V4/Telephony.php +++ b/lib/RetailCrm/Methods/V4/Telephony.php @@ -30,108 +30,4 @@ use RetailCrm\Methods\V3\Telephony as Previous; trait Telephony { use Previous; - - /** - * Edit telephony settings - * - * @param string $code symbolic code - * @param string $clientId client id - * @param boolean $active telephony activity - * @param mixed $name service name - * @param mixed $makeCallUrl service init url - * @param mixed $image service logo url(svg file) - * - * @param array $additionalCodes - * @param array $externalPhones - * @param bool $allowEdit - * @param bool $inputEventSupported - * @param bool $outputEventSupported - * @param bool $hangupEventSupported - * @param bool $changeUserStatusUrl - * - * @return \RetailCrm\Response\ApiResponse - */ - public function telephonySettingsEdit( - $code, - $clientId, - $active = false, - $name = false, - $makeCallUrl = false, - $image = false, - $additionalCodes = [], - $externalPhones = [], - $allowEdit = false, - $inputEventSupported = false, - $outputEventSupported = false, - $hangupEventSupported = false, - $changeUserStatusUrl = false - ) { - if (!isset($code)) { - throw new \InvalidArgumentException('Code must be set'); - } - - $parameters['code'] = $code; - - if (!isset($clientId)) { - throw new \InvalidArgumentException('client id must be set'); - } - - $parameters['clientId'] = $clientId; - - if (!isset($active)) { - $parameters['active'] = false; - } else { - $parameters['active'] = $active; - } - - if (!isset($name)) { - throw new \InvalidArgumentException('name must be set'); - } - - if (isset($name)) { - $parameters['name'] = $name; - } - - if (isset($makeCallUrl)) { - $parameters['makeCallUrl'] = $makeCallUrl; - } - - if (isset($image)) { - $parameters['image'] = $image; - } - - if (isset($additionalCodes)) { - $parameters['additionalCodes'] = $additionalCodes; - } - - if (isset($externalPhones)) { - $parameters['externalPhones'] = $externalPhones; - } - - if (isset($allowEdit)) { - $parameters['allowEdit'] = $allowEdit; - } - - if (isset($inputEventSupported)) { - $parameters['inputEventSupported'] = $inputEventSupported; - } - - if (isset($outputEventSupported)) { - $parameters['outputEventSupported'] = $outputEventSupported; - } - - if (isset($hangupEventSupported)) { - $parameters['hangupEventSupported'] = $hangupEventSupported; - } - - if (isset($changeUserStatusUrl)) { - $parameters['changeUserStatusUrl'] = $changeUserStatusUrl; - } - - return $this->client->makeRequest( - "/telephony/setting/$code/edit", - "POST", - ['configuration' => json_encode($parameters)] - ); - } } diff --git a/lib/RetailCrm/Methods/V5/Customers.php b/lib/RetailCrm/Methods/V5/Customers.php index 2c420ff..97774d5 100644 --- a/lib/RetailCrm/Methods/V5/Customers.php +++ b/lib/RetailCrm/Methods/V5/Customers.php @@ -115,7 +115,7 @@ trait Customers return $this->client->makeRequest( '/customers/notes/create', "POST", - ['note' => json_encode($note)] + $this->fillSite($site, ['note' => json_encode($note)]) ); } diff --git a/tests/RetailCrm/Tests/Methods/Version4/ApiClientCustomersTest.php b/tests/RetailCrm/Tests/Methods/Version4/ApiClientCustomersTest.php index 232ee98..73cb1a5 100644 --- a/tests/RetailCrm/Tests/Methods/Version4/ApiClientCustomersTest.php +++ b/tests/RetailCrm/Tests/Methods/Version4/ApiClientCustomersTest.php @@ -34,7 +34,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersCreate() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $externalId = 'c-create-' . time(); @@ -59,7 +59,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCreateExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersCreate([]); } @@ -73,7 +73,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersGet(array $ids) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->customersGet(678678678); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -99,7 +99,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersGetException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersGet(678678678, 'asdf'); } @@ -111,7 +111,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersEdit(array $ids) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->customersEdit( [ @@ -138,7 +138,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersEditExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersEdit([], 'asdf'); } @@ -148,7 +148,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersEditException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersEdit(['id' => 678678678], 'asdf'); } @@ -157,7 +157,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersList() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->customersList(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -185,7 +185,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersFixExternalIdsException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersFixExternalIds([]); } @@ -194,7 +194,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersFixExternalIds() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersCreate([ 'firstName' => 'Aaa111', @@ -246,7 +246,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersUploadExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->customersUpload([]); } @@ -255,7 +255,7 @@ class ApiClientCustomersTest extends TestCase */ public function testCustomersUpload() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $externalIdA = 'upload-a-' . time(); $externalIdB = 'upload-b-' . time(); diff --git a/tests/RetailCrm/Tests/Methods/Version4/ApiClientOrdersTest.php b/tests/RetailCrm/Tests/Methods/Version4/ApiClientOrdersTest.php index 974a555..48363b7 100644 --- a/tests/RetailCrm/Tests/Methods/Version4/ApiClientOrdersTest.php +++ b/tests/RetailCrm/Tests/Methods/Version4/ApiClientOrdersTest.php @@ -34,7 +34,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersCreate() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $externalId = 'o-create-' . time(); @@ -58,7 +58,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersCreateExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersCreate([]); } @@ -70,7 +70,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersStatuses(array $ids) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersStatuses(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -117,7 +117,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersGet(array $ids) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersGet(678678678); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -143,7 +143,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersGetException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersGet(678678678, 'asdf'); } @@ -155,7 +155,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEdit(array $ids) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersEdit( [ @@ -182,7 +182,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEditExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersEdit([], 'asdf'); } @@ -192,7 +192,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEditException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersEdit(['id' => 678678678], 'asdf'); } @@ -201,7 +201,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersHistory() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersHistory(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -214,7 +214,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersList() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersList(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -238,7 +238,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersFixExternalIdsException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersFixExternalIds([]); } @@ -247,7 +247,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersFixExternalIds() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->ordersCreate([ 'firstName' => 'Aaa', @@ -292,7 +292,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersUploadExceptionEmpty() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->ordersUpload([]); } @@ -301,7 +301,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersUpload() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $externalIdA = 'upload-a-' . time(); $externalIdB = 'upload-b-' . time(); diff --git a/tests/RetailCrm/Tests/Methods/Version4/ApiClientReferenceTest.php b/tests/RetailCrm/Tests/Methods/Version4/ApiClientReferenceTest.php index 4ac9251..4844b15 100644 --- a/tests/RetailCrm/Tests/Methods/Version4/ApiClientReferenceTest.php +++ b/tests/RetailCrm/Tests/Methods/Version4/ApiClientReferenceTest.php @@ -34,7 +34,7 @@ class ApiClientReferenceTest extends TestCase */ public function testList($name) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $method = $name . 'List'; $response = $client->request->$method(); @@ -56,7 +56,7 @@ class ApiClientReferenceTest extends TestCase */ public function testEditingException($name) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $method = $name . 'Edit'; $client->request->$method([]); @@ -70,7 +70,7 @@ class ApiClientReferenceTest extends TestCase */ public function testEditing($name) { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $code = 'dict-' . strtolower($name) . '-' . time(); $method = $name . 'Edit'; @@ -104,7 +104,7 @@ class ApiClientReferenceTest extends TestCase public function testSiteEditing() { $name = 'sites'; - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $code = 'dict-' . strtolower($name) . '-' . time(); $method = $name . 'Edit'; diff --git a/tests/RetailCrm/Tests/Methods/Version4/ApiClientStoreTest.php b/tests/RetailCrm/Tests/Methods/Version4/ApiClientStoreTest.php index 4034756..7389ef6 100644 --- a/tests/RetailCrm/Tests/Methods/Version4/ApiClientStoreTest.php +++ b/tests/RetailCrm/Tests/Methods/Version4/ApiClientStoreTest.php @@ -35,7 +35,7 @@ class ApiClientStoreTest extends TestCase */ public function testStoreCreate() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->storesEdit(['name' => self::SNAME, 'code' => self::SCODE]); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -48,7 +48,7 @@ class ApiClientStoreTest extends TestCase */ public function testStoreInventories() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->storeInventories(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -66,7 +66,7 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesException() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $client->request->storeInventoriesUpload([]); } @@ -75,7 +75,7 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesUpload() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->storeInventoriesUpload([ [ @@ -109,7 +109,7 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesFailed() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $externalIdA = 'upload-a-' . time(); $externalIdB = 'upload-b-' . time(); @@ -136,7 +136,7 @@ class ApiClientStoreTest extends TestCase */ public function testStoreProducts() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->storeProducts(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); diff --git a/tests/RetailCrm/Tests/Methods/Version4/ApiClientTelephonyTest.php b/tests/RetailCrm/Tests/Methods/Version4/ApiClientTelephonyTest.php index eb5d727..6b91584 100644 --- a/tests/RetailCrm/Tests/Methods/Version4/ApiClientTelephonyTest.php +++ b/tests/RetailCrm/Tests/Methods/Version4/ApiClientTelephonyTest.php @@ -40,7 +40,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonySettingsEdit() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->telephonySettingsEdit( self::TEL_CODE, @@ -67,7 +67,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonySettingsGet() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->telephonySettingsGet(self::TEL_CODE); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -84,7 +84,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyEvent() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->telephonyCallEvent( '+79999999999', @@ -109,7 +109,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyUpload() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->telephonyCallsUpload( [ @@ -148,7 +148,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyManager() { - $client = static::getApiClient(null, null, 'v4'); + $client = static::getApiClient(null, null, \RetailCrm\ApiClient::V4); $response = $client->request->telephonyCallManager('+79999999999', 1); diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientOrdersTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientOrdersTest.php index f59f565..1f52337 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientOrdersTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientOrdersTest.php @@ -34,7 +34,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersCreate() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $externalId = 'o-create-' . time(); @@ -58,7 +58,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersCreateExceptionEmpty() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersCreate([]); } @@ -70,7 +70,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersStatuses(array $ids) { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersStatuses(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -117,7 +117,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersGet(array $ids) { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersGet(678678678); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -143,7 +143,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersGetException() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersGet(678678678, 'asdf'); } @@ -155,7 +155,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEdit(array $ids) { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersEdit( [ @@ -182,7 +182,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEditExceptionEmpty() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersEdit([], 'asdf'); } @@ -192,7 +192,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersEditException() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersEdit(['id' => 678678678], 'asdf'); } @@ -201,7 +201,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersHistory() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersHistory(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -214,7 +214,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersList() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersList(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -238,7 +238,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersFixExternalIdsException() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersFixExternalIds([]); } @@ -247,7 +247,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersFixExternalIds() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersCreate([ 'firstName' => 'Aaa', @@ -292,7 +292,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersUploadExceptionEmpty() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->ordersUpload([]); } @@ -301,7 +301,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersUpload() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $externalIdA = 'upload-a-' . time(); $externalIdB = 'upload-b-' . time(); @@ -335,7 +335,7 @@ class ApiClientOrdersTest extends TestCase */ public function testOrdersCombine() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $responseCreateFirst = $client->request->ordersCreate([ 'firstName' => 'Aaa111', @@ -372,7 +372,7 @@ class ApiClientOrdersTest extends TestCase public function testOrdersPayment() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $externalId = 'AA-' . time(); $responseCreateFirst = $client->request->ordersCreate([ diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientPacksTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientPacksTest.php index 34d6991..5f246d5 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientPacksTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientPacksTest.php @@ -32,7 +32,7 @@ class ApiClientPacksTest extends TestCase */ public function testPacksHistory() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->ordersPacksHistory(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -53,7 +53,8 @@ class ApiClientPacksTest extends TestCase */ public function testPacksCreateFailed() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); + $pack = [ 'itemId' => 12, 'store' => 'test', diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientPricesTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientPricesTest.php index 07cc993..b1a9238 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientPricesTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientPricesTest.php @@ -33,8 +33,7 @@ class ApiClientPricesTest extends TestCase */ public function testPricesEdit() { - - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->pricesTypesEdit( [ @@ -56,8 +55,7 @@ class ApiClientPricesTest extends TestCase */ public function testPricesGet() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->pricesTypes(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); static::assertTrue(in_array($response->getStatusCode(), [200, 201])); @@ -72,7 +70,7 @@ class ApiClientPricesTest extends TestCase */ public function testPricesUploadExceptionEmpty() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $client->request->storePricesUpload([]); } @@ -82,7 +80,8 @@ class ApiClientPricesTest extends TestCase */ public function testPricesUpload() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $xmlIdA = 'upload-a-' . time(); $xmlIdB = 'upload-b-' . time(); diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientReferenceTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientReferenceTest.php index da64adf..646e34a 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientReferenceTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientReferenceTest.php @@ -34,7 +34,8 @@ class ApiClientReferenceTest extends TestCase */ public function testList($name) { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $method = $name . 'List'; $response = $client->request->$method(); @@ -56,7 +57,8 @@ class ApiClientReferenceTest extends TestCase */ public function testEditingException($name) { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $method = $name . 'Edit'; $client->request->$method([]); @@ -70,7 +72,8 @@ class ApiClientReferenceTest extends TestCase */ public function testEditing($name) { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $code = 'dict-' . strtolower($name) . '-' . time(); $method = $name . 'Edit'; @@ -104,7 +107,8 @@ class ApiClientReferenceTest extends TestCase public function testSiteEditing() { $name = 'sites'; - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $code = 'dict-' . strtolower($name) . '-' . time(); $method = $name . 'Edit'; diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php index cbb4a66..1948cbe 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientStoreTest.php @@ -35,7 +35,8 @@ class ApiClientStoreTest extends TestCase */ public function testStoreCreate() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $response = $client->request->storesEdit(['name' => self::SNAME, 'code' => self::SCODE]); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -48,7 +49,8 @@ class ApiClientStoreTest extends TestCase */ public function testStoreInventories() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $response = $client->request->storeInventories(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -66,7 +68,8 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesException() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $client->request->storeInventoriesUpload([]); } @@ -75,7 +78,8 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesUpload() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $response = $client->request->storeInventoriesUpload([ [ @@ -109,7 +113,8 @@ class ApiClientStoreTest extends TestCase */ public function testInventoriesFailed() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $externalIdA = 'upload-a-' . time(); $externalIdB = 'upload-b-' . time(); @@ -136,7 +141,8 @@ class ApiClientStoreTest extends TestCase */ public function testStoreProducts() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $response = $client->request->storeProducts(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -149,7 +155,8 @@ class ApiClientStoreTest extends TestCase */ public function testStoreProductsGroups() { - $client = static::getApiClient(null, null, "v5"); + + $client = static::getApiClient(); $response = $client->request->storeProductsGroups(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTasksTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTasksTest.php index ca0a623..024ef9b 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTasksTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTasksTest.php @@ -32,8 +32,8 @@ class ApiClientTasksTest extends TestCase */ public function testTasksList() { - $client = static::getApiClient(null, null, 'v5'); + $client = static::getApiClient(); $response = $client->request->tasksList(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -46,14 +46,14 @@ class ApiClientTasksTest extends TestCase */ public function testTasksCreateExceptionEmpty() { - $client = static::getApiClient(null, null, 'v5'); + $client = static::getApiClient(); $client->request->tasksCreate([]); } public function testTasksCRU() { - $client = static::getApiClient(null, null, 'v5'); + $client = static::getApiClient(); $task = [ 'text' => 'test task', 'commentary' => 'test task commentary', diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php index 7faaee4..9520474 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientTelephonyTest.php @@ -31,33 +31,6 @@ class ApiClientTelephonyTest extends TestCase const TEL_CLIENT = '456'; const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg'; - /** - * Settings Edit test - * - * @group telephony - * - * @return void - */ - public function testTelephonySettingsEdit() - { - $client = static::getApiClient(null, null, "v5"); - - $response = $client->request->telephonySettingsEdit( - self::TEL_CODE, - self::TEL_CLIENT, - true, - 'TestTelephonyV5', - false, - self::TEL_IMAGE, - [['userId' => $_SERVER['CRM_USER_ID'], 'code' => '101']], - [['siteCode' => 'api-client-php', 'externalPhone' => '+74950000000']] - ); - - static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - static::assertTrue(in_array($response->getStatusCode(), [200, 201])); - static::assertTrue($response->isSuccessful()); - } - /** * Settings Get test * @@ -67,8 +40,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonySettingsGet() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->telephonySettingsGet(self::TEL_CODE); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); static::assertEquals(200, $response->getStatusCode()); @@ -84,8 +56,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyEvent() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->telephonyCallEvent( '+79999999999', 'in', @@ -109,8 +80,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyUpload() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->telephonyCallsUpload( [ [ @@ -148,8 +118,7 @@ class ApiClientTelephonyTest extends TestCase */ public function testTelephonyManager() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->telephonyCallManager('+79999999999', 1); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientUsersTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientUsersTest.php index 15e912c..d107a69 100644 --- a/tests/RetailCrm/Tests/Methods/Version5/ApiClientUsersTest.php +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientUsersTest.php @@ -32,7 +32,7 @@ class ApiClientUsersTest extends TestCase */ public function testUsersGroups() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->usersGroups(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -45,7 +45,7 @@ class ApiClientUsersTest extends TestCase */ public function testUsersList() { - $client = static::getApiClient(null, null, "v5"); + $client = static::getApiClient(); $response = $client->request->usersList(); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); @@ -58,8 +58,7 @@ class ApiClientUsersTest extends TestCase */ public function testUsersGet() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->usersGet($_SERVER["CRM_USER_ID"]); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); static::assertTrue(in_array($response->getStatusCode(), [200, 201])); @@ -71,8 +70,7 @@ class ApiClientUsersTest extends TestCase */ public function testUsersStatus() { - $client = static::getApiClient(null, null, "v5"); - + $client = static::getApiClient(); $response = $client->request->usersStatus($_SERVER["CRM_USER_ID"], 'dinner'); static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); static::assertTrue(in_array($response->getStatusCode(), [200, 201]));