From b8f4cfa1497cf10b26eed3ae38b5c440f44e4e03 Mon Sep 17 00:00:00 2001 From: AlexBergal <53344575+AlexBergal@users.noreply.github.com> Date: Fri, 9 Jul 2021 17:44:23 +0700 Subject: [PATCH] Lost Boolean params while Request signing (#10) --- src/Factory/TopRequestFactory.php | 3 +++ src/TopClient/TopClient.php | 2 +- tests/RetailCrm/Tests/TopClient/ClientTest.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Factory/TopRequestFactory.php b/src/Factory/TopRequestFactory.php index 38b3da5..e9d4092 100644 --- a/src/Factory/TopRequestFactory.php +++ b/src/Factory/TopRequestFactory.php @@ -264,6 +264,8 @@ class TopRequestFactory implements TopRequestFactoryInterface * * @return string|resource|null * @todo Arrays will be encoded to JSON. Is this correct? Press X to doubt. + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function castValue($value) { @@ -274,6 +276,7 @@ class TopRequestFactory implements TopRequestFactoryInterface case 'NULL': return $value; case 'boolean': + return $value ? 'true' : 'false'; case 'integer': case 'double': case 'string': diff --git a/src/TopClient/TopClient.php b/src/TopClient/TopClient.php index 9c7406b..7e1aa6f 100644 --- a/src/TopClient/TopClient.php +++ b/src/TopClient/TopClient.php @@ -255,7 +255,7 @@ class TopClient implements TopClientInterface try { $httpResponse = $this->httpClient->sendRequest($httpRequest); } catch (ClientExceptionInterface $exception) { - throw new TopClientException(sprintf('Error sending request: %s', $exception->getMessage()), $exception); + throw new TopClientException(sprintf('Error sending request: %s', $exception->getMessage()), 0, $exception); } $bodyData = self::getBodyContents($httpResponse->getBody()); diff --git a/tests/RetailCrm/Tests/TopClient/ClientTest.php b/tests/RetailCrm/Tests/TopClient/ClientTest.php index 3df20f7..daa1899 100644 --- a/tests/RetailCrm/Tests/TopClient/ClientTest.php +++ b/tests/RetailCrm/Tests/TopClient/ClientTest.php @@ -141,7 +141,7 @@ EOF; 'app_key' => self::getEnvAppKey(), 'method' => 'aliexpress.solution.seller.category.tree.query', 'category_id' => '5090300', - 'filter_no_permission' => 1, + 'filter_no_permission' => 'true', 'session' => self::getEnvToken() ]), $this->responseJson(200, $json)