Skip to content

Commit 6682305

Browse files
authored
Merge pull request #300 from picqer/rewind-fix-on-main
Replace deprecated PSR7 rewind with body rewind
2 parents e445676 + 3189f0e commit 6682305

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/Picqer/Financials/Moneybird/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function needsAuthentication()
420420
private function parseResponse(Response $response)
421421
{
422422
try {
423-
Psr7\Message::rewindBody($response);
423+
$response->getBody()->rewind();
424424
$json = json_decode($response->getBody()->getContents(), true);
425425

426426
return $json;
@@ -483,7 +483,7 @@ private function acquireAccessToken()
483483
$response = $this->client()->post($this->getTokenUrl(), $body);
484484

485485
if ($response->getStatusCode() == 200) {
486-
Psr7\Message::rewindBody($response);
486+
$response->getBody()->rewind();
487487
$body = json_decode($response->getBody()->getContents(), true);
488488

489489
if (json_last_error() === JSON_ERROR_NONE) {
@@ -517,7 +517,7 @@ private function parseExceptionForErrorMessages(Exception $exception)
517517
return new ApiException('Response is NULL.', 0, $exception);
518518
}
519519

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

tests/ConnectionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use GuzzleHttp\Exception\BadResponseException;
66
use GuzzleHttp\Middleware;
77
use GuzzleHttp\Promise\PromiseInterface;
8-
use GuzzleHttp\Psr7;
98
use PHPUnit\Framework\TestCase;
109
use Picqer\Financials\Moneybird\Connection;
1110
use Picqer\Financials\Moneybird\Entities\Contact;
@@ -110,7 +109,7 @@ public function testClientTriesToGetAccessTokenWhenNoneGiven()
110109
$request = $this->getRequestFromHistoryContainer();
111110
$this->assertEquals('POST', $request->getMethod());
112111

113-
Psr7\Message::rewindBody($request);
112+
$request->getBody()->rewind();
114113
$this->assertEquals(
115114
'redirect_uri=testRedirectUrl&grant_type=authorization_code&client_id=testClientId&client_secret=testClientSecret&code=testAuthorizationCode',
116115
$request->getBody()->getContents()

0 commit comments

Comments
 (0)