File tree Expand file tree Collapse file tree 2 files changed +75
-5
lines changed
src/Symfony/Component/Notifier/Bridge/Brevo Expand file tree Collapse file tree 2 files changed +75
-5
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Notifier \Bridge \Brevo ;
13+
14+ use Symfony \Component \Notifier \Message \MessageOptionsInterface ;
15+
16+ final class BrevoOptions implements MessageOptionsInterface
17+ {
18+ public function __construct (
19+ private array $ options = [],
20+ ) {
21+ }
22+
23+ public function toArray (): array
24+ {
25+ return $ this ->options ;
26+ }
27+
28+ public function getRecipientId (): ?string
29+ {
30+ return null ;
31+ }
32+
33+ /**
34+ * @return $this
35+ */
36+ public function webUrl (string $ url ): static
37+ {
38+ $ this ->options ['webUrl ' ] = $ url ;
39+
40+ return $ this ;
41+ }
42+
43+ /**
44+ * @return $this
45+ */
46+ public function type (string $ type ="transactional " ): static
47+ {
48+ $ this ->options ['type ' ] = $ type ;
49+
50+ return $ this ;
51+ }
52+
53+ public function tag (string $ tag ): static
54+ {
55+ $ this ->options ['tag ' ] = $ tag ;
56+
57+ return $ this ;
58+ }
59+ }
Original file line number Diff line number Diff line change @@ -54,13 +54,24 @@ protected function doSend(MessageInterface $message): SentMessage
5454 }
5555
5656 $ sender = $ message ->getFrom () ?: $ this ->sender ;
57+ $ options = $ message ->getOptions ()?->toArray() ?? [];
58+ $ body = [
59+ 'sender ' => $ sender ,
60+ 'recipient ' => $ message ->getPhone (),
61+ 'content ' => $ message ->getSubject (),
62+ ];
63+ if (isset ($ options ['webUrl ' ])) {
64+ $ body ['webUrl ' ] = $ options ['webUrl ' ];
65+ }
66+ if (isset ($ options ['type ' ])) {
67+ $ body ['type ' ] = $ options ['type ' ];
68+ }
69+ if (isset ($ options ['tag ' ])) {
70+ $ body ['tag ' ] = $ options ['tag ' ];
71+ }
5772
5873 $ response = $ this ->client ->request ('POST ' , 'https:// ' .$ this ->getEndpoint ().'/v3/transactionalSMS/sms ' , [
59- 'json ' => [
60- 'sender ' => $ sender ,
61- 'recipient ' => $ message ->getPhone (),
62- 'content ' => $ message ->getSubject (),
63- ],
74+ 'json ' => $ body ,
6475 'headers ' => [
6576 'api-key ' => $ this ->apiKey ,
6677 ],
You can’t perform that action at this time.
0 commit comments