|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2013-2016 Mailgun |
|
5
|
|
|
* |
|
6
|
|
|
* This software may be modified and distributed under the terms |
|
7
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Mailgun\Resource\Api\Webhook; |
|
11
|
|
|
|
|
12
|
|
|
use Mailgun\Resource\ApiResponse; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author Tobias Nyholm <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class IndexResponse implements ApiResponse |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
private $bounce = []; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var array |
|
26
|
|
|
*/ |
|
27
|
|
|
private $deliver = []; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var array |
|
31
|
|
|
*/ |
|
32
|
|
|
private $drop = []; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var array |
|
36
|
|
|
*/ |
|
37
|
|
|
private $spam = []; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
private $unsubscribe = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
private $click = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var array |
|
51
|
|
|
*/ |
|
52
|
|
|
private $open = []; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Do not let this object be creted without the ::create. |
|
56
|
|
|
*/ |
|
57
|
|
|
private function __construct() |
|
58
|
|
|
{ |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param array $data |
|
63
|
|
|
* |
|
64
|
|
|
* @return IndexResponse |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function create(array $data) |
|
67
|
|
|
{ |
|
68
|
|
|
$self = new self(); |
|
69
|
|
|
if (isset($data['bounce'])) { |
|
70
|
|
|
$self->setBounce($data['bounce']); |
|
71
|
|
|
} |
|
72
|
|
|
if (isset($data['deliver'])) { |
|
73
|
|
|
$self->setDeliver($data['deliver']); |
|
74
|
|
|
} |
|
75
|
|
|
if (isset($data['drop'])) { |
|
76
|
|
|
$self->setDrop($data['drop']); |
|
77
|
|
|
} |
|
78
|
|
|
if (isset($data['spam'])) { |
|
79
|
|
|
$self->setSpam($data['spam']); |
|
80
|
|
|
} |
|
81
|
|
|
if (isset($data['unsubscribe'])) { |
|
82
|
|
|
$self->setUnsubscribe($data['unsubscribe']); |
|
83
|
|
|
} |
|
84
|
|
|
if (isset($data['click'])) { |
|
85
|
|
|
$self->setClick($data['click']); |
|
86
|
|
|
} |
|
87
|
|
|
if (isset($data['open'])) { |
|
88
|
|
|
$self->setOpen($data['open']); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return $self; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return string|null |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getBounceUrl() |
|
98
|
|
|
{ |
|
99
|
|
|
if (isset($this->bounce['url'])) { |
|
100
|
|
|
return $this->bounce['url']; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param array $bounce |
|
106
|
|
|
*/ |
|
107
|
|
|
private function setBounce($bounce) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->bounce = $bounce; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return string|null |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getDeliverUrl() |
|
116
|
|
|
{ |
|
117
|
|
|
if (isset($this->deliver['url'])) { |
|
118
|
|
|
return $this->deliver['url']; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @param array $deliver |
|
124
|
|
|
*/ |
|
125
|
|
|
private function setDeliver($deliver) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->deliver = $deliver; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return string|null |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getDropUrl() |
|
134
|
|
|
{ |
|
135
|
|
|
if (isset($this->drop['url'])) { |
|
136
|
|
|
return $this->drop['url']; |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param array $drop |
|
142
|
|
|
*/ |
|
143
|
|
|
private function setDrop($drop) |
|
144
|
|
|
{ |
|
145
|
|
|
$this->drop = $drop; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @return string|null |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getSpamUrl() |
|
152
|
|
|
{ |
|
153
|
|
|
if (isset($this->spam['url'])) { |
|
154
|
|
|
return $this->spam['url']; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @param array $spam |
|
160
|
|
|
*/ |
|
161
|
|
|
private function setSpam($spam) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->spam = $spam; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @return string|null |
|
168
|
|
|
*/ |
|
169
|
|
|
public function getUnsubscribeUrl() |
|
170
|
|
|
{ |
|
171
|
|
|
if (isset($this->unsubscribe['url'])) { |
|
172
|
|
|
return $this->unsubscribe['url']; |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param array $unsubscribe |
|
178
|
|
|
*/ |
|
179
|
|
|
private function setUnsubscribe($unsubscribe) |
|
180
|
|
|
{ |
|
181
|
|
|
$this->unsubscribe = $unsubscribe; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @return string|null |
|
186
|
|
|
*/ |
|
187
|
|
|
public function getClickUrl() |
|
188
|
|
|
{ |
|
189
|
|
|
if (isset($this->click['url'])) { |
|
190
|
|
|
return $this->click['url']; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @param array $click |
|
196
|
|
|
*/ |
|
197
|
|
|
private function setClick($click) |
|
198
|
|
|
{ |
|
199
|
|
|
$this->click = $click; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @return string|null |
|
204
|
|
|
*/ |
|
205
|
|
|
public function getOpenUrl() |
|
206
|
|
|
{ |
|
207
|
|
|
if (isset($this->open['url'])) { |
|
208
|
|
|
return $this->open['url']; |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @param array $open |
|
214
|
|
|
*/ |
|
215
|
|
|
private function setOpen($open) |
|
216
|
|
|
{ |
|
217
|
|
|
$this->open = $open; |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
|