1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Azine\MailgunWebhooksBundle\Entity; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* MailgunMessageSummary |
7
|
|
|
*/ |
8
|
|
|
class MailgunMessageSummary |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
private $id; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $fromAddress; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $toAddress; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \DateTime |
27
|
|
|
*/ |
28
|
|
|
private $firstOpened; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \DateTime |
32
|
|
|
*/ |
33
|
|
|
private $lastOpened; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var integer |
37
|
|
|
*/ |
38
|
|
|
private $openCount; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var \DateTime |
42
|
|
|
*/ |
43
|
|
|
private $sendDate; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
private $deliveryStatus; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string |
52
|
|
|
*/ |
53
|
|
|
private $senderIp; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
private $subject; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var \Doctrine\Common\Collections\Collection |
62
|
|
|
*/ |
63
|
|
|
private $events; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Constructor |
67
|
|
|
*/ |
68
|
|
|
public function __construct($id, \DateTime $sendDate, $fromAddress, $toAddress, $subject, $senderIp) |
69
|
|
|
{ |
70
|
|
|
$this->events = new \Doctrine\Common\Collections\ArrayCollection(); |
71
|
|
|
$this->id = $id; |
72
|
|
|
$this->sendDate = $sendDate; |
73
|
|
|
$this->fromAddress = $fromAddress; |
74
|
|
|
$this->toAddress = $toAddress; |
75
|
|
|
$this->subject = $subject; |
76
|
|
|
$this->senderIp = $senderIp; |
77
|
|
|
$this->openCount = 0; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Append the latest event to the delivery status |
82
|
|
|
* |
83
|
|
|
* @param $eventType |
84
|
|
|
*/ |
85
|
|
|
public function updateDeliveryStatus($eventType){ |
86
|
|
|
if(stripos($this->deliveryStatus, $eventType) === false){ |
87
|
|
|
$this->deliveryStatus = $this->deliveryStatus."$eventType, "; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get id |
93
|
|
|
* |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
|
|
public function getId() |
97
|
|
|
{ |
98
|
|
|
return $this->id; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get fromAddress |
103
|
|
|
* |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getFromAddress() |
107
|
|
|
{ |
108
|
|
|
return $this->fromAddress; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get toAddress |
113
|
|
|
* |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getToAddress() |
117
|
|
|
{ |
118
|
|
|
return $this->toAddress; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Set firstOpened |
123
|
|
|
* |
124
|
|
|
* @param \DateTime $firstOpened |
125
|
|
|
* |
126
|
|
|
* @return MailgunMessageSummary |
127
|
|
|
*/ |
128
|
|
|
public function setFirstOpened($firstOpened) |
129
|
|
|
{ |
130
|
|
|
$this->firstOpened = $firstOpened; |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get firstOpened |
137
|
|
|
* |
138
|
|
|
* @return \DateTime |
139
|
|
|
*/ |
140
|
|
|
public function getFirstOpened() |
141
|
|
|
{ |
142
|
|
|
return $this->firstOpened; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Set lastOpened |
147
|
|
|
* |
148
|
|
|
* @param \DateTime $lastOpened |
149
|
|
|
* |
150
|
|
|
* @return MailgunMessageSummary |
151
|
|
|
*/ |
152
|
|
|
public function setLastOpened($lastOpened) |
153
|
|
|
{ |
154
|
|
|
$this->lastOpened = $lastOpened; |
155
|
|
|
|
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get lastOpened |
161
|
|
|
* |
162
|
|
|
* @return \DateTime |
163
|
|
|
*/ |
164
|
|
|
public function getLastOpened() |
165
|
|
|
{ |
166
|
|
|
return $this->lastOpened; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Increase openCount by 1 |
171
|
|
|
* |
172
|
|
|
* @return MailgunMessageSummary |
173
|
|
|
*/ |
174
|
|
|
public function increaseOpenCount() |
175
|
|
|
{ |
176
|
|
|
$this->openCount++; |
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Get openCount |
182
|
|
|
* |
183
|
|
|
* @return integer |
184
|
|
|
*/ |
185
|
|
|
public function getOpenCount() |
186
|
|
|
{ |
187
|
|
|
return $this->openCount; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Get sendDate |
192
|
|
|
* |
193
|
|
|
* @return \DateTime |
194
|
|
|
*/ |
195
|
|
|
public function getSendDate() |
196
|
|
|
{ |
197
|
|
|
return $this->sendDate; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Get deliveryStatus |
202
|
|
|
* |
203
|
|
|
* @return string |
204
|
|
|
*/ |
205
|
|
|
public function getDeliveryStatus() |
206
|
|
|
{ |
207
|
|
|
return trim($this->deliveryStatus, ", "); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Get senderIp |
212
|
|
|
* |
213
|
|
|
* @return string |
214
|
|
|
*/ |
215
|
|
|
public function getSenderIp() |
216
|
|
|
{ |
217
|
|
|
return $this->senderIp; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Set senderIp |
222
|
|
|
* |
223
|
|
|
* @return MailgunMessageSummary |
224
|
|
|
*/ |
225
|
|
|
public function setSenderIp($ip) |
226
|
|
|
{ |
227
|
|
|
$this->senderIp = $ip; |
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
/** |
232
|
|
|
* Get events |
233
|
|
|
* |
234
|
|
|
* @return \Doctrine\Common\Collections\Collection |
235
|
|
|
*/ |
236
|
|
|
public function getEvents() |
237
|
|
|
{ |
238
|
|
|
return $this->events; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Get subject |
243
|
|
|
* |
244
|
|
|
* @return string |
245
|
|
|
*/ |
246
|
|
|
public function getSubject() |
247
|
|
|
{ |
248
|
|
|
return $this->subject; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Set subject |
253
|
|
|
* |
254
|
|
|
* @return MailgunMessageSummary |
255
|
|
|
*/ |
256
|
|
|
public function setSubject($subject) |
257
|
|
|
{ |
258
|
|
|
$this->subject = $subject; |
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Set fromAddress |
264
|
|
|
* |
265
|
|
|
* @return MailgunMessageSummary |
266
|
|
|
*/ |
267
|
|
|
public function setFromAddress($fromAddress) |
268
|
|
|
{ |
269
|
|
|
$this->fromAddress = $fromAddress; |
270
|
|
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Set toAddress |
275
|
|
|
* |
276
|
|
|
* @return MailgunMessageSummary |
277
|
|
|
*/ |
278
|
|
|
public function appendToToAddress($toAddress) |
279
|
|
|
{ |
280
|
|
|
$this->toAddress = trim($this->toAddress . ", " . $toAddress,", "); |
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
} |
285
|
|
|
|