diff --git a/doc/notification.md b/doc/notification.md index b47c1d5f7c3..ad022cad835 100644 --- a/doc/notification.md +++ b/doc/notification.md @@ -37,9 +37,18 @@ $client->api('notification')->markRead(new DateTime('2015/01/01')); Marks all notifications as read up until the current date, unless a date is given -## Get a single notification using his ID +### Mark a thread as read using its ID + +```php +$client->api('notification')->markThreadRead($id); +``` + +Marks a single thread as read using its ID. + +### Get a single thread using its ID ```php $client->api('notification')->id($id); ``` -Retrieves single notification data using his ID. + +Retrieves single thread's data using its ID. diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php index fbaed083518..1759f26132c 100644 --- a/lib/Github/Api/Notification.php +++ b/lib/Github/Api/Notification.php @@ -41,7 +41,8 @@ public function all($includingRead = false, $participating = false, DateTime $si } /** - * Marks all notifications as read from the current date + * 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 @@ -60,7 +61,19 @@ public function markRead(DateTime $since = null) } /** - * Gets a single notification using his ID. + * 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 * diff --git a/test/Github/Tests/Api/NotificationTest.php b/test/Github/Tests/Api/NotificationTest.php index 5cbf7fabc11..e34dc171ced 100644 --- a/test/Github/Tests/Api/NotificationTest.php +++ b/test/Github/Tests/Api/NotificationTest.php @@ -97,6 +97,20 @@ public function shouldMarkNotificationsAsReadForGivenDate() $api->markRead($since); } + /** + * @test + */ + public function shouldMarkThreadAsRead() + { + $id = mt_rand(1, time()); + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('patch') + ->with('/notifications/threads/'.$id); + + $api->markThreadRead($id); + } + public function shouldGetNotification() { $id = mt_rand(1, time());