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