-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_manager.py
37 lines (30 loc) · 1.15 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
37
from pprint import pprint
import requests
SHEETY_PRICES_ENDPOINT = "https://api.sheety.co/80c8d6c6798e3fc49cf7d87c70688b78/flightDeals/prices"
SHEET_USERS_ENDPOINT = "https://api.sheety.co/80c8d6c6798e3fc49cf7d87c70688b78/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 = SHEET_USERS_ENDPOINT
response = requests.get(customers_endpoint)
data = response.json()
self.customer_data = data["users"]
return self.customer_data