1
0
mirror of synced 2024-11-23 22:06:11 +03:00

Добавлена передача дополнительных параметров в GET запросах (#366)

This commit is contained in:
ellynoize 2024-10-14 19:59:41 +06:00 committed by GitHub
parent a77b29cd49
commit 6fb061e6cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,6 @@
## 2024-10-14 v6.5.33
- Добавлена передача дополнительных параметров в GET запросах
## 2024-10-03 v6.5.32
- Исправлена подписка на событие создания заказа при обновлении

View File

@ -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
) {

View File

@ -1 +1 @@
- Исправлена подписка на событие сохранения заказа при обновлении
- Добавлена передача дополнительных параметров в GET запросах

View File

@ -1,6 +1,6 @@
<?php
$arModuleVersion = [
'VERSION' => '6.5.32',
'VERSION_DATE' => '2024-10-03 17:00:00'
'VERSION' => '6.5.33',
'VERSION_DATE' => '2024-10-14 17:00:00'
];

View File

@ -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';