From 6fb061e6cc51301b58bda929a2de254f950f0d09 Mon Sep 17 00:00:00 2001 From: ellynoize <111681973+ellynoize@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:59:41 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B2=20=D0=B2=20GET=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=B0=D1=85=20(#366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ .../classes/general/Http/Client.php | 25 +++++++++++++------ intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +-- intaro.retailcrm/lib/component/constants.php | 1 + 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 440f9e0b..f2335577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-10-14 v6.5.33 +- Добавлена передача дополнительных параметров в GET запросах + ## 2024-10-03 v6.5.32 - Исправлена подписка на событие создания заказа при обновлении diff --git a/intaro.retailcrm/classes/general/Http/Client.php b/intaro.retailcrm/classes/general/Http/Client.php index cf1ccba5..66f5b5bc 100644 --- a/intaro.retailcrm/classes/general/Http/Client.php +++ b/intaro.retailcrm/classes/general/Http/Client.php @@ -11,6 +11,7 @@ namespace RetailCrm\Http; +use Intaro\RetailCrm\Component\Constants; use RetailCrm\Exception\CurlException; use RetailCrm\Exception\InvalidJsonException; use RetailCrm\Response\ApiResponse; @@ -38,7 +39,7 @@ class Client * * @throws \InvalidArgumentException */ - public function __construct($url, array $defaultParameters = array()) + public function __construct($url, array $defaultParameters = []) { if (false === stripos($url, 'https://')) { throw new \InvalidArgumentException( @@ -49,7 +50,7 @@ class Client $this->url = $url; $this->defaultParameters = $defaultParameters; $this->retry = 0; - $this->curlErrors = array( + $this->curlErrors = [ CURLE_COULDNT_RESOLVE_PROXY, CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, @@ -57,8 +58,8 @@ class Client CURLE_HTTP_POST_ERROR, CURLE_SSL_CONNECT_ERROR, CURLE_SEND_ERROR, - CURLE_RECV_ERROR - ); + CURLE_RECV_ERROR, + ]; } /** @@ -79,9 +80,9 @@ class Client public function makeRequest( $path, $method, - array $parameters = array() + array $parameters = [] ) { - $allowedMethods = array(self::METHOD_GET, self::METHOD_POST); + $allowedMethods = [self::METHOD_GET, self::METHOD_POST]; if (!in_array($method, $allowedMethods, false)) { throw new \InvalidArgumentException( @@ -93,7 +94,14 @@ class Client ); } - $parameters = array_merge($this->defaultParameters, $parameters); + $parameters = self::METHOD_GET === $method + ? array_merge($this->defaultParameters, $parameters, [ + 'cms_source' => 'Bitrix', + 'cms_version' => SM_VERSION, + 'php_version' => function_exists('phpversion') ? phpversion() : '', + 'module_version' => Constants::MODULE_VERSION, + ]) + : $parameters = array_merge($this->defaultParameters, $parameters); $url = $this->url . $path; @@ -122,7 +130,8 @@ class Client curl_close($curlHandler); - if ($errno + if ( + $errno && in_array($errno, $this->curlErrors, false) && $this->retry < 3 ) { diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 293bec97..c5b7ed75 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена подписка на событие сохранения заказа при обновлении +- Добавлена передача дополнительных параметров в GET запросах diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index f96b8ae8..bb690a8c 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.32', - 'VERSION_DATE' => '2024-10-03 17:00:00' + 'VERSION' => '6.5.33', + 'VERSION_DATE' => '2024-10-14 17:00:00' ]; diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 4e703674..34ec5925 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -18,6 +18,7 @@ namespace Intaro\RetailCrm\Component; */ class Constants { + public const MODULE_VERSION = '6.5.33'; public const CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; public const CRM_USERS_MAP = 'crm_users_map';