1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Andreshg112\HablameSms; |
4
|
|
|
|
5
|
|
|
class HablameMessage |
6
|
|
|
{ |
7
|
|
|
private ?string $phoneNumber = null; |
8
|
|
|
|
9
|
|
|
private ?string $sms = null; |
10
|
|
|
|
11
|
|
|
private ?string $datetime = null; |
12
|
|
|
|
13
|
|
|
private ?string $reference = null; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Creates the instance. |
17
|
|
|
* |
18
|
|
|
* @param string|null $phoneNumber |
19
|
|
|
* @param string|null $sms |
20
|
|
|
* @param string|null $datetime |
21
|
|
|
* @param string|null $reference |
22
|
|
|
*/ |
23
|
|
|
public function __construct( |
24
|
|
|
string $phoneNumber = null, |
25
|
|
|
string $sms = null, |
26
|
|
|
string $datetime = null, |
27
|
6 |
|
string $reference = null |
28
|
|
|
) { |
29
|
|
|
$this->phoneNumber = $phoneNumber; |
30
|
|
|
|
31
|
|
|
$this->sms = $sms; |
32
|
|
|
|
33
|
6 |
|
$this->datetime = $datetime; |
34
|
|
|
|
35
|
6 |
|
$this->reference = $reference; |
36
|
|
|
} |
37
|
6 |
|
|
38
|
|
|
/** |
39
|
6 |
|
* Número telefonico a enviar SMS. |
40
|
6 |
|
* |
41
|
|
|
* @param string $phoneNumber |
42
|
|
|
* @return $this |
43
|
|
|
*/ |
44
|
|
|
public function phoneNumber(string $phoneNumber): self |
45
|
|
|
{ |
46
|
|
|
$this->phoneNumber = $phoneNumber; |
47
|
|
|
|
48
|
1 |
|
return $this; |
49
|
|
|
} |
50
|
1 |
|
|
51
|
|
|
/** |
52
|
1 |
|
* Mensaje de texto a enviar. |
53
|
|
|
* |
54
|
|
|
* @param string $sms |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function sms(string $sms): self |
58
|
|
|
{ |
59
|
|
|
$this->sms = $sms; |
60
|
|
|
|
61
|
1 |
|
return $this; |
62
|
|
|
} |
63
|
1 |
|
|
64
|
|
|
/** |
65
|
1 |
|
* [optional] Fecha de envío. Si está vacío, se envía inmediatamente. |
66
|
|
|
* (Ejemplo: 2017-12-31 23:59:59). |
67
|
|
|
* |
68
|
|
|
* @param string|null $datetime |
69
|
|
|
* @return $this |
70
|
|
|
*/ |
71
|
|
|
public function datetime(string $datetime = null): self |
72
|
|
|
{ |
73
|
|
|
$this->datetime = $datetime; |
74
|
|
|
|
75
|
1 |
|
return $this; |
76
|
|
|
} |
77
|
1 |
|
|
78
|
|
|
/** |
79
|
1 |
|
* [optional] Número de reference o nombre de campaña. |
80
|
|
|
* |
81
|
|
|
* @param string|null $reference |
82
|
|
|
* @return $this |
83
|
|
|
*/ |
84
|
|
|
public function reference(string $reference = null): self |
85
|
|
|
{ |
86
|
|
|
$this->reference = $reference; |
87
|
|
|
|
88
|
1 |
|
return $this; |
89
|
|
|
} |
90
|
1 |
|
|
91
|
|
|
public function toArray(): array |
92
|
1 |
|
{ |
93
|
|
|
return [ |
94
|
|
|
'toNumber' => $this->phoneNumber, |
95
|
6 |
|
'sms' => $this->sms, |
96
|
|
|
'sendDate' => $this->datetime, |
97
|
|
|
'reference' => $this->reference, |
98
|
6 |
|
]; |
99
|
6 |
|
} |
100
|
|
|
} |
101
|
|
|
|