forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification.php
More file actions
91 lines (80 loc) · 2.31 KB
/
Copy pathNotification.php
File metadata and controls
91 lines (80 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace Github\Api;
use DateTime;
/**
* API for accessing Notifications from your Git/Github repositories.
*
* Important! You have to be authenticated to perform these methods
*
* @link https://developer.github.com/v3/activity/notifications/
*
* @author Dennis de Greef <github@link0.net>
*/
class Notification extends AbstractApi
{
/**
* Get a listing of notifications.
*
* @link https://developer.github.com/v3/activity/notifications/
*
* @param bool $includingRead
* @param bool $participating
* @param DateTime|null $since
* @param DateTime|null $before
*
* @return array array of notifications
*/
public function all($includingRead = false, $participating = false, ?DateTime $since = null, ?DateTime $before = null)
{
$parameters = [
'all' => $includingRead,
'participating' => $participating,
];
if ($since !== null) {
$parameters['since'] = $since->format(DateTime::ISO8601);
}
if ($before !== null) {
$parameters['before'] = $before->format(DateTime::ISO8601);
}
return $this->get('/notifications', $parameters);
}
/**
* Marks all notifications as read from the current date.
*
* Optionally give DateTime to mark as read before that date.
*
* @link https://developer.github.com/v3/activity/notifications/#mark-as-read
*
* @param DateTime|null $since
*/
public function markRead(?DateTime $since = null)
{
$parameters = [];
if ($since !== null) {
$parameters['last_read_at'] = $since->format(DateTime::ISO8601);
}
$this->put('/notifications', $parameters);
}
/**
* Mark a single thread as read using its ID.
*
* @link https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
*
* @param int $id
*/
public function markThreadRead($id)
{
$this->patch('/notifications/threads/'.$id);
}
/**
* Gets a single thread using its ID.
*
* @link https://developer.github.com/v3/activity/notifications/#view-a-single-thread
*
* @param int $id
*/
public function id($id)
{
return $this->get('/notifications/threads/'.$id);
}
}