Skip to content

Commit

Permalink
Revert "Replace deprecated PSR7 rewind with body rewind"
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderlissenburg authored Jun 3, 2024
1 parent 6e99525 commit 64b0dd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 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 {
$response->getBody()->rewind();
Psr7\Message::rewindBody($response);
$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) {
$response->getBody()->rewind();
Psr7\Message::rewindBody($response);
$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);
}

$response->getBody()->rewind();
Psr7\Message::rewindBody($response);
$responseBody = $response->getBody()->getContents();
$decodedResponseBody = json_decode($responseBody, true);

Expand Down
3 changes: 2 additions & 1 deletion tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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 @@ -109,7 +110,7 @@ public function testClientTriesToGetAccessTokenWhenNoneGiven()
$request = $this->getRequestFromHistoryContainer();
$this->assertEquals('POST', $request->getMethod());

$request->getBody()->rewind();
Psr7\Message::rewindBody($request);
$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 64b0dd9

Please sign in to comment.