-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_calls.py
51 lines (39 loc) · 1.05 KB
/
api_calls.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import requests
import json
BASE_URL = "https://api.sci-all.icu/api/v1"
def publish(payload):
url = f"{BASE_URL}/social/publications"
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
return {
"status": "success",
"data": response.json()
}
else:
return {
"status": "error",
"data": response.json()
}
def login(phone_number, password):
url = f"{BASE_URL}/auth/user/login"
payload = json.dumps({
"phoneNumber": phone_number,
"password": password
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
if response.status_code == 200:
return {
"status": "success",
"data": response.json()
}
else:
return {
"status": "error",
"data": response.json()
}