Skip to content

Commit c05876c

Browse files
committed
update FlightSearch
1 parent c7c1f0f commit c05876c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

FlightDealsStart/data_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def get_flights_from_google_sheet(self) -> dict:
1919
print(f"Error in request: {err}")
2020

2121

22-
test = DataManager(api_key="")
22+
# test = DataManager(api_key="")
2323
print(test.get_flights_from_google_sheet())

FlightDealsStart/flight_search.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import requests
22

3+
34
class FlightSearch:
45
# This class is responsible for talking to the Flight Search API.
56
# https://tequila.kiwi.com/
67
# https://api.tequila.kiwi.com/v2/search?
78

8-
def __init__(self):
9-
pass
9+
def __init__(self, api_key: str):
10+
self.__API_URL = ""
11+
self.__HEADERS = {
12+
'Authorization': f'Basic {api_key}'
13+
}
14+
15+
def get_flight_price(self, info: dict) -> dict:
16+
try:
17+
response = requests.get(self.__API_URL, headers=self.__HEADERS)
18+
response.raise_for_status()
19+
data = response.json()
20+
return data
21+
except requests.exceptions.HTTPError as err:
22+
print(f"Error in request: {err}")

0 commit comments

Comments
 (0)