Skip to content

Commit

Permalink
Replace PSR7 rewind with body rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderlissenburg committed Jun 3, 2024
1 parent e7d0104 commit 90e5c47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Picqer/Financials/Moneybird/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 90e5c47

Please sign in to comment.