Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Notifier] [Brevo][SMS] Brevo sms notifier add options #58786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions 59 src/Symfony/Component/Notifier/Bridge/Brevo/BrevoOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Notifier\Bridge\Brevo;

use Symfony\Component\Notifier\Message\MessageOptionsInterface;

final class BrevoOptions implements MessageOptionsInterface
{
public function __construct(
private array $options = [],
) {
}

public function toArray(): array
{
return $this->options;
}

public function getRecipientId(): ?string
{
return null;
}

/**
* @return $this
*/
public function webUrl(string $url): static
{
$this->options['webUrl'] = $url;

return $this;
}

/**
* @return $this
*/
public function type(string $type="transactional"): static
{
$this->options['type'] = $type;

return $this;
}

public function tag(string $tag): static
{
$this->options['tag'] = $tag;

return $this;
}
}
21 changes: 16 additions & 5 deletions 21 src/Symfony/Component/Notifier/Bridge/Brevo/BrevoTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,24 @@ protected function doSend(MessageInterface $message): SentMessage
}

$sender = $message->getFrom() ?: $this->sender;
$options = $message->getOptions()?->toArray() ?? [];
$body = [
'sender' => $sender,
'recipient' => $message->getPhone(),
'content' => $message->getSubject(),
];
if (isset($options['webUrl'])) {
$body['webUrl'] = $options['webUrl'];
}
if (isset($options['type'])) {
$body['type'] = $options['type'];
}
if (isset($options['tag'])) {
$body['tag'] = $options['tag'];
}

$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/transactionalSMS/sms', [
'json' => [
'sender' => $sender,
'recipient' => $message->getPhone(),
'content' => $message->getSubject(),
],
'json' => $body,
'headers' => [
'api-key' => $this->apiKey,
],
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.