-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_manager.py
58 lines (44 loc) · 2.02 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import requests
# -------------------------------------GOOGLE SHEET END POINT (DO NOT TOUCH THIS CODE)---------------------------------#
SHEETY_PRICE_END_POINT = "........................................."
# ------------------add_destination_dat() ADMIN--TESTING PURPOSE (UPDATE FLIGHT DATA)----------------------------------#
CITY = "LA"
IATA_CODE = "TESTING"
PRICE = "110"
# ----------------------------------------------------DATA MANAGER CODE------------------------------------------------#
class DataManager:
# This class is responsible for talking to the Google Sheet.
def __init__(self):
self.destination_data = {}
# ----------TESTING PURPOSE--------#
# self.google_sheet_data()
# self.add_iata_code()
# print(self.destination_data)
# self.add_destination_name()
def google_sheet_data(self):
fly_to = requests.get(url=SHEETY_PRICE_END_POINT)
sheet_response = fly_to.json()
self.destination_data = sheet_response['prices']
return self.destination_data
def add_iata_code(self):
for city in self.destination_data:
iata_data = {
"price":
{"iataCode": city["iataCode"],
}
}
response = requests.put(url=f"{SHEETY_PRICE_END_POINT}/{city['id']}", json=iata_data)
print(response)
# -------------------------------------------------ADDITIONAL CODE(NOT IN USE)-------------------------------------#
def add_destination_name(self):
iata_data = {
"price":
{"city": CITY,
"iataCode": IATA_CODE,
"lowestPrice": PRICE,
}
}
requests.post(f"{SHEETY_PRICE_END_POINT}", json=iata_data)
# ----------------------------------------------CALLING CLASS ( TESTING)----------------------------------------------#
# data = DataManager()
# --------------------------------------------------END----------------------------------------------------------------#