Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions libsaas/services/github/notifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from libsaas import http, parsers
from libsaas.services import base

from . import resource


class Notifications(resource.GitHubResource):

path = 'notifications'

@base.apimethod
def get(self, reason=None, unread=True):
"""
For details on the meanings and allowed values for each parameter, see
http://developer.github.com/v3/activity/notifications/
"""
url = self.get_url()
params = base.get_params(
('all', 'participating', 'since', 'page', 'per_page'), locals())

headers = resource.mimetype_accept(format)

return http.Request('GET', url, params, headers), parsers.parse_json

# TODO Repo specific notifications
# TODO Mark as read
# TODO Threading/ Subscriptions
11 changes: 10 additions & 1 deletion libsaas/services/github/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from libsaas.filters import auth
from libsaas.services import base

from . import authorizations, gists, issues, repos, users
from . import authorizations, gists, issues, notifications, repos, users


class GitHub(base.Resource):
Expand Down Expand Up @@ -80,6 +80,15 @@ def issues(self):
"""
return issues.Issues(self)

@base.resource(notifications.Notifications)
def notifications(self):
"""
Return the resource corresponding to all the notifications of the
authenticated user.
"""
return notifications.Notifications(self)


@base.resource(repos.Repo)
def repo(self, user, repo):
"""
Expand Down
6 changes: 6 additions & 0 deletions test/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ def test_authorizations(self):
self.service.authorization(1).delete()
self.expect('DELETE', '/authorizations/1')

def test_notifications(self):
self.service.notifications().get()
self.expect('GET', '/notifications')
# TODO : The rest of the notificatons API


def test_unicode(self):
# try an unicode name
self.service.repo('myuser', b'\xce\xbb'.decode('utf-8')).get()
Expand Down