From 73dc060297a26701eccba84a7a0e0d7aaa0244dc Mon Sep 17 00:00:00 2001 From: Alexey Chelnakov Date: Wed, 10 Apr 2019 19:21:17 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=89=D0=B0=D0=B5=D0=BC=20response=20=D1=81=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 1 + src/AtolOnlineClient/AtolOnlineApi.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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); }