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