Skip to content

Commit

Permalink
[Mailchimp] use Httpv2
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Nov 4, 2024
1 parent 092cabd commit 42da3c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion config/packages/http_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ framework:
headers:
'User-Agent': 'Renaissance'
timeout: 60
http_version: '1.1'
ohme.client:
base_uri: 'https://api-ohme.oneheart.fr/api/v1/'
timeout: 60
Expand Down
10 changes: 7 additions & 3 deletions src/Mailchimp/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,14 @@ public function getLastError(): ?string

public function isSuccessfulResponse(?ResponseInterface $response, bool $log = false): bool
{
$isSuccessful = $response && 200 <= $response->getStatusCode() && $response->getStatusCode() < 300;
try {
$isSuccessful = $response && 200 <= $response->getStatusCode() && $response->getStatusCode() < 300;
} catch (TransportExceptionInterface $e) {
$isSuccessful = false;
}

if (!$isSuccessful && $log && $response) {
$this->logger->error(\sprintf('[API] Error: %s', $response->getContent(false)));
if (!$isSuccessful && $log) {
$this->logger->error(\sprintf('[API] Error: %s', $response ? $response->getContent(false) : 'unknown'));
}

return $isSuccessful;
Expand Down

0 comments on commit 42da3c4

Please sign in to comment.