Skip to content

Commit f17c158

Browse files
GrahamCampbellacrobat
authored andcommitted
Added the ability to mark a single thread as read (#693)
* Added the ability to mark a single thread as read * Added test for markThreadRead * Fixed phpdoc * Updated notification docs
1 parent 44dc857 commit f17c158

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

doc/notification.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@ $client->api('notification')->markRead(new DateTime('2015/01/01'));
3737

3838
Marks all notifications as read up until the current date, unless a date is given
3939

40-
## Get a single notification using his ID
40+
### Mark a thread as read using its ID
41+
42+
```php
43+
$client->api('notification')->markThreadRead($id);
44+
```
45+
46+
Marks a single thread as read using its ID.
47+
48+
### Get a single thread using its ID
4149

4250
```php
4351
$client->api('notification')->id($id);
4452
```
45-
Retrieves single notification data using his ID.
53+
54+
Retrieves single thread's data using its ID.

lib/Github/Api/Notification.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public function all($includingRead = false, $participating = false, DateTime $si
4141
}
4242

4343
/**
44-
* Marks all notifications as read from the current date
44+
* Marks all notifications as read from the current date.
45+
*
4546
* Optionally give DateTime to mark as read before that date.
4647
*
4748
* @link https://developer.github.com/v3/activity/notifications/#mark-as-read
@@ -60,7 +61,19 @@ public function markRead(DateTime $since = null)
6061
}
6162

6263
/**
63-
* Gets a single notification using his ID.
64+
* Mark a single thread as read using its ID.
65+
*
66+
* @link https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
67+
*
68+
* @param int $id
69+
*/
70+
public function markThreadRead($id)
71+
{
72+
$this->patch('/notifications/threads/'.$id);
73+
}
74+
75+
/**
76+
* Gets a single thread using its ID.
6477
*
6578
* @link https://developer.github.com/v3/activity/notifications/#view-a-single-thread
6679
*

test/Github/Tests/Api/NotificationTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ public function shouldMarkNotificationsAsReadForGivenDate()
9797
$api->markRead($since);
9898
}
9999

100+
/**
101+
* @test
102+
*/
103+
public function shouldMarkThreadAsRead()
104+
{
105+
$id = mt_rand(1, time());
106+
$api = $this->getApiMock();
107+
$api->expects($this->once())
108+
->method('patch')
109+
->with('/notifications/threads/'.$id);
110+
111+
$api->markThreadRead($id);
112+
}
113+
100114
public function shouldGetNotification()
101115
{
102116
$id = mt_rand(1, time());

0 commit comments

Comments
 (0)