Code Duplication    Length = 89-89 lines in 2 locations

src/Mailgun/Api/Suppression/Bounce.php 1 location

@@ 25-113 (lines=89) @@
22
 *
23
 * @author Sean Johnson <[email protected]>
24
 */
25
class Bounce extends HttpApi
26
{
27
    use Pagination;
28
29
    /**
30
     * @param string $domain Domain to list bounces 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/bounces', $domain), $params);
45
46
        return $this->hydrateResponse($response, IndexResponse::class);
47
    }
48
49
    /**
50
     * @param string $domain  Domain to show bounce from
51
     * @param string $address Bounce address to show
52
     *
53
     * @return ShowResponse
54
     */
55
    public function show($domain, $address)
56
    {
57
        Assert::stringNotEmpty($domain);
58
        Assert::stringNotEmpty($address);
59
60
        $response = $this->httpGet(sprintf('/v3/%s/bounces/%s', $domain, $address));
61
62
        return $this->hydrateResponse($response, ShowResponse::class);
63
    }
64
65
    /**
66
     * @param string $domain  Domain to create a bounce for
67
     * @param string $address Address to create a bounce for
68
     * @param array  $params  optional
69
     *
70
     * @return CreateResponse
71
     */
72
    public function create($domain, $address, array $params = [])
73
    {
74
        Assert::stringNotEmpty($domain);
75
        Assert::stringNotEmpty($address);
76
77
        $params['address'] = $address;
78
79
        $response = $this->httpPost(sprintf('/v3/%s/bounces', $domain), $params);
80
81
        return $this->hydrateResponse($response, CreateResponse::class);
82
    }
83
84
    /**
85
     * @param string $domain  Domain to delete a bounce for
86
     * @param string $address Bounce address to delete
87
     *
88
     * @return DeleteResponse
89
     */
90
    public function delete($domain, $address)
91
    {
92
        Assert::stringNotEmpty($domain);
93
        Assert::stringNotEmpty($address);
94
95
        $response = $this->httpDelete(sprintf('/v3/%s/bounces/%s', $domain, $address));
96
97
        return $this->hydrateResponse($response, DeleteResponse::class);
98
    }
99
100
    /**
101
     * @param string $domain Domain to delete all bounces for
102
     *
103
     * @return DeleteResponse
104
     */
105
    public function deleteAll($domain)
106
    {
107
        Assert::stringNotEmpty($domain);
108
109
        $response = $this->httpDelete(sprintf('/v3/%s/bounces', $domain));
110
111
        return $this->hydrateResponse($response, DeleteResponse::class);
112
    }
113
}
114

src/Mailgun/Api/Suppression/Unsubscribe.php 1 location

@@ 25-113 (lines=89) @@
22
 *
23
 * @author Sean Johnson <[email protected]>
24
 */
25
class Unsubscribe extends HttpApi
26
{
27
    use Pagination;
28
29
    /**
30
     * @param string $domain Domain to get unsubscribes 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/unsubscribes', $domain), $params);
45
46
        return $this->hydrateResponse($response, IndexResponse::class);
47
    }
48
49
    /**
50
     * @param string $domain  Domain to show unsubscribe for
51
     * @param string $address Unsubscribe address
52
     *
53
     * @return ShowResponse
54
     */
55
    public function show($domain, $address)
56
    {
57
        Assert::stringNotEmpty($domain);
58
        Assert::stringNotEmpty($address);
59
60
        $response = $this->httpGet(sprintf('/v3/%s/unsubscribes/%s', $domain, $address));
61
62
        return $this->hydrateResponse($response, ShowResponse::class);
63
    }
64
65
    /**
66
     * @param string $domain  Domain to create unsubscribe for
67
     * @param string $address Unsubscribe address
68
     * @param array  $params  optional
69
     *
70
     * @return CreateResponse
71
     */
72
    public function create($domain, $address, array $params = [])
73
    {
74
        Assert::stringNotEmpty($domain);
75
        Assert::stringNotEmpty($address);
76
77
        $params['address'] = $address;
78
79
        $response = $this->httpPost(sprintf('/v3/%s/unsubscribes', $domain), $params);
80
81
        return $this->hydrateResponse($response, CreateResponse::class);
82
    }
83
84
    /**
85
     * @param string $domain  Domain to delete unsubscribe for
86
     * @param string $address Unsubscribe address
87
     *
88
     * @return DeleteResponse
89
     */
90
    public function delete($domain, $address)
91
    {
92
        Assert::stringNotEmpty($domain);
93
        Assert::stringNotEmpty($address);
94
95
        $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes/%s', $domain, $address));
96
97
        return $this->hydrateResponse($response, DeleteResponse::class);
98
    }
99
100
    /**
101
     * @param string $domain Domain to delete all unsubscribes for
102
     *
103
     * @return DeleteResponse
104
     */
105
    public function deleteAll($domain)
106
    {
107
        Assert::stringNotEmpty($domain);
108
109
        $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes', $domain));
110
111
        return $this->hydrateResponse($response, DeleteResponse::class);
112
    }
113
}
114