Implemented the basics versions of createApplication and deleteApplication
Both seem to be working, need to run more tests though
This commit is contained in:
parent
8cfe2a0092
commit
858c7fbe70
41
gotipy.py
41
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user