Skip to content

Commit e120be8

Browse files
authored
Create data_manager.py
1 parent 9332afc commit e120be8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

day39/data_manager.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import requests
2+
3+
SHEETY_PRICES_ENDPOINT = "https://api.sheety.co/*************************/flightDeals/prices/"
4+
5+
6+
class DataManager:
7+
8+
def __init__(self):
9+
self.destination_data = {}
10+
11+
def get_destination_data(self):
12+
response = requests.get(url=SHEETY_PRICES_ENDPOINT)
13+
data = response.json()
14+
self.destination_data = data["prices"]
15+
return self.destination_data
16+
17+
def update_destination_codes(self):
18+
for city in self.destination_data:
19+
new_data = {
20+
"price": {
21+
"iataCode": city["iataCode"]
22+
}
23+
}
24+
response = requests.put(
25+
url=f"{SHEETY_PRICES_ENDPOINT}/{city['id']}",
26+
json=new_data
27+
)
28+
print(response.text)

0 commit comments

Comments
 (0)