|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the FreshSinchBundle |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Artem Henvald <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace Fresh\SinchBundle\Model; |
|
14
|
|
|
|
|
15
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* CallbackRequest Model. |
|
19
|
|
|
* |
|
20
|
|
|
* @author Artem Henvald <[email protected]> |
|
21
|
|
|
* |
|
22
|
|
|
* @see https://www.sinch.com/docs/sms/#incomingsms |
|
23
|
|
|
*/ |
|
24
|
|
|
class CallbackRequest |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
* |
|
29
|
|
|
* @Assert\NotNull(message="Event cannot be null.") |
|
30
|
|
|
* @Assert\Choice(choices = {"incomingSms"}, message = "Invalid event.") |
|
31
|
|
|
*/ |
|
32
|
|
|
private $event; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var Identity |
|
36
|
|
|
* |
|
37
|
|
|
* @Assert\NotNull(message="To cannot be null.") |
|
38
|
|
|
* @Assert\Type(type="object") |
|
39
|
|
|
* @Assert\Valid() |
|
40
|
|
|
*/ |
|
41
|
|
|
private $to; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var Identity |
|
45
|
|
|
* |
|
46
|
|
|
* @Assert\NotNull(message="From cannot be null.") |
|
47
|
|
|
* @Assert\Type(type="object") |
|
48
|
|
|
* @Assert\Valid() |
|
49
|
|
|
*/ |
|
50
|
|
|
private $from; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var string |
|
54
|
|
|
* |
|
55
|
|
|
* @Assert\NotNull(message="Message cannot be null.") |
|
56
|
|
|
* @Assert\Type(type="string") |
|
57
|
|
|
*/ |
|
58
|
|
|
private $message; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var \DateTime |
|
62
|
|
|
* |
|
63
|
|
|
* @Assert\NotNull(message="Timestamp cannot be null.") |
|
64
|
|
|
* @Assert\DateTime() |
|
65
|
|
|
*/ |
|
66
|
|
|
private $timestamp; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var int |
|
70
|
|
|
* |
|
71
|
|
|
* @Assert\NotNull(message="Version cannot be null.") |
|
72
|
|
|
* @Assert\Type(type="integer") |
|
73
|
|
|
*/ |
|
74
|
|
|
private $version; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return string|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getEvent(): ?string |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->event; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param string $event |
|
86
|
|
|
* |
|
87
|
|
|
* @return $this |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setEvent(string $event): self |
|
90
|
|
|
{ |
|
91
|
|
|
$this->event = $event; |
|
92
|
|
|
|
|
93
|
|
|
return $this; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return Identity |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getTo(): ?Identity |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->to; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param Identity $to |
|
106
|
|
|
* |
|
107
|
|
|
* @return $this |
|
108
|
|
|
*/ |
|
109
|
|
|
public function setTo(Identity $to): self |
|
110
|
|
|
{ |
|
111
|
|
|
$this->to = $to; |
|
112
|
|
|
|
|
113
|
|
|
return $this; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return Identity |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getFrom(): ?Identity |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->from; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @param Identity $from |
|
126
|
|
|
* |
|
127
|
|
|
* @return $this |
|
128
|
|
|
*/ |
|
129
|
|
|
public function setFrom(Identity $from): self |
|
130
|
|
|
{ |
|
131
|
|
|
$this->from = $from; |
|
132
|
|
|
|
|
133
|
|
|
return $this; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return string|null |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getMessage(): ?string |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->message; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @param string $message |
|
146
|
|
|
* |
|
147
|
|
|
* @return $this |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setMessage(string $message): self |
|
150
|
|
|
{ |
|
151
|
|
|
$this->message = $message; |
|
152
|
|
|
|
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @return \DateTime |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getTimestamp(): ?\DateTime |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->timestamp; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param \DateTime $timestamp |
|
166
|
|
|
* |
|
167
|
|
|
* @return $this |
|
168
|
|
|
*/ |
|
169
|
|
|
public function setTimestamp(\DateTime $timestamp): self |
|
170
|
|
|
{ |
|
171
|
|
|
$this->timestamp = $timestamp; |
|
172
|
|
|
|
|
173
|
|
|
return $this; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @return string|null |
|
178
|
|
|
*/ |
|
179
|
|
|
public function getVersion(): ?int |
|
180
|
|
|
{ |
|
181
|
|
|
return $this->version; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @param int $version |
|
186
|
|
|
* |
|
187
|
|
|
* @return $this |
|
188
|
|
|
*/ |
|
189
|
|
|
public function setVersion(int $version): self |
|
190
|
|
|
{ |
|
191
|
|
|
$this->version = $version; |
|
192
|
|
|
|
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
} |
|
196
|
|
|
|