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\Api; |
11
|
|
|
|
12
|
|
|
use Mailgun\Assert; |
13
|
|
|
use Mailgun\Resource\Api\Suppressions\Complaint\CreateResponse; |
14
|
|
|
use Mailgun\Resource\Api\Suppressions\Complaint\DeleteResponse; |
15
|
|
|
use Mailgun\Resource\Api\Suppressions\Complaint\IndexResponse; |
16
|
|
|
use Mailgun\Resource\Api\Suppressions\Complaint\ShowResponse; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @see https://documentation.mailgun.com/api-suppressions.html#complaints |
20
|
|
|
* |
21
|
|
|
* @author Sean Johnson <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Complaint extends HttpApi |
24
|
|
|
{ |
25
|
|
|
use Pagination; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param string $domain Domain to get complaints for |
29
|
|
|
* @param int $limit optional |
30
|
|
|
* |
31
|
|
|
* @return IndexResponse |
32
|
|
|
*/ |
33
|
|
|
public function index($domain, $limit = 100) |
34
|
|
|
{ |
35
|
|
|
Assert::stringNotEmpty($domain); |
36
|
|
|
Assert::range($limit, 1, 10000, 'Limit parameter must be between 1 and 10000'); |
37
|
|
|
|
38
|
|
|
$params = [ |
39
|
|
|
'limit' => $limit, |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
$response = $this->httpGet(sprintf('/v3/%s/complaints', $domain), $params); |
43
|
|
|
|
44
|
|
|
return $this->safeDeserialize($response, IndexResponse::class); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $domain Domain to show complaint for |
49
|
|
|
* @param string $address Complaint address |
50
|
|
|
* |
51
|
|
|
* @return ShowResponse |
52
|
|
|
*/ |
53
|
|
|
public function show($domain, $address) |
54
|
|
|
{ |
55
|
|
|
Assert::stringNotEmpty($domain); |
56
|
|
|
Assert::stringNotEmpty($address); |
57
|
|
|
$response = $this->httpGet(sprintf('/v3/%s/complaints/%s', $domain, $address)); |
58
|
|
|
|
59
|
|
|
return $this->safeDeserialize($response, ShowResponse::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $domain Domain to create complaint for |
64
|
|
|
* @param string $address Complaint address |
65
|
|
|
* @param array $params optional |
|
|
|
|
66
|
|
|
* |
67
|
|
|
* @return CreateResponse |
68
|
|
|
*/ |
69
|
|
|
public function create($domain, $address, $code = null, $error = null, $createdAt = null) |
|
|
|
|
70
|
|
|
{ |
71
|
|
|
Assert::stringNotEmpty($domain); |
72
|
|
|
Assert::stringNotEmpty($address); |
73
|
|
|
|
74
|
|
|
$params['address'] = $address; |
|
|
|
|
75
|
|
|
|
76
|
|
|
$response = $this->httpPost(sprintf('/v3/%s/complaints', $domain), $params); |
77
|
|
|
|
78
|
|
|
return $this->safeDeserialize($response, CreateResponse::class); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param string $domain Domain to delete complaint for |
83
|
|
|
* @param string $address Complaint address |
84
|
|
|
* |
85
|
|
|
* @return DeleteResponse |
86
|
|
|
*/ |
87
|
|
|
public function delete($domain, $address) |
88
|
|
|
{ |
89
|
|
|
Assert::stringNotEmpty($domain); |
90
|
|
|
Assert::stringNotEmpty($address); |
91
|
|
|
|
92
|
|
|
$response = $this->httpDelete(sprintf('/v3/%s/complaints/%s', $domain, $address)); |
93
|
|
|
|
94
|
|
|
return $this->safeDeserialize($response, DeleteResponse::class); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param string $domain Domain to delete all bounces for |
99
|
|
|
* |
100
|
|
|
* @return DeleteResponse |
101
|
|
|
*/ |
102
|
|
|
public function deleteAll($domain) |
103
|
|
|
{ |
104
|
|
|
Assert::stringNotEmpty($domain); |
105
|
|
|
|
106
|
|
|
$response = $this->httpDelete(sprintf('/v3/%s/complaints', $domain)); |
107
|
|
|
|
108
|
|
|
return $this->safeDeserialize($response, DeleteResponse::class); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.