-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.py
More file actions
45 lines (29 loc) · 1.06 KB
/
handlers.py
File metadata and controls
45 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import requests
SERVER_IP_PATH = os.getenv('SERVER_IP_PATH')
def _get_events():
req = requests.get(f'{SERVER_IP_PATH}/events')
return req.json()
def _post_events(data):
req = requests.post(f'{SERVER_IP_PATH}/events', json=data)
return req.status_code
def get_user_subscriptions(user_id):
req = requests.get(f'{SERVER_IP_PATH}/users/{user_id}/subscriptions')
return req.json()
def subscribe_user(user_id, event):
req = requests.post(f'{SERVER_IP_PATH}/users/{user_id}/subscriptions',
json={'event': event})
return req.status_code
def unsubscribe_user(user_id, event):
req = requests.delete(
f'{SERVER_IP_PATH}/users/{user_id}/subscriptions',
json={'event': event})
return req.status_code
def get_dashboard_users(d_id):
req = requests.get(
f'{SERVER_IP_PATH}/dashboards/{d_id}/users')
return req.json()
def get_event_subscribers(event_id, event):
req = requests.get(
f'{SERVER_IP_PATH}/events/{event_id}/subscribers?query={event}')
return req.json()