Completed
Pull Request — master (#245)
by Tobias
17:36 queued 07:28
created

Event::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
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\Event\EventResponse;
14
15
/**
16
 * {@link https://documentation.mailgun.com/api-events.html}.
17
 *
18
 * @author Tobias Nyholm <[email protected]>
19
 */
20
class Event extends HttpApi
21
{
22
    use Pagination;
23
24
    /**
25
     * @param string $domain
26
     * @param array  $params
27
     *
28
     * @return EventResponse
29
     */
30
    public function get($domain, array $params = [])
31
    {
32
        Assert::stringNotEmpty($domain);
33
34
        $response = $this->httpGet(sprintf('/v3/%s/events', $domain), $params);
35
36
        return $this->safeDeserialize($response, EventResponse::class);
37
    }
38
39
    /**
40
     * @param EventResponse $eventResponse
41
     *
42
     * @return EventResponse|null
43
     */
44
    public function getPaginationNext(EventResponse $eventResponse)
45
    {
46
        return $this->getPaginationUrl($eventResponse->getNextUrl(), EventResponse::class);
47
    }
48
49
    /**
50
     * @param EventResponse $eventResponse
51
     *
52
     * @return EventResponse|null
53
     */
54
    public function getPaginationPrevious(EventResponse $eventResponse)
55
    {
56
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
57
    }
58
59
    /**
60
     * @param EventResponse $eventResponse
61
     *
62
     * @return EventResponse|null
63
     */
64
    public function getPaginationFirst(EventResponse $eventResponse)
65
    {
66
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
67
    }
68
69
    /**
70
     * @param EventResponse $eventResponse
71
     *
72
     * @return EventResponse|null
73
     */
74
    public function getPaginationLast(EventResponse $eventResponse)
75
    {
76
        return $this->getPaginationUrl($eventResponse->getPreviousUrl(), EventResponse::class);
77
    }
78
}
79