-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_manager.py
36 lines (29 loc) · 1.13 KB
/
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
import requests
SHEETY_PRICES_ENDPOINT ="https://api.sheety.co/7c6b742fb38c0b79b8913452912f2814/flightDeals/prices"
SHEETY_USERS_ENDPOINT = "https://api.sheety.co/7c6b742fb38c0b79b8913452912f2814/flightDeals/users"
class DataManager:
def __init__(self):
self.destination_data = {}
def get_destination_data(self):
response = requests.get(url=SHEETY_PRICES_ENDPOINT)
data = response.json()
self.destination_data = data["prices"]
return self.destination_data
def update_destination_codes(self):
for city in self.destination_data:
new_data = {
"price": {
"iataCode": city["iataCode"]
}
}
response = requests.put(
url=f"{SHEETY_PRICES_ENDPOINT}/{city['id']}",
json=new_data
)
print(response.text)
def get_customer_emails(self):
customers_endpoint = SHEETY_USERS_ENDPOINT
response = requests.get(url=customers_endpoint)
data = response.json()
self.customer_data = data["users"]
return self.customer_data