adds firebase handler, extracts set functions

This commit is contained in:
Raphael Maenle 2021-12-30 16:10:49 +01:00
parent 3d3633592a
commit 7f3ffbc906

23
main.py
View File

@ -115,15 +115,17 @@ class Bump:
def push(self, data): def push(self, data):
url = self.URL + "push"
params = { params = {
'sender': self.get_sender(), 'sender': self.get_sender(),
'data': self.encrypt(data) 'data': self.encrypt(data)
} }
return self.set_post("push", params)
print(url) def firebase(self):
r = requests.post(url, params) params = {
print(r.json()) 'token': "HIJKLMNOPQRSTUVWXYZ"
}
return self.set_post("firebase", params)
def peek(self): def peek(self):
@ -138,9 +140,22 @@ class Bump:
} }
return self.get_post("list", params) return self.get_post("list", params)
def clear(self): def clear(self):
return self.get_post("clear") return self.get_post("clear")
def set_post(self, mechanism, add_params = None):
url = self.URL + mechanism
params = {
'sender': self.get_sender(),
}
if add_params != None:
params.update(add_params)
messages = requests.post(url, params).json()
print(messages)
def get_post(self, mechanism, add_params = None): def get_post(self, mechanism, add_params = None):
url = self.URL + mechanism url = self.URL + mechanism