Skip to content

Commit

Permalink
Do not use empty attribute array for SendInBlue
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed May 7, 2019
1 parent 5bc14f1 commit d983e43
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/SubscribeMe/Subscriber/SendInBlueSubscriber.php
Expand Up @@ -19,11 +19,17 @@ public function subscribe(string $email, array $options, array $userConsents = [
{
$body = [
'email' => $email,
'attributes' => $options,
'listIds' => [$this->getContactListId()]
];

if (count($options) > 0) {
$body['attributes'] = $options;
}

if (count($userConsents) > 0 && null !== $consent = $userConsents[0]) {
if (!isset($body['attributes'])) {
$body['attributes'] = [];
}
if (!($consent instanceof UserConsent)) {
throw new \InvalidArgumentException('User consent is not valid UserConsent object');
}
Expand Down Expand Up @@ -80,7 +86,7 @@ public function subscribe(string $email, array $options, array $userConsents = [
}
}
throw new CannotSubscribeException($exception->getMessage(), $exception);
}catch (RequestException $exception) {
} catch (RequestException $exception) {
throw new CannotSubscribeException($exception->getMessage(), $exception);
}

Expand Down

0 comments on commit d983e43

Please sign in to comment.