diff --git a/composer.json b/composer.json index 1e64e56..f232e70 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "require": { "php": ">=7.1", "ext-curl": "*", + "ext-json": "*", "guzzle/guzzle": "~3.7", "jms/serializer": "~0.12 || ~1.4.2", "symfony/validator": "~2.8|~3.4|~4.0", diff --git a/src/AtolOnlineClient/AtolOnlineApi.php b/src/AtolOnlineClient/AtolOnlineApi.php index 2ddb0f9..c7b176a 100644 --- a/src/AtolOnlineClient/AtolOnlineApi.php +++ b/src/AtolOnlineClient/AtolOnlineApi.php @@ -114,7 +114,6 @@ class AtolOnlineApi $url = $this->buildUrl('report/'.$uuid, $token); $request = $this->client->get($url); - $response = false; try { $this->attemptsCheckStatus++; $response = $request->send(); @@ -124,10 +123,12 @@ class AtolOnlineApi if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) { return $this->checkStatus($uuid); } - $this->logDebug($url, $uuid, $e->getResponse()); + $response = $e->getResponse(); } if ($response) { + $this->logDebug($url, $uuid, $response); + return $response->getBody()->__toString(); } @@ -263,7 +264,6 @@ class AtolOnlineApi $url = $this->buildUrl($operation, $token); $request = $this->client->createRequest('POST', $url, null, $data); - $response = false; try { $this->attempts++; $response = $this->client->send($request); @@ -273,8 +273,9 @@ class AtolOnlineApi if ($this->isTokenExpired($body) && $this->attempts <= 1) { return $this->sendOperationRequest($operation, $data); } - $this->logDebug($url, $data, $e->getResponse()); + $response = $e->getResponse(); } + if ($response) { $this->logDebug($url, $data, $response); }