1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mailgun\Api; |
4
|
|
|
|
5
|
|
|
use Mailgun\Assert; |
6
|
|
|
use Mailgun\Resource\Api\Webhook\CreateResponse; |
7
|
|
|
use Mailgun\Resource\Api\Webhook\DeleteResponse; |
8
|
|
|
use Mailgun\Resource\Api\Webhook\IndexResponse; |
9
|
|
|
use Mailgun\Resource\Api\Webhook\ShowResponse; |
10
|
|
|
use Mailgun\Resource\Api\Webhook\UpdateResponse; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @author Tobias Nyholm <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class Webhook extends HttpApi |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param string $domain |
19
|
|
|
* |
20
|
|
|
* @return IndexResponse |
21
|
|
|
*/ |
22
|
|
|
public function index($domain) |
23
|
|
|
{ |
24
|
|
|
Assert::notEmpty($domain); |
25
|
|
|
$response = $this->httpGet(sprintf('/v3/domains/%s/webhooks', $domain)); |
26
|
|
|
|
27
|
|
|
return $this->deserializer->deserialize($response, IndexResponse::class); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param string $domain |
32
|
|
|
* @param string $webhook |
33
|
|
|
* |
34
|
|
|
* @return ShowResponse |
35
|
|
|
*/ |
36
|
|
View Code Duplication |
public function show($domain, $webhook) |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
Assert::notEmpty($domain); |
39
|
|
|
Assert::notEmpty($webhook); |
40
|
|
|
$response = $this->httpGet(sprintf('/v3/domains/%s/webhooks/%s', $domain, $webhook)); |
41
|
|
|
|
42
|
|
|
return $this->deserializer->deserialize($response, ShowResponse::class); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $domain |
47
|
|
|
* @param string $id |
48
|
|
|
* @param string $url |
49
|
|
|
* |
50
|
|
|
* @return CreateResponse |
51
|
|
|
*/ |
52
|
|
View Code Duplication |
public function create($domain, $id, $url) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
Assert::notEmpty($domain); |
55
|
|
|
Assert::notEmpty($id); |
56
|
|
|
Assert::notEmpty($url); |
57
|
|
|
|
58
|
|
|
$params = [ |
59
|
|
|
'id' => $id, |
60
|
|
|
'url' => $url, |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
$response = $this->httpPost(sprintf('/v3/domains/%s/webhooks', $domain), $params); |
64
|
|
|
|
65
|
|
|
return $this->deserializer->deserialize($response, CreateResponse::class); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $domain |
70
|
|
|
* @param string $id |
71
|
|
|
* @param string $url |
72
|
|
|
* |
73
|
|
|
* @return UpdateResponse |
74
|
|
|
*/ |
75
|
|
|
public function update($domain, $id, $url) |
76
|
|
|
{ |
77
|
|
|
Assert::notEmpty($domain); |
78
|
|
|
Assert::notEmpty($id); |
79
|
|
|
Assert::notEmpty($url); |
80
|
|
|
|
81
|
|
|
$params = [ |
82
|
|
|
'url' => $url, |
83
|
|
|
]; |
84
|
|
|
|
85
|
|
|
$response = $this->httpPut(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id), $params); |
86
|
|
|
|
87
|
|
|
return $this->deserializer->deserialize($response, UpdateResponse::class); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string $domain |
92
|
|
|
* @param string $id |
93
|
|
|
* |
94
|
|
|
* @return DeleteResponse |
95
|
|
|
*/ |
96
|
|
View Code Duplication |
public function delete($domain, $id) |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
Assert::notEmpty($domain); |
99
|
|
|
Assert::notEmpty($id); |
100
|
|
|
|
101
|
|
|
$response = $this->httpDelete(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id)); |
102
|
|
|
|
103
|
|
|
return $this->deserializer->deserialize($response, DeleteResponse::class); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.