1
0
mirror of synced 2024-11-21 20:46:03 +03:00

fix возвращаем response с ошибкой

This commit is contained in:
Alexey Chelnakov 2019-04-10 19:21:17 +03:00
parent aa735cff8d
commit 73dc060297
2 changed files with 6 additions and 4 deletions

View File

@ -12,6 +12,7 @@
"require": { "require": {
"php": ">=7.1", "php": ">=7.1",
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*",
"guzzle/guzzle": "~3.7", "guzzle/guzzle": "~3.7",
"jms/serializer": "~0.12 || ~1.4.2", "jms/serializer": "~0.12 || ~1.4.2",
"symfony/validator": "~2.8|~3.4|~4.0", "symfony/validator": "~2.8|~3.4|~4.0",

View File

@ -114,7 +114,6 @@ class AtolOnlineApi
$url = $this->buildUrl('report/'.$uuid, $token); $url = $this->buildUrl('report/'.$uuid, $token);
$request = $this->client->get($url); $request = $this->client->get($url);
$response = false;
try { try {
$this->attemptsCheckStatus++; $this->attemptsCheckStatus++;
$response = $request->send(); $response = $request->send();
@ -124,10 +123,12 @@ class AtolOnlineApi
if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) { if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) {
return $this->checkStatus($uuid); return $this->checkStatus($uuid);
} }
$this->logDebug($url, $uuid, $e->getResponse()); $response = $e->getResponse();
} }
if ($response) { if ($response) {
$this->logDebug($url, $uuid, $response);
return $response->getBody()->__toString(); return $response->getBody()->__toString();
} }
@ -263,7 +264,6 @@ class AtolOnlineApi
$url = $this->buildUrl($operation, $token); $url = $this->buildUrl($operation, $token);
$request = $this->client->createRequest('POST', $url, null, $data); $request = $this->client->createRequest('POST', $url, null, $data);
$response = false;
try { try {
$this->attempts++; $this->attempts++;
$response = $this->client->send($request); $response = $this->client->send($request);
@ -273,8 +273,9 @@ class AtolOnlineApi
if ($this->isTokenExpired($body) && $this->attempts <= 1) { if ($this->isTokenExpired($body) && $this->attempts <= 1) {
return $this->sendOperationRequest($operation, $data); return $this->sendOperationRequest($operation, $data);
} }
$this->logDebug($url, $data, $e->getResponse()); $response = $e->getResponse();
} }
if ($response) { if ($response) {
$this->logDebug($url, $data, $response); $this->logDebug($url, $data, $response);
} }