File tree 2 files changed +66
-5
lines changed
src/Symfony/Component/Notifier/Bridge/Brevo
2 files changed +66
-5
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Component \Notifier \Bridge \Brevo ;
4
+
5
+ use Symfony \Component \Notifier \Message \MessageOptionsInterface ;
6
+
7
+ final class BrevoOptions implements MessageOptionsInterface
8
+ {
9
+ public function __construct (
10
+ private array $ options = [],
11
+ ) {
12
+ }
13
+
14
+ public function toArray (): array
15
+ {
16
+ return $ this ->options ;
17
+ }
18
+
19
+ public function getRecipientId (): ?string
20
+ {
21
+ return null ;
22
+ }
23
+
24
+ /**
25
+ * @return $this
26
+ */
27
+ public function webUrl (string $ url ): static
28
+ {
29
+ $ this ->options ['webUrl ' ] = $ url ;
30
+
31
+ return $ this ;
32
+ }
33
+
34
+ /**
35
+ * @return $this
36
+ */
37
+ public function type (string $ type ="transactional " ): static
38
+ {
39
+ $ this ->options ['type ' ] = $ type ;
40
+
41
+ return $ this ;
42
+ }
43
+
44
+ public function tag (string $ tag ): static
45
+ {
46
+ $ this ->options ['tag ' ] = $ tag ;
47
+
48
+ return $ this ;
49
+ }
50
+ }
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