1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Copyright (C) 2013 Mailgun |
7
|
|
|
* |
8
|
|
|
* This software may be modified and distributed under the terms |
9
|
|
|
* of the MIT license. See the LICENSE file for details. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Mailgun\Model\Webhook; |
13
|
|
|
|
14
|
|
|
use Mailgun\Model\ApiResponse; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Tobias Nyholm <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
final class IndexResponse implements ApiResponse |
20
|
|
|
{ |
21
|
|
|
private $legacyBounce = null; |
22
|
|
|
private $legacyDeliver = null; |
23
|
|
|
private $legacyDrop = null; |
24
|
|
|
private $legacySpam = null; |
25
|
|
|
private $legacyUnsubscribe = null; |
26
|
|
|
private $legacyClick = null; |
27
|
|
|
private $legacyOpen = null; |
28
|
|
|
private $clicked = []; |
29
|
|
|
private $complained = []; |
30
|
|
|
private $delivered = []; |
31
|
|
|
private $opened = []; |
32
|
|
|
private $permanentFail = []; |
33
|
|
|
private $temporaryFail = []; |
34
|
|
|
private $unsubscribed = []; |
35
|
|
|
|
36
|
2 |
|
private function __construct() |
37
|
|
|
{ |
38
|
2 |
|
} |
39
|
|
|
|
40
|
2 |
|
public static function create(array $data): self |
41
|
|
|
{ |
42
|
2 |
|
$model = new self(); |
43
|
|
|
|
44
|
2 |
|
$data = $data['webhooks'] ?? $data; |
45
|
|
|
|
46
|
2 |
|
$model->legacyBounce = $data['bounce']['url'] ?? null; |
47
|
2 |
|
$model->legacyDeliver = $data['deliver']['url'] ?? null; |
48
|
2 |
|
$model->legacyDrop = $data['drop']['url'] ?? null; |
49
|
2 |
|
$model->legacySpam = $data['spam']['url'] ?? null; |
50
|
2 |
|
$model->legacyUnsubscribe = $data['unsubscribe']['url'] ?? null; |
51
|
2 |
|
$model->legacyClick = $data['click']['url'] ?? null; |
52
|
2 |
|
$model->legacyOpen = $data['open']['url'] ?? null; |
53
|
|
|
|
54
|
2 |
|
$model->clicked = $data['clicked']['urls'] ?? []; |
55
|
2 |
|
$model->complained = $data['complained']['urls'] ?? []; |
56
|
2 |
|
$model->delivered = $data['delivered']['urls'] ?? []; |
57
|
2 |
|
$model->opened = $data['opened']['urls'] ?? []; |
58
|
2 |
|
$model->permanentFail = $data['permanent_fail']['urls'] ?? []; |
59
|
2 |
|
$model->temporaryFail = $data['temporary_fail']['urls'] ?? []; |
60
|
2 |
|
$model->unsubscribed = $data['unsubscribed']['urls'] ?? []; |
61
|
|
|
|
62
|
2 |
|
return $model; |
63
|
|
|
} |
64
|
|
|
|
65
|
2 |
|
public function getBounceUrl(): ?string |
66
|
|
|
{ |
67
|
2 |
|
return $this->legacyBounce; |
68
|
|
|
} |
69
|
|
|
|
70
|
2 |
|
public function getDeliverUrl(): ?string |
71
|
|
|
{ |
72
|
2 |
|
return $this->legacyDeliver; |
73
|
|
|
} |
74
|
|
|
|
75
|
2 |
|
public function getDropUrl(): ?string |
76
|
|
|
{ |
77
|
2 |
|
return $this->legacyDrop; |
78
|
|
|
} |
79
|
|
|
|
80
|
2 |
|
public function getSpamUrl(): ?string |
81
|
|
|
{ |
82
|
2 |
|
return $this->legacySpam; |
83
|
|
|
} |
84
|
|
|
|
85
|
2 |
|
public function getUnsubscribeUrl(): ?string |
86
|
|
|
{ |
87
|
2 |
|
return $this->legacyUnsubscribe; |
88
|
|
|
} |
89
|
|
|
|
90
|
2 |
|
public function getClickUrl(): ?string |
91
|
|
|
{ |
92
|
2 |
|
return $this->legacyClick; |
93
|
|
|
} |
94
|
|
|
|
95
|
2 |
|
public function getOpenUrl(): ?string |
96
|
|
|
{ |
97
|
2 |
|
return $this->legacyOpen; |
98
|
|
|
} |
99
|
|
|
|
100
|
2 |
|
public function getClickedUrls(): ?array |
101
|
|
|
{ |
102
|
2 |
|
return $this->clicked; |
103
|
|
|
} |
104
|
|
|
|
105
|
2 |
|
public function getComplainedUrls(): ?array |
106
|
|
|
{ |
107
|
2 |
|
return $this->complained; |
108
|
|
|
} |
109
|
|
|
|
110
|
2 |
|
public function getDeliveredUrls(): ?array |
111
|
|
|
{ |
112
|
2 |
|
return $this->delivered; |
113
|
|
|
} |
114
|
|
|
|
115
|
2 |
|
public function getOpenedUrls(): ?array |
116
|
|
|
{ |
117
|
2 |
|
return $this->opened; |
118
|
|
|
} |
119
|
|
|
|
120
|
2 |
|
public function getPermanentFailUrls(): ?array |
121
|
|
|
{ |
122
|
2 |
|
return $this->permanentFail; |
123
|
|
|
} |
124
|
|
|
|
125
|
2 |
|
public function getTemporaryFailUrls(): ?array |
126
|
|
|
{ |
127
|
2 |
|
return $this->temporaryFail; |
128
|
|
|
} |
129
|
|
|
|
130
|
2 |
|
public function getUnsubscribeUrls(): ?array |
131
|
|
|
{ |
132
|
2 |
|
return $this->unsubscribed; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|