File tree 2 files changed +75
-5
lines changed
src/Symfony/Component/Notifier/Bridge/Brevo 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
54
54
}
55
55
56
56
$ 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
+ }
57
72
58
73
$ 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 ,
64
75
'headers ' => [
65
76
'api-key ' => $ this ->apiKey ,
66
77
],
You can’t perform that action at this time.
0 commit comments