Mark notification as read (#932)

Wraps the parts of the notification API that allows the user to mark notifications as read.
New methods are : 
 
- Notification.mark_as_read : marks a single notification thread as read
- Repository.mark_notifications_as_read : marks all the notifications for a given repository as read
- AuthenticatedUser.mark_notifications_as_read : marks all the notifications as read

Aims to fix : https://github.com/PyGithub/PyGithub/issues/571 and simply uses the APIs described on this page : https://developer.github.com/enterprise/11.10.340/v3/activity/notifications/

A weird thing I noticed doing this is that Repository.notifications_url doesn't seem to be usable directly. I used Repository.url + "/notifications" instead.
This commit is contained in:
Alice GIRARD
2018-10-19 07:24:45 +08:00
committed by Wan Liuyang
parent 2b2ecfad4d
commit 0a10d7cdf0
12 changed files with 166 additions and 0 deletions
+9
View File
@@ -115,6 +115,15 @@ class Notification(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._url)
return self._url.value
def mark_as_read(self):
"""
:calls: `PATCH /notifications/threads/:id <https://developer.github.com/v3/activity/notifications/>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
)
def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._last_read_at = github.GithubObject.NotSet