|
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 $bounce = []; |
|
22
|
|
|
private $deliver = []; |
|
23
|
|
|
private $drop = []; |
|
24
|
|
|
private $spam = []; |
|
25
|
|
|
private $unsubscribe = []; |
|
26
|
|
|
private $click = []; |
|
27
|
|
|
private $open = []; |
|
28
|
|
|
|
|
29
|
|
|
private function __construct() |
|
30
|
|
|
{ |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public static function create(array $data): self |
|
34
|
|
|
{ |
|
35
|
|
|
$model = new self(); |
|
36
|
|
|
|
|
37
|
|
|
$data = $data['webhooks'] ?? $data; |
|
38
|
|
|
|
|
39
|
|
|
$model->bounce = $data['bounce'] ?? []; |
|
40
|
|
|
$model->deliver = $data['deliver'] ?? []; |
|
41
|
|
|
$model->drop = $data['drop'] ?? []; |
|
42
|
|
|
$model->spam = $data['spam'] ?? []; |
|
43
|
|
|
$model->unsubscribe = $data['unsubscribe'] ?? []; |
|
44
|
|
|
$model->click = $data['click'] ?? []; |
|
45
|
|
|
$model->open = $data['open'] ?? []; |
|
46
|
|
|
|
|
47
|
|
|
return $model; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getBounceUrl(): ?string |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->bounce['url'] ?? null; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getDeliverUrl(): ?string |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->deliver['url'] ?? null; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getDropUrl(): ?string |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->drop['url'] ?? null; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function getSpamUrl(): ?string |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->spam['url'] ?? null; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function getUnsubscribeUrl() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->unsubscribe['url'] ?? null; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function getClickUrl(): ?string |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->click['url'] ?? null; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getOpenUrl(): ?string |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->open['url'] ?? null; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|