From 2ba4aab65a16cdfa750abb34b05893c1135ec64e Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 14 Oct 2024 19:18:07 +0600 Subject: [PATCH] fix code style --- CHANGELOG.md | 2 +- .../retailcrm/lib/api/RetailcrmHttpClient.php | 26 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 977d293..1dbaa6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## v4.1.17 -* Add parameters with versions of PHP, module, opencart +* Added additional parameters to GET requests. ## v4.1.16 * Support for services in ICML diff --git a/src/upload/system/library/retailcrm/lib/api/RetailcrmHttpClient.php b/src/upload/system/library/retailcrm/lib/api/RetailcrmHttpClient.php index 33db435..dd4a1ee 100644 --- a/src/upload/system/library/retailcrm/lib/api/RetailcrmHttpClient.php +++ b/src/upload/system/library/retailcrm/lib/api/RetailcrmHttpClient.php @@ -7,7 +7,6 @@ class RetailcrmHttpClient protected $url; protected $defaultParameters; - protected $versionData; /** * Client constructor. @@ -27,12 +26,6 @@ class RetailcrmHttpClient $this->url = $url; $this->defaultParameters = $defaultParameters; - $this->versionData = [ - 'php_version' => function_exists('phpversion') ? phpversion() : '', - 'cms_source' => 'Opencart', - 'module_version' => ControllerExtensionModuleRetailcrm::VERSION_MODULE, - 'cms_version' => VERSION - ]; } /** @@ -53,9 +46,9 @@ class RetailcrmHttpClient 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( @@ -67,11 +60,16 @@ class RetailcrmHttpClient ); } - if (self::METHOD_GET === $method) { - $parameters = array_merge($this->defaultParameters, $parameters, $this->versionData); - } else { - $parameters = array_merge($this->defaultParameters, $parameters); - } + + $parameters = self::METHOD_GET === $method + ? array_merge($this->defaultParameters, $parameters, [ + 'php_version' => function_exists('phpversion') ? phpversion() : '', + 'cms_source' => 'Opencart', + 'module_version' => ControllerExtensionModuleRetailcrm::VERSION_MODULE, + 'cms_version' => VERSION, + ]) + : $parameters = array_merge($this->defaultParameters, $parameters); + $url = $this->url . $path;