forked from epicrunze/HCChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.py
35 lines (29 loc) · 1.02 KB
/
webhook.py
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
import httphelper
def addWebhook(hook:str,auth:str)->str:
url = "https://api-prod.hypercare.com/graphql/private"
payload = "{\"query\":\"mutation RegisterWebhook($url: String!) {\\n"+\
" self {\\n"+\
" registerWebhook(url: $url) {\\n"+\
" url\\n"+\
" createdAt\\n"+\
" updatedAt\\n"+\
" }\\n"+\
" }\\n"+\
"}\",\"variables\":{\"url\":\""+hook+"\"}}"
headers = {
'Content-Type': 'application/json',
'Authorization':'Bearer '+auth
}
return httphelper.post(url,headers,payload).text.encode('utf8')
def removeWebhook(auth)->str:
url = "https://api-prod.hypercare.com/graphql/private"
payload = "{\"query\":\"mutation UnregisterWebhook {\\n"+\
" self {\\n"+\
" unregisterWebhook\\n"+\
" }\\n"+\
"}\",\"variables\":{}}"
headers = {
'Content-Type': 'application/json',
'Authorization':'Bearer '+auth
}
return httphelper.post(url,headers,payload).text.encode('utf8')