From 22cb1646c6c1e9f983b0c124ca029f71fceba04c Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Sun, 3 Feb 2013 00:01:10 +0100 Subject: [PATCH] Add functions to add and remove aspects --- diaspy/client.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/diaspy/client.py b/diaspy/client.py index 8aa7e0c..70af42f 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -221,3 +221,29 @@ class Client: raise Exception('wrong status code: ' + str(r.status_code)) return r.json() + + def add_aspect(self, aspect_name, visible=0): + """ This function adds a new aspect. + """ + + data = {'authenticity_token': self.get_token(), + 'aspect[name]': aspect_name, + 'aspect[contacts_visible]': visible} + + r = self.session.post(self.pod + '/aspects', + data=data) + + if r.status_code != 200: + raise Exception('wrong status code: ' + str(r.status_code)) + + def remove_aspect(self, aspect_id): + """ This function adds a new aspect. + """ + + data = {'authenticity_token': self.get_token()} + + r = self.session.delete(self.pod + '/aspects/' + aspect_id, + data=data} + + if r.status_code != 404: + raise Exception('wrong status code: ' + str(r.status_code)) -- 2.25.1