Completed
Pull Request — master (#245)
by Tobias
07:56
created

Event   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 57
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 1
A getPaginationNext() 0 4 1
A getPaginationPrevious() 0 4 1
A getPaginationFirst() 0 4 1
A getPaginationLast() 0 4 1
1
<?php
2
3
namespace Mailgun\Api;
4
5
use Mailgun\Assert;
6
use Mailgun\Resource\Api\Event\EventResponse;
7
8
/**
9
 * {@link https://documentation.mailgun.com/api-events.html}
10
 *
11
 * @author Tobias Nyholm <[email protected]>
12
 */
13
class Event extends HttpApi
14
{
15
    use Pagination;
16
17
    /**
18
     * @param string $domain
19
     * @param array $params
20
     *
21
     * @return EventResponse
22
     */
23
    public function get($domain, array $params = [])
24
    {
25
        Assert::stringNotEmpty($domain);
26
27
        $response = $this->httpGet(sprintf('/v3/%s/events', $domain), $params);
28
29
        return $this->safeDeserialize($response, EventResponse::class);
30
    }
31
32
    /**
33
     * @param EventResponse $eventResponse
34
     *
35
     * @return EventResponse|null
36
     */
37
    public function getPaginationNext(EventResponse $eventResponse)
38
    {
39
        return $this->getPaginationUrl($eventResponse->getNextUrl(), EventResponse::class);
40
    }
41
42
    /**
43
     * @param EventResponse $eventResponse
44
     *
45
     * @return EventResponse|null
46
     */
47
    public function getPaginationPrevious(EventResponse $eventResponse)
48
    {
49
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
50
    }
51
    /**
52
     * @param EventResponse $eventResponse
53
     *
54
     * @return EventResponse|null
55
     */
56
    public function getPaginationFirst(EventResponse $eventResponse)
57
    {
58
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
59
    }
60
    /**
61
     * @param EventResponse $eventResponse
62
     *
63
     * @return EventResponse|null
64
     */
65
    public function getPaginationLast(EventResponse $eventResponse)
66
    {
67
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
68
    }
69
}
70