1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CoreProc\NotificationChannels\Telerivet; |
4
|
|
|
|
5
|
|
|
class TelerivetMessage |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var string |
9
|
|
|
*/ |
10
|
|
|
protected $messageType; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $content; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $toNumber; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $contactId; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $routeId; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $statusUrl; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $statusSecret; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
protected $isTemplate; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var bool |
49
|
|
|
*/ |
50
|
|
|
protected $trackClicks; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $mediaUrls; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var array |
59
|
|
|
*/ |
60
|
|
|
protected $labelIds; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var object |
64
|
|
|
*/ |
65
|
|
|
protected $vars; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var int |
69
|
|
|
*/ |
70
|
|
|
protected $priority; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var bool |
74
|
|
|
*/ |
75
|
|
|
protected $simulated; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var string |
79
|
|
|
*/ |
80
|
|
|
protected $serviceId; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var string |
84
|
|
|
*/ |
85
|
|
|
protected $audioUrl; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var string |
89
|
|
|
*/ |
90
|
|
|
protected $ttsLang; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var string |
94
|
|
|
*/ |
95
|
|
|
protected $ttsVoice; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
public function getMessageType(): ?string |
101
|
|
|
{ |
102
|
|
|
return $this->messageType; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* [Optional] Type of message to send. If text, will use the default text message type for the selected route. |
107
|
|
|
* Possible Values: sms, mms, ussd, call, text |
108
|
|
|
* Default: text |
109
|
|
|
* |
110
|
|
|
* @param string $messageType |
111
|
|
|
* @return TelerivetMessage |
112
|
|
|
*/ |
113
|
|
|
public function setMessageType(?string $messageType): self |
114
|
|
|
{ |
115
|
|
|
$this->messageType = $messageType; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getContent(): ?string |
124
|
|
|
{ |
125
|
|
|
return $this->content; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* [Required if sending SMS message] |
130
|
|
|
* Content of the message to send (if message_type is call, the text will be spoken during a text-to-speech call) |
131
|
|
|
* |
132
|
|
|
* @param string $content |
133
|
|
|
* @return TelerivetMessage |
134
|
|
|
*/ |
135
|
|
|
public function setContent(?string $content): self |
136
|
|
|
{ |
137
|
|
|
$this->content = $content; |
138
|
|
|
|
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return string |
144
|
|
|
*/ |
145
|
|
|
public function getToNumber(): ?string |
146
|
|
|
{ |
147
|
|
|
return $this->toNumber; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* [Required if contact_id not set] |
152
|
|
|
* Phone number to send the message to. |
153
|
|
|
* |
154
|
|
|
* @param string $toNumber |
155
|
|
|
* @return TelerivetMessage |
156
|
|
|
*/ |
157
|
|
|
public function setToNumber(?string $toNumber): self |
158
|
|
|
{ |
159
|
|
|
$this->toNumber = $toNumber; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getContactId(): ?string |
168
|
|
|
{ |
169
|
|
|
return $this->contactId; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* [Required if to_number not set] |
174
|
|
|
* ID of the contact to send the message to |
175
|
|
|
* |
176
|
|
|
* @param string $contactId |
177
|
|
|
* @return TelerivetMessage |
178
|
|
|
*/ |
179
|
|
|
public function setContactId(?string $contactId): self |
180
|
|
|
{ |
181
|
|
|
$this->contactId = $contactId; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return string |
188
|
|
|
*/ |
189
|
|
|
public function getRouteId(): ?string |
190
|
|
|
{ |
191
|
|
|
return $this->routeId; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* [Optional] ID of the phone or route to send the message from |
196
|
|
|
* Default: default sender route ID for your project |
197
|
|
|
* |
198
|
|
|
* @param string $routeId |
199
|
|
|
* @return TelerivetMessage |
200
|
|
|
*/ |
201
|
|
|
public function setRouteId(?string $routeId): self |
202
|
|
|
{ |
203
|
|
|
$this->routeId = $routeId; |
204
|
|
|
|
205
|
|
|
return $this; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @return string |
210
|
|
|
*/ |
211
|
|
|
public function getStatusUrl(): ?string |
212
|
|
|
{ |
213
|
|
|
return $this->statusUrl; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* [Optional] Webhook callback URL to be notified when message status changes |
218
|
|
|
* |
219
|
|
|
* @param string $statusUrl |
220
|
|
|
* @return TelerivetMessage |
221
|
|
|
*/ |
222
|
|
|
public function setStatusUrl(?string $statusUrl): self |
223
|
|
|
{ |
224
|
|
|
$this->statusUrl = $statusUrl; |
225
|
|
|
|
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @return string |
231
|
|
|
*/ |
232
|
|
|
public function getStatusSecret(): ?string |
233
|
|
|
{ |
234
|
|
|
return $this->statusSecret; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* [Optional] POST parameter 'secret' passed to status_url |
239
|
|
|
* |
240
|
|
|
* @param string $statusSecret |
241
|
|
|
* @return TelerivetMessage |
242
|
|
|
*/ |
243
|
|
|
public function setStatusSecret(?string $statusSecret): self |
244
|
|
|
{ |
245
|
|
|
$this->statusSecret = $statusSecret; |
246
|
|
|
|
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @return bool |
252
|
|
|
*/ |
253
|
|
|
public function isTemplate(): ?bool |
254
|
|
|
{ |
255
|
|
|
return $this->isTemplate; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* [Optional] Set to true to evaluate variables like [[contact.name]] in message content. |
260
|
|
|
* (See available variables https://telerivet.com/api/rest/curl#variables) |
261
|
|
|
* Default: false |
262
|
|
|
* |
263
|
|
|
* @param bool $isTemplate |
264
|
|
|
* @return TelerivetMessage |
265
|
|
|
*/ |
266
|
|
|
public function setIsTemplate(?bool $isTemplate): self |
267
|
|
|
{ |
268
|
|
|
$this->isTemplate = $isTemplate; |
269
|
|
|
|
270
|
|
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @return bool |
275
|
|
|
*/ |
276
|
|
|
public function isTrackClicks(): ?bool |
277
|
|
|
{ |
278
|
|
|
return $this->trackClicks; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* [Optional] If true, URLs in the message content will automatically be replaced with unique short URLs. |
283
|
|
|
* Default: false |
284
|
|
|
* |
285
|
|
|
* @param bool $trackClicks |
286
|
|
|
* @return TelerivetMessage |
287
|
|
|
*/ |
288
|
|
|
public function setTrackClicks(?bool $trackClicks): self |
289
|
|
|
{ |
290
|
|
|
$this->trackClicks = $trackClicks; |
291
|
|
|
|
292
|
|
|
return $this; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @return array |
297
|
|
|
*/ |
298
|
|
|
public function getMediaUrls(): ?array |
299
|
|
|
{ |
300
|
|
|
return $this->mediaUrls; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* [Optional] URLs of media files to attach to the text message. If message_type is sms, short links to each media |
305
|
|
|
* URL will be appended to the end of the content (separated by a new line). |
306
|
|
|
* |
307
|
|
|
* @param array $mediaUrls |
308
|
|
|
* @return TelerivetMessage |
309
|
|
|
*/ |
310
|
|
|
public function setMediaUrls(?array $mediaUrls): self |
311
|
|
|
{ |
312
|
|
|
$this->mediaUrls = $mediaUrls; |
313
|
|
|
|
314
|
|
|
return $this; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @return array |
319
|
|
|
*/ |
320
|
|
|
public function getLabelIds(): ?array |
321
|
|
|
{ |
322
|
|
|
return $this->labelIds; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* [Optional] Array string IDs of Label <https://telerivet.com/api/rest/curl#Label> |
327
|
|
|
* List of IDs of labels to add to this message |
328
|
|
|
* |
329
|
|
|
* @param array $labelIds |
330
|
|
|
* @return TelerivetMessage |
331
|
|
|
*/ |
332
|
|
|
public function setLabelIds(?array $labelIds): self |
333
|
|
|
{ |
334
|
|
|
$this->labelIds = $labelIds; |
335
|
|
|
|
336
|
|
|
return $this; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @return object |
341
|
|
|
*/ |
342
|
|
|
public function getVars(): ?object |
343
|
|
|
{ |
344
|
|
|
return $this->vars; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* [Optional] Custom variables to store with the message |
349
|
|
|
* |
350
|
|
|
* @param object $vars |
351
|
|
|
* @return TelerivetMessage |
352
|
|
|
*/ |
353
|
|
|
public function setVars(?object $vars): self |
354
|
|
|
{ |
355
|
|
|
$this->vars = $vars; |
356
|
|
|
|
357
|
|
|
return $this; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* @return int |
362
|
|
|
*/ |
363
|
|
|
public function getPriority(): ?int |
364
|
|
|
{ |
365
|
|
|
return $this->priority; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* [Optional] Priority of the message. Telerivet will attempt to send messages with higher priority numbers first |
370
|
|
|
* (for example, so you can prioritize an auto-reply ahead of a bulk message to a large group). |
371
|
|
|
* Possible Values: 1, 2 |
372
|
|
|
* Default: 1 |
373
|
|
|
* |
374
|
|
|
* @param int $priority |
375
|
|
|
* @return TelerivetMessage |
376
|
|
|
*/ |
377
|
|
|
public function setPriority(?int $priority): self |
378
|
|
|
{ |
379
|
|
|
$this->priority = $priority; |
380
|
|
|
|
381
|
|
|
return $this; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* @return bool |
386
|
|
|
*/ |
387
|
|
|
public function isSimulated(): ?bool |
388
|
|
|
{ |
389
|
|
|
return $this->simulated; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* [Optional] Set to true to test the Telerivet API without actually sending a message from the route |
394
|
|
|
* Default: false |
395
|
|
|
* |
396
|
|
|
* @param bool $simulated |
397
|
|
|
* @return TelerivetMessage |
398
|
|
|
*/ |
399
|
|
|
public function setSimulated(?bool $simulated): self |
400
|
|
|
{ |
401
|
|
|
$this->simulated = $simulated; |
402
|
|
|
|
403
|
|
|
return $this; |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* @return string |
408
|
|
|
*/ |
409
|
|
|
public function getServiceId(): ?string |
410
|
|
|
{ |
411
|
|
|
return $this->serviceId; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* [Optional] string ID of Service <https://telerivet.com/api/rest/curl#Service> |
416
|
|
|
* Service that defines the call flow of the voice call (when message_type is call) |
417
|
|
|
* |
418
|
|
|
* @param string $serviceId |
419
|
|
|
* @return TelerivetMessage |
420
|
|
|
*/ |
421
|
|
|
public function setServiceId(?string $serviceId): self |
422
|
|
|
{ |
423
|
|
|
$this->serviceId = $serviceId; |
424
|
|
|
|
425
|
|
|
return $this; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @return string |
430
|
|
|
*/ |
431
|
|
|
public function getAudioUrl(): ?string |
432
|
|
|
{ |
433
|
|
|
return $this->audioUrl; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* [Optional] The URL of an MP3 file to play when the contact answers the call (when message_type is call). |
438
|
|
|
* If audio_url is provided, the text-to-speech voice is not used to say content, although you can optionally use |
439
|
|
|
* content to indicate the script for the audio. |
440
|
|
|
* For best results, use an MP3 file containing only speech. Music is not recommended because the audio quality will |
441
|
|
|
* be low when played over a phone line. |
442
|
|
|
* |
443
|
|
|
* @param string $audioUrl |
444
|
|
|
* @return TelerivetMessage |
445
|
|
|
*/ |
446
|
|
|
public function setAudioUrl(?string $audioUrl): self |
447
|
|
|
{ |
448
|
|
|
$this->audioUrl = $audioUrl; |
449
|
|
|
|
450
|
|
|
return $this; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* @return string |
455
|
|
|
*/ |
456
|
|
|
public function getTtsLang(): ?string |
457
|
|
|
{ |
458
|
|
|
return $this->ttsLang; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* [Optional] The language of the text-to-speech voice (when message_type is call) |
463
|
|
|
* Possible Values: en-US, en-GB, en-GB-WLS, en-AU, en-IN, da-DK, nl-NL, fr-FR, fr-CA, de-DE, is-IS, it-IT, pl-PL, |
464
|
|
|
* pt-BR, pt-PT, ru-RU, es-ES, es-US, sv-SE |
465
|
|
|
* Default: en-US |
466
|
|
|
* |
467
|
|
|
* @param string $ttsLang |
468
|
|
|
* @return TelerivetMessage |
469
|
|
|
*/ |
470
|
|
|
public function setTtsLang(?string $ttsLang): self |
471
|
|
|
{ |
472
|
|
|
$this->ttsLang = $ttsLang; |
473
|
|
|
|
474
|
|
|
return $this; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* @return string |
479
|
|
|
*/ |
480
|
|
|
public function getTtsVoice(): ?string |
481
|
|
|
{ |
482
|
|
|
return $this->ttsVoice; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* [Optional] The name of the text-to-speech voice (when message_type=call) |
487
|
|
|
* Possible Values: female, male |
488
|
|
|
* Default: female |
489
|
|
|
* |
490
|
|
|
* @param string $ttsVoice |
491
|
|
|
* @return TelerivetMessage |
492
|
|
|
*/ |
493
|
|
|
public function setTtsVoice(?string $ttsVoice): self |
494
|
|
|
{ |
495
|
|
|
$this->ttsVoice = $ttsVoice; |
496
|
|
|
|
497
|
|
|
return $this; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
public function toArray() |
501
|
|
|
{ |
502
|
|
|
return [ |
503
|
|
|
'message_type' => $this->getMessageType(), |
504
|
|
|
'content' => $this->getContent(), |
505
|
|
|
'to_number' => $this->getToNumber(), |
506
|
|
|
'contact_id' => $this->getContactId(), |
507
|
|
|
'route_id' => $this->getRouteId(), |
508
|
|
|
'status_url' => $this->getStatusUrl(), |
509
|
|
|
'status_secret' => $this->getStatusSecret(), |
510
|
|
|
'is_template' => $this->isTemplate(), |
511
|
|
|
'track_clicks' => $this->isTrackClicks(), |
512
|
|
|
'media_urls' => $this->getMediaUrls(), |
513
|
|
|
'label_ids' => $this->getLabelIds(), |
514
|
|
|
'vars' => $this->getVars(), |
515
|
|
|
'priority' => $this->getPriority(), |
516
|
|
|
'simulated' => $this->isSimulated(), |
517
|
|
|
'service_id' => $this->getServiceId(), |
518
|
|
|
'audio_url' => $this->getAudioUrl(), |
519
|
|
|
'tts_lang' => $this->getTtsLang(), |
520
|
|
|
'tts_voice' => $this->getTtsVoice(), |
521
|
|
|
]; |
522
|
|
|
} |
523
|
|
|
} |
524
|
|
|
|