From 858c7fbe70e8b09afe69793fdb580b38f61eb0f7 Mon Sep 17 00:00:00 2001 From: benjamyn Date: Sat, 10 Nov 2018 18:27:50 +1100 Subject: [PATCH] Implemented the basics versions of createApplication and deleteApplication Both seem to be working, need to run more tests though --- gotipy.py | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/gotipy.py b/gotipy.py index c36b3f1..65dcd95 100644 --- a/gotipy.py +++ b/gotipy.py @@ -7,7 +7,38 @@ class gotipy(object): self.token = token self.url = url self.headers = {'X-Gotify-Key' : self.token} + +## Token Functions + def getApplications(self): + self.requrl = self.url + '/application' + req = requests.get(self.requrl, headers=self.headers) + try: + return req.json()['error'] + except: + return req.json() + + def createApplication(self, name, description): + self.name = name + self.description = description + self.requrl = self.url + '/application' + + data = {} + data["name"] = self.name + data["description"] = self.description + + req = requests.post(self.requrl, headers=self.headers, json=data) + pprint(req) + return req + + def deleteApplication(self, id): + self.id = id + self.requrl = self.url + '/application/' + self.id + + req = requests.delete(self.requrl, headers=self.headers) + return req + +## Message Functions def sendMessage(self, title, message): self.title = title self.message = message @@ -23,11 +54,5 @@ class gotipy(object): return req.json()['error'] except: return "Message Sent :)" - def getApplications(self): - self.requrl = self.url + '/application' - - req = requests.get(self.requrl, headers=self.headers) - try: - return req.json()['error'] - except: - return req.json() + +## User Functions