From: Marek Marecki Date: Fri, 29 Mar 2013 10:37:09 +0000 (+0100) Subject: get_stream() and get_notifications() refactored to use _sessionget() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=af4eb01a0de56b326cc084071fb3fd23e9f3f6ca;p=diaspy.git get_stream() and get_notifications() refactored to use _sessionget() --- diff --git a/diaspy/client.py b/diaspy/client.py index e219bd0..d7f036b 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -150,31 +150,26 @@ class Client: """This functions returns a list of posts found in the stream. :returns: list -- list of Post objects. - """ data = {'authenticity_token': self.get_token()} - r = self.session.get('{0}/stream.json'.format(self.pod)) + r = self._sessionget('stream.json') - if r.status_code != 200: + if r.status_code != 200: raise Exception('wrong status code: {0}'.format(r.status_code)) stream = r.json() - posts = [ diaspy.models.Post(str(post['id']), self) for post in stream ] - - return posts + return [ diaspy.models.Post(str(post['id']), self) for post in stream ] def get_notifications(self): """This functions returns a list of notifications. :returns: list -- list of json formatted notifications - """ - data = {'authenticity_token': self.get_token()} - r = self.session.get('{0}/notifications.json'.format(self.pod)) + r = self._sessionget('notifications.json') - if r.status_code != 200: + if r.status_code != 200: raise Exception('wrong status code: {0}'.format(r.status_code)) notifications = r.json()