forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotification.php
More file actions
60 lines (52 loc) · 1.57 KB
/
Copy pathNotification.php
File metadata and controls
60 lines (52 loc) · 1.57 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
<?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
*
* @return array array of notifications
*/
public function all($includingRead = false, $participating = false, DateTime $since = null)
{
$parameters = array(
'all' => $includingRead,
'participating' => $participating
);
if($since !== null) {
$parameters['since'] = $since->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 = array();
if($since !== null) {
$parameters['last_read_at'] = $since->format(DateTime::ISO8601);
}
$this->put('notifications', $parameters);
}
}