From 3189f0e88517de82d1c667aee58c4279ade99b09 Mon Sep 17 00:00:00 2001 From: Sander Lissenburg Date: Mon, 3 Jun 2024 09:55:10 +0200 Subject: [PATCH] Replace PSR7 rewind with body rewind --- src/Picqer/Financials/Moneybird/Connection.php | 6 +++--- tests/ConnectionTest.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Picqer/Financials/Moneybird/Connection.php b/src/Picqer/Financials/Moneybird/Connection.php index 833964a..016136d 100644 --- a/src/Picqer/Financials/Moneybird/Connection.php +++ b/src/Picqer/Financials/Moneybird/Connection.php @@ -420,7 +420,7 @@ public function needsAuthentication() private function parseResponse(Response $response) { try { - Psr7\Message::rewindBody($response); + $response->getBody()->rewind(); $json = json_decode($response->getBody()->getContents(), true); return $json; @@ -483,7 +483,7 @@ private function acquireAccessToken() $response = $this->client()->post($this->getTokenUrl(), $body); if ($response->getStatusCode() == 200) { - Psr7\Message::rewindBody($response); + $response->getBody()->rewind(); $body = json_decode($response->getBody()->getContents(), true); if (json_last_error() === JSON_ERROR_NONE) { @@ -517,7 +517,7 @@ private function parseExceptionForErrorMessages(Exception $exception) return new ApiException('Response is NULL.', 0, $exception); } - Psr7\Message::rewindBody($response); + $response->getBody()->rewind(); $responseBody = $response->getBody()->getContents(); $decodedResponseBody = json_decode($responseBody, true); diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index bf0d9b9..b85af0b 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -5,7 +5,6 @@ use GuzzleHttp\Exception\BadResponseException; use GuzzleHttp\Middleware; use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; use Picqer\Financials\Moneybird\Connection; use Picqer\Financials\Moneybird\Entities\Contact; @@ -110,7 +109,7 @@ public function testClientTriesToGetAccessTokenWhenNoneGiven() $request = $this->getRequestFromHistoryContainer(); $this->assertEquals('POST', $request->getMethod()); - Psr7\Message::rewindBody($request); + $request->getBody()->rewind(); $this->assertEquals( 'redirect_uri=testRedirectUrl&grant_type=authorization_code&client_id=testClientId&client_secret=testClientSecret&code=testAuthorizationCode', $request->getBody()->getContents()