Skip to content

Commit

Permalink
Merge pull request #300 from picqer/rewind-fix-on-main
Browse files Browse the repository at this point in the history
Replace deprecated PSR7 rewind with body rewind
  • Loading branch information
stephangroen authored Jun 18, 2024
2 parents e445676 + 3189f0e commit 6682305
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 6682305

Please sign in to comment.