Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Передача доп.параметров с версиями #366

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2024-10-14 v6.5.33
- Добавлена передача дополнительных параметров в GET запросах

## 2024-10-03 v6.5.32
- Исправлена подписка на событие создания заказа при обновлении

Expand Down
25 changes: 17 additions & 8 deletions intaro.retailcrm/classes/general/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace RetailCrm\Http;

use Intaro\RetailCrm\Component\Constants;
use RetailCrm\Exception\CurlException;
use RetailCrm\Exception\InvalidJsonException;
use RetailCrm\Response\ApiResponse;
Expand Down Expand Up @@ -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(
Expand All @@ -49,16 +50,16 @@ public function __construct($url, array $defaultParameters = array())
$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,
CURLE_OPERATION_TIMEOUTED,
CURLE_HTTP_POST_ERROR,
CURLE_SSL_CONNECT_ERROR,
CURLE_SEND_ERROR,
CURLE_RECV_ERROR
);
CURLE_RECV_ERROR,
];
}

/**
Expand All @@ -79,9 +80,9 @@ public function __construct($url, array $defaultParameters = array())
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(
Expand All @@ -93,7 +94,14 @@ public function makeRequest(
);
}

$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;

Expand Down Expand Up @@ -122,7 +130,8 @@ public function makeRequest(

curl_close($curlHandler);

if ($errno
if (
$errno
&& in_array($errno, $this->curlErrors, false)
&& $this->retry < 3
) {
Expand Down
2 changes: 1 addition & 1 deletion intaro.retailcrm/description.ru
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Исправлена подписка на событие сохранения заказа при обновлении
- Добавлена передача дополнительных параметров в GET запросах
4 changes: 2 additions & 2 deletions intaro.retailcrm/install/version.php
Original file line number Diff line number Diff line change
@@ -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'
];
1 change: 1 addition & 0 deletions intaro.retailcrm/lib/component/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
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';
Expand Down
Loading