get_stream() and get_notifications() refactored to use _sessionget()
authorMarek Marecki <triviuss@gmail.com>
Fri, 29 Mar 2013 10:37:09 +0000 (11:37 +0100)
committerMarek Marecki <triviuss@gmail.com>
Fri, 29 Mar 2013 10:37:09 +0000 (11:37 +0100)
diaspy/client.py

index e219bd0e698374f90afbb2a0526d6575d9cc62ea..d7f036b61e3bddcce42821947c41de249d6718b9 100644 (file)
@@ -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()