From 4f57734e92c714547dad4382c35c08cb08097255 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 22 Jun 2017 16:42:42 +0300 Subject: [PATCH] Minor bugfixes (#42) --- README.md | 6 +- README.ru.md | 6 +- lib/RetailCrm/ApiClient.php | 12 +- lib/RetailCrm/Client/AbstractLoader.php | 4 +- lib/RetailCrm/Client/ApiVersion3.php | 4 +- lib/RetailCrm/Client/ApiVersion4.php | 5 +- lib/RetailCrm/Client/ApiVersion5.php | 5 +- lib/RetailCrm/Exception/CurlException.php | 2 +- .../Exception/InvalidJsonException.php | 2 +- lib/RetailCrm/Methods/V3/Customers.php | 4 +- lib/RetailCrm/Methods/V3/Orders.php | 4 +- lib/RetailCrm/Methods/V3/Packs.php | 4 +- lib/RetailCrm/Methods/V3/References.php | 4 +- lib/RetailCrm/Methods/V3/Statistic.php | 2 +- lib/RetailCrm/Methods/V3/Stores.php | 4 +- lib/RetailCrm/Methods/V4/Customers.php | 4 +- lib/RetailCrm/Methods/V4/Delivery.php | 30 +-- lib/RetailCrm/Methods/V4/Orders.php | 4 +- lib/RetailCrm/Methods/V4/Packs.php | 4 +- lib/RetailCrm/Methods/V4/References.php | 4 +- lib/RetailCrm/Methods/V4/Settings.php | 186 ++++++++++++++++++ lib/RetailCrm/Methods/V4/Statistic.php | 4 +- lib/RetailCrm/Methods/V4/Stores.php | 29 +-- lib/RetailCrm/Methods/V4/Telephony.php | 104 ---------- lib/RetailCrm/Methods/V4/Users.php | 4 +- lib/RetailCrm/Methods/V5/Customers.php | 8 +- lib/RetailCrm/Methods/V5/Delivery.php | 4 +- lib/RetailCrm/Methods/V5/Marketplace.php | 33 ---- lib/RetailCrm/Methods/V5/Orders.php | 5 +- lib/RetailCrm/Methods/V5/Packs.php | 4 +- lib/RetailCrm/Methods/V5/References.php | 4 +- lib/RetailCrm/Methods/V5/Statistic.php | 4 +- lib/RetailCrm/Methods/V5/Stores.php | 4 +- lib/RetailCrm/Methods/V5/Tasks.php | 4 +- lib/RetailCrm/Methods/V5/Users.php | 4 +- .../Version4/ApiClientCustomersTest.php | 24 +-- .../Methods/Version4/ApiClientOrdersTest.php | 28 +-- .../Version4/ApiClientReferenceTest.php | 8 +- .../Methods/Version4/ApiClientStoreTest.php | 12 +- .../Version4/ApiClientTelephonyTest.php | 10 +- .../Methods/Version5/ApiClientOrdersTest.php | 32 +-- .../Methods/Version5/ApiClientPacksTest.php | 5 +- .../Methods/Version5/ApiClientPricesTest.php | 11 +- .../Version5/ApiClientReferenceTest.php | 12 +- .../Methods/Version5/ApiClientStoreTest.php | 21 +- .../Methods/Version5/ApiClientTasksTest.php | 6 +- .../Version5/ApiClientTelephonyTest.php | 39 +--- .../Methods/Version5/ApiClientUsersTest.php | 10 +- 48 files changed, 356 insertions(+), 377 deletions(-) create mode 100644 lib/RetailCrm/Methods/V4/Settings.php delete mode 100644 lib/RetailCrm/Methods/V5/Marketplace.php 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/AbstractLoader.php b/lib/RetailCrm/Client/AbstractLoader.php index 061d07f..08613cd 100644 --- a/lib/RetailCrm/Client/AbstractLoader.php +++ b/lib/RetailCrm/Client/AbstractLoader.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * API client class + * Abstract API client * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Http\Client; /** * PHP version 5.4 * - * API client class + * Abstract API client class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Client/ApiVersion3.php b/lib/RetailCrm/Client/ApiVersion3.php index 30f6aa6..446c9c4 100644 --- a/lib/RetailCrm/Client/ApiVersion3.php +++ b/lib/RetailCrm/Client/ApiVersion3.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * API client class + * API client v3 * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3; /** * PHP version 5.4 * - * API client class + * API client v3 class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Client/ApiVersion4.php b/lib/RetailCrm/Client/ApiVersion4.php index 27f686a..067b080 100644 --- a/lib/RetailCrm/Client/ApiVersion4.php +++ b/lib/RetailCrm/Client/ApiVersion4.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * API client class + * API client v4 * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4; /** * PHP version 5.4 * - * API client class + * API client v4 class * * @category RetailCrm * @package RetailCrm @@ -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/Client/ApiVersion5.php b/lib/RetailCrm/Client/ApiVersion5.php index cbb9c79..b8a6f3e 100644 --- a/lib/RetailCrm/Client/ApiVersion5.php +++ b/lib/RetailCrm/Client/ApiVersion5.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * API client class + * API client v5 * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V5; /** * PHP version 5.4 * - * API client class + * API client v5 class * * @category RetailCrm * @package RetailCrm @@ -46,7 +46,6 @@ class ApiVersion5 extends AbstractLoader use V5\Customers; use V5\CustomFields; use V5\Delivery; - use V5\Marketplace; use V5\Orders; use V5\Packs; use V5\References; diff --git a/lib/RetailCrm/Exception/CurlException.php b/lib/RetailCrm/Exception/CurlException.php index 922a810..900f3e5 100644 --- a/lib/RetailCrm/Exception/CurlException.php +++ b/lib/RetailCrm/Exception/CurlException.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * Class CurlException + * CurlException * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Exception/InvalidJsonException.php b/lib/RetailCrm/Exception/InvalidJsonException.php index d6288b3..08c98f7 100644 --- a/lib/RetailCrm/Exception/InvalidJsonException.php +++ b/lib/RetailCrm/Exception/InvalidJsonException.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * Class InvalidJsonException + * InvalidJsonException * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/Customers.php b/lib/RetailCrm/Methods/V3/Customers.php index 796f749..f6f1350 100644 --- a/lib/RetailCrm/Methods/V3/Customers.php +++ b/lib/RetailCrm/Methods/V3/Customers.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Customers * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * - * TaskTrait class + * Customers class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/Orders.php b/lib/RetailCrm/Methods/V3/Orders.php index 56bd6bc..13ba925 100644 --- a/lib/RetailCrm/Methods/V3/Orders.php +++ b/lib/RetailCrm/Methods/V3/Orders.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Orders * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * - * TaskTrait class + * Orders class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/Packs.php b/lib/RetailCrm/Methods/V3/Packs.php index c493ce3..e08713a 100644 --- a/lib/RetailCrm/Methods/V3/Packs.php +++ b/lib/RetailCrm/Methods/V3/Packs.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Packs * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * - * TaskTrait class + * Packs class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/References.php b/lib/RetailCrm/Methods/V3/References.php index 4b9279b..76075fc 100644 --- a/lib/RetailCrm/Methods/V3/References.php +++ b/lib/RetailCrm/Methods/V3/References.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * References * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * - * TaskTrait class + * References class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/Statistic.php b/lib/RetailCrm/Methods/V3/Statistic.php index ed49eb2..a98bbc7 100644 --- a/lib/RetailCrm/Methods/V3/Statistic.php +++ b/lib/RetailCrm/Methods/V3/Statistic.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * Statistic class + * Statistic * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V3/Stores.php b/lib/RetailCrm/Methods/V3/Stores.php index 8b9022b..a370764 100644 --- a/lib/RetailCrm/Methods/V3/Stores.php +++ b/lib/RetailCrm/Methods/V3/Stores.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Stores * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V3; /** * PHP version 5.4 * - * TaskTrait class + * Stores class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/Customers.php b/lib/RetailCrm/Methods/V4/Customers.php index 0ccf28d..b850061 100644 --- a/lib/RetailCrm/Methods/V4/Customers.php +++ b/lib/RetailCrm/Methods/V4/Customers.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Customers * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Customers as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Customers class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/Delivery.php b/lib/RetailCrm/Methods/V4/Delivery.php index 6c15a01..e2d22fb 100644 --- a/lib/RetailCrm/Methods/V4/Delivery.php +++ b/lib/RetailCrm/Methods/V4/Delivery.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Delivery * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V4; /** * PHP version 5.4 * - * TaskTrait class + * Delivery class * * @category RetailCrm * @package RetailCrm @@ -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/Orders.php b/lib/RetailCrm/Methods/V4/Orders.php index dc8bb80..d34e752 100644 --- a/lib/RetailCrm/Methods/V4/Orders.php +++ b/lib/RetailCrm/Methods/V4/Orders.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Orders * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Orders as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Orders class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/Packs.php b/lib/RetailCrm/Methods/V4/Packs.php index 04fc4b9..da00cfc 100644 --- a/lib/RetailCrm/Methods/V4/Packs.php +++ b/lib/RetailCrm/Methods/V4/Packs.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Packs * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Packs as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Packs class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/References.php b/lib/RetailCrm/Methods/V4/References.php index e40f454..92a0404 100644 --- a/lib/RetailCrm/Methods/V4/References.php +++ b/lib/RetailCrm/Methods/V4/References.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * References * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\References as Previous; /** * PHP version 5.4 * - * TaskTrait class + * References class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/Settings.php b/lib/RetailCrm/Methods/V4/Settings.php new file mode 100644 index 0000000..e0167fd --- /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 + * + * Settings 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/Statistic.php b/lib/RetailCrm/Methods/V4/Statistic.php index be8bb8a..ebe3841 100644 --- a/lib/RetailCrm/Methods/V4/Statistic.php +++ b/lib/RetailCrm/Methods/V4/Statistic.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Statistic * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Statistic as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Statistic class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V4/Stores.php b/lib/RetailCrm/Methods/V4/Stores.php index 69e8515..7a2a21b 100644 --- a/lib/RetailCrm/Methods/V4/Stores.php +++ b/lib/RetailCrm/Methods/V4/Stores.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Stores * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Stores as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Stores class * * @category RetailCrm * @package RetailCrm @@ -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/V4/Users.php b/lib/RetailCrm/Methods/V4/Users.php index 8f778cf..5180f52 100644 --- a/lib/RetailCrm/Methods/V4/Users.php +++ b/lib/RetailCrm/Methods/V4/Users.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Users * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V4; /** * PHP version 5.4 * - * TaskTrait class + * Users class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Customers.php b/lib/RetailCrm/Methods/V5/Customers.php index 2c420ff..6c29a36 100644 --- a/lib/RetailCrm/Methods/V5/Customers.php +++ b/lib/RetailCrm/Methods/V5/Customers.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Customers * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4\Customers as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Customers class * * @category RetailCrm * @package RetailCrm @@ -115,12 +115,12 @@ trait Customers return $this->client->makeRequest( '/customers/notes/create', "POST", - ['note' => json_encode($note)] + $this->fillSite($site, ['note' => json_encode($note)]) ); } /** - * Create customer note + * Delete customer note * * @param integer $id * diff --git a/lib/RetailCrm/Methods/V5/Delivery.php b/lib/RetailCrm/Methods/V5/Delivery.php index 71ce0a0..0469177 100644 --- a/lib/RetailCrm/Methods/V5/Delivery.php +++ b/lib/RetailCrm/Methods/V5/Delivery.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Delivery * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4\Delivery as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Delivery class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Marketplace.php b/lib/RetailCrm/Methods/V5/Marketplace.php deleted file mode 100644 index 0611933..0000000 --- a/lib/RetailCrm/Methods/V5/Marketplace.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 - */ - -namespace RetailCrm\Methods\V5; - -use RetailCrm\Methods\V4\Marketplace as Previous; - -/** - * PHP version 5.4 - * - * Marketplace class - * - * @category RetailCrm - * @package RetailCrm - * @author RetailCrm - * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 - */ -trait Marketplace -{ - use Previous; -} diff --git a/lib/RetailCrm/Methods/V5/Orders.php b/lib/RetailCrm/Methods/V5/Orders.php index 3116310..5c2e7b2 100644 --- a/lib/RetailCrm/Methods/V5/Orders.php +++ b/lib/RetailCrm/Methods/V5/Orders.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Orders * * @category RetailCrm * @package RetailCrm @@ -14,13 +14,12 @@ namespace RetailCrm\Methods\V5; -use RetailCrm\Response\ApiResponse; use RetailCrm\Methods\V4\Orders as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Orders class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Packs.php b/lib/RetailCrm/Methods/V5/Packs.php index 6db3a02..c514ed5 100644 --- a/lib/RetailCrm/Methods/V5/Packs.php +++ b/lib/RetailCrm/Methods/V5/Packs.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Packs * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4\Packs as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Packs class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/References.php b/lib/RetailCrm/Methods/V5/References.php index df6caf4..a51e72e 100644 --- a/lib/RetailCrm/Methods/V5/References.php +++ b/lib/RetailCrm/Methods/V5/References.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * References * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4\References as Previous; /** * PHP version 5.4 * - * TaskTrait class + * References class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Statistic.php b/lib/RetailCrm/Methods/V5/Statistic.php index c0e11c6..76c02b4 100644 --- a/lib/RetailCrm/Methods/V5/Statistic.php +++ b/lib/RetailCrm/Methods/V5/Statistic.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Statistic * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V3\Statistic as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Statistic class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Stores.php b/lib/RetailCrm/Methods/V5/Stores.php index 8100fca..93a7c7f 100644 --- a/lib/RetailCrm/Methods/V5/Stores.php +++ b/lib/RetailCrm/Methods/V5/Stores.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Stores * * @category RetailCrm * @package RetailCrm @@ -19,7 +19,7 @@ use RetailCrm\Methods\V4\Stores as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Stores class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Tasks.php b/lib/RetailCrm/Methods/V5/Tasks.php index 5892e89..4f96811 100644 --- a/lib/RetailCrm/Methods/V5/Tasks.php +++ b/lib/RetailCrm/Methods/V5/Tasks.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Tasks * * @category RetailCrm * @package RetailCrm @@ -17,7 +17,7 @@ namespace RetailCrm\Methods\V5; /** * PHP version 5.4 * - * TaskTrait class + * Tasks class * * @category RetailCrm * @package RetailCrm diff --git a/lib/RetailCrm/Methods/V5/Users.php b/lib/RetailCrm/Methods/V5/Users.php index 82b1331..ab3ee70 100644 --- a/lib/RetailCrm/Methods/V5/Users.php +++ b/lib/RetailCrm/Methods/V5/Users.php @@ -3,7 +3,7 @@ /** * PHP version 5.4 * - * TaskTrait + * Users * * @category RetailCrm * @package RetailCrm @@ -20,7 +20,7 @@ use RetailCrm\Methods\V4\Users as Previous; /** * PHP version 5.4 * - * TaskTrait class + * Users class * * @category RetailCrm * @package RetailCrm 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]));