From af4eb01a0de56b326cc084071fb3fd23e9f3f6ca Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Fri, 29 Mar 2013 11:37:09 +0100 Subject: [PATCH] get_stream() and get_notifications() refactored to use _sessionget() --- diaspy/client.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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() -- 2.25.1