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
|
|
|
|