-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_manager.py
37 lines (29 loc) · 913 Bytes
/
data_manager.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
import requests
SHEET_END = "_YOUR_SHEETY_END_POINT_"
USER_END = "_YOUR_SHEETY_END_POINT_"
# get sheety
class DataManager:
def __init__(self):
self.sheet_data = {}
def get_data(self):
response = requests.get(url=SHEET_END)
data = response.json()
self.sheet_data = data["sheet1"]
return self.sheet_data
def update_codes(self):
for city in self.sheet_data:
new_code = {
"sheet1": {
"iataCode": city["iataCode"]
}
}
response = requests.put(
url=f"{SHEET_END}/{city['id']}",
json=new_code,
)
print(response.text)
def get_user(self):
response = requests.get(url=USER_END)
confirmed_users = response.json()
self.user_data = confirmed_users["users"]
return self.user_data