1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\Twilio; |
4
|
|
|
|
5
|
|
|
class TwilioSmsMessage extends TwilioMessage |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var null|string |
9
|
|
|
*/ |
10
|
|
|
public $alphaNumSender; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var null|string |
14
|
|
|
*/ |
15
|
|
|
public $messagingServiceSid; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var null|string |
19
|
|
|
*/ |
20
|
|
|
public $applicationSid; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var null|bool |
24
|
|
|
*/ |
25
|
|
|
public $forceDelivery; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var null|float |
29
|
|
|
*/ |
30
|
|
|
public $maxPrice; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var null|bool |
34
|
|
|
*/ |
35
|
|
|
public $provideFeedback; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var null|int |
39
|
|
|
*/ |
40
|
|
|
public $validityPeriod; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get the from address of this message. |
44
|
|
|
* |
45
|
|
|
* @return null|string |
46
|
|
|
*/ |
47
|
13 |
|
public function getFrom(): ?string |
48
|
|
|
{ |
49
|
13 |
|
if ($this->from) { |
50
|
4 |
|
return $this->from; |
51
|
|
|
} |
52
|
|
|
|
53
|
9 |
|
if ($this->alphaNumSender !== null && $this->alphaNumSender !== '') { |
54
|
2 |
|
return $this->alphaNumSender; |
55
|
|
|
} |
56
|
|
|
|
57
|
7 |
|
return null; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Set the messaging service SID. |
62
|
|
|
* |
63
|
|
|
* @param string $messagingServiceSid |
64
|
|
|
* @return $this |
65
|
|
|
*/ |
66
|
|
|
public function messagingServiceSid(string $messagingServiceSid): self |
67
|
|
|
{ |
68
|
|
|
$this->messagingServiceSid = $messagingServiceSid; |
69
|
|
|
|
70
|
|
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get the messaging service SID of this message. |
75
|
|
|
* |
76
|
|
|
* @return null|string |
77
|
|
|
*/ |
78
|
9 |
|
public function getMessagingServiceSid(): ?string |
79
|
|
|
{ |
80
|
9 |
|
return $this->messagingServiceSid; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Set the alphanumeric sender. |
85
|
|
|
* |
86
|
|
|
* @param string $sender |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
4 |
|
public function sender(string $sender): self |
90
|
|
|
{ |
91
|
4 |
|
$this->alphaNumSender = $sender; |
92
|
|
|
|
93
|
4 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set application SID for the message status callback. |
98
|
|
|
* |
99
|
|
|
* @param string $applicationSid |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
5 |
|
public function applicationSid(string $applicationSid): self |
103
|
|
|
{ |
104
|
5 |
|
$this->applicationSid = $applicationSid; |
105
|
|
|
|
106
|
5 |
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Set force delivery (Deliver message without validation). |
111
|
|
|
* |
112
|
|
|
* @param bool $forceDelivery |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
1 |
|
public function forceDelivery(bool $forceDelivery): self |
116
|
|
|
{ |
117
|
1 |
|
$this->forceDelivery = $forceDelivery; |
118
|
|
|
|
119
|
1 |
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Set the max price (in USD dollars). |
124
|
|
|
* |
125
|
|
|
* @param float $maxPrice |
126
|
|
|
* @return $this |
127
|
|
|
*/ |
128
|
5 |
|
public function maxPrice(float $maxPrice): self |
129
|
|
|
{ |
130
|
5 |
|
$this->maxPrice = $maxPrice; |
131
|
|
|
|
132
|
5 |
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Set the provide feedback option. |
137
|
|
|
* |
138
|
|
|
* @param bool $provideFeedback |
139
|
|
|
* @return $this |
140
|
|
|
*/ |
141
|
5 |
|
public function provideFeedback(bool $provideFeedback): self |
142
|
|
|
{ |
143
|
5 |
|
$this->provideFeedback = $provideFeedback; |
144
|
|
|
|
145
|
5 |
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set the validity period (in seconds). |
150
|
|
|
* |
151
|
|
|
* @param int $validityPeriodSeconds |
152
|
|
|
* |
153
|
|
|
* @return $this |
154
|
|
|
*/ |
155
|
5 |
|
public function validityPeriod(int $validityPeriodSeconds): self |
156
|
|
|
{ |
157
|
5 |
|
$this->validityPeriod = $validityPeriodSeconds; |
158
|
|
|
|
159
|
5 |
|
return $this; |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|