From d42ff9df87867299dadf382ac4085b9de5236147 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 23 May 2023 10:38:09 +0100 Subject: [PATCH] Guzzle related fixes --- composer.json | 4 +++- src/Api/ApiClient.php | 6 +++--- src/Api/BaseApiClient.php | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index bd32b218..ba2c90a9 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,9 @@ "require": { "php": ">=5.6.0", "cloudinary/transformation-builder-sdk": "^1", - "guzzlehttp/guzzle": "^6|^7", + "guzzlehttp/guzzle": "^6.5.8|^7.4.5", + "guzzlehttp/promises": "^1.5.3|^2.0", + "guzzlehttp/psr7": "^1.9.1|^2.5", "teapot/status-code": "^1|^2", "ext-json": "*", "monolog/monolog": "^1|^2|^3", diff --git a/src/Api/ApiClient.php b/src/Api/ApiClient.php index c9b256eb..fc2b24b7 100644 --- a/src/Api/ApiClient.php +++ b/src/Api/ApiClient.php @@ -20,7 +20,7 @@ use Cloudinary\Utils; use Exception; use GuzzleHttp\Client; -use GuzzleHttp\Promise; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\LimitStream; use InvalidArgumentException; @@ -355,13 +355,13 @@ private function postLargeFileAsync($endPoint, $fileHandle, $parameters, $option ] ); - return Promise\rejection_for($e); + return Create::rejectionFor($e); } ArrayUtils::addNonEmptyFromOther($parameters, 'public_id', $uploadResult); } - return Promise\promise_for($uploadResult); + return Create::promiseFor($uploadResult); } /** diff --git a/src/Api/BaseApiClient.php b/src/Api/BaseApiClient.php index 501b9aa5..6cb70e96 100644 --- a/src/Api/BaseApiClient.php +++ b/src/Api/BaseApiClient.php @@ -28,7 +28,7 @@ use Exception; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; -use GuzzleHttp\Promise; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use InvalidArgumentException; use JsonSerializable; @@ -330,7 +330,7 @@ function (ResponseInterface $response) { ['statusCode' => $response->getStatusCode()] ); try { - return Promise\promise_for($this->handleApiResponse($response)); + return Create::promiseFor($this->handleApiResponse($response)); } catch (Exception $e) { $this->getLogger()->critical( 'Async request failed', @@ -340,7 +340,7 @@ function (ResponseInterface $response) { ] ); - return Promise\rejection_for($e); + return Create::rejectionFor($e); } }, function (Exception $error) { @@ -352,10 +352,10 @@ function (Exception $error) { ] ); if ($error instanceof ClientException) { - return Promise\rejection_for($this->handleApiResponse($error->getResponse())); + return Create::rejectionFor($this->handleApiResponse($error->getResponse())); } - return Promise\rejection_for($error); + return Create::rejectionFor($error); } ); }