Add function to add and remove comments
authorMoritz Kiefer <moritz.kiefer@gmail.com>
Thu, 17 Jan 2013 16:02:29 +0000 (17:02 +0100)
committerMoritz Kiefer <moritz.kiefer@gmail.com>
Thu, 17 Jan 2013 16:02:29 +0000 (17:02 +0100)
diaspy.py

index cfbba38053212099fcb00f42093c5e4ea785a9a0..da8494f42e28ee48bfd4fdb9384b99ba12cb19b7 100644 (file)
--- a/diaspy.py
+++ b/diaspy.py
@@ -123,4 +123,37 @@ class Client:
                 'authenticity_token': self._get_token()}
 
         r = self._session.post(self._pod + "/reshares", data=data)
-        print(r.text)
+
+    def comment(self, post_id, text):
+        """This function comments on a post
+
+        :param post_id: id of the post to comment on.
+        :type post_id: str
+        :param text: text to comment.
+        :type text: str
+
+        """
+
+        data = {'text': text,
+                'authenticity_token': self._get_token()}
+
+        r = self._session.post(self._pod + "/posts/" + post_id + "/comments", data=data)
+
+        return r.json()
+    
+    def rmcomment(self, post_id, comment_id):
+        """This function removes a comment from a post
+
+        :param post_id: id of the post to remove the like from.
+        :type post_id: str
+        :param like_id: id of the like to remove.
+        :type like_id: str
+
+        """
+
+        data = {'authenticity_token': self._get_token()}
+
+        r = self._session.delete(self._pod + "/posts/" + 
+                                 post_id + "/comments/" +
+                                 comment_id,
+                                 data=data)