Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bessudnov committed Sep 4, 2023
1 parent 97fe9d9 commit abccf24
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/AmoCRM/Client/AmoCRMApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use AmoCRM\Exceptions\AmoCRMApiHttpClientException;
use AmoCRM\Exceptions\AmoCRMApiNoContentException;
use AmoCRM\Exceptions\AmoCRMApiTooManyRedirectsException;
use AmoCRM\Exceptions\AmoCRMApiTooManyRequestsException;
use AmoCRM\Exceptions\AmoCRMoAuthApiException;
use AmoCRM\OAuth\AmoCRMOAuth;
use Fig\Http\Message\StatusCodeInterface;
Expand Down Expand Up @@ -35,7 +36,7 @@ class AmoCRMApiRequest
public const CONNECT_TIMEOUT = 5;
public const REQUEST_TIMEOUT = 20;
//TODO Do not forget to change this on each release
public const LIBRARY_VERSION = '1.0.2';
public const LIBRARY_VERSION = '1.0.4';
public const USER_AGENT = 'amoCRM-API-Library/' . self::LIBRARY_VERSION;

public const SUCCESS_STATUSES = [
Expand Down Expand Up @@ -594,9 +595,14 @@ private function parseResponse(ResponseInterface $response): array
&& !$decodedBody
&& !empty($bodyContents)
) {
if($e->getCode() == 429) {
throw new AmoCRMApiTooManyRequestsException("Too many requests", $e->getCode(), $this->getLastRequestInfo());
if ($response->getStatusCode() === StatusCodeInterface::STATUS_TOO_MANY_REQUESTS) {
throw new AmoCRMApiTooManyRequestsException(
"Too many requests",
$response->getStatusCode(),
$this->getLastRequestInfo()
);
}

throw new AmoCRMApiException(
"Response body is not json",
$response->getStatusCode(),
Expand Down

0 comments on commit abccf24

Please sign in to comment.