Skip to content

Commit

Permalink
Enable http_errors option only if needed.
Browse files Browse the repository at this point in the history
The BaseHttpClient needs to handle 429 Too Many Requests.
  • Loading branch information
PATROMO committed Jul 24, 2020
1 parent 4062dbc commit 6f378c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Client.php
Expand Up @@ -63,7 +63,6 @@ private function send(RequestInterface $request)
{
return $this->httpClient->send($request, [
'base_uri' => $this->endpoint->getHost(),
'http_errors' => true,
]);
}
}
5 changes: 5 additions & 0 deletions src/HttpClient/BaseHttpClient.php
Expand Up @@ -2,6 +2,7 @@

use easybill\SDK\HttpClientInterface;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;

class BaseHttpClient implements HttpClientInterface
Expand Down Expand Up @@ -35,6 +36,10 @@ public function __construct(HttpClientInterface $httpClient, $maxApiCallsPerMinu
public function send(RequestInterface $request, array $options = [])
{
$this->checkAndWaitForCall();

// TODO:: Improve this client and allow to deal with both options.
$options[RequestOptions::HTTP_ERRORS] = true;

try {
$res = $this->httpClient->send($request, $options);
$this->apiCalls[] = time();
Expand Down

0 comments on commit 6f378c8

Please sign in to comment.