# Change the timedelta's to be in the range you want date_from = (datetime.now() + timedelta(days=1)).strftime( '%d/%m/%Y') # starting date, currently set to tomorrow date_to = (datetime.now() + timedelta(days=180)).strftime( '%d/%m/%Y') # end date, currently set to 6 months from today flight_search = FlightSearch() data_manager = DataManager() notification_manager = NotificationManager() sheet_data = data_manager.retrieve_data( False) # Change to True to use an API call - only 200 a month though data_manager.update_destination_code(sheet_data) for city in sheet_data: fly_to = city['iataCode'] flight_data = flight_search.check_flights(fly_from, fly_to, date_from, date_to) try: if city['lowestPrice'] > flight_data.price: print( f'{flight_data.destination_city} new deal is lower: {flight_data.price}' ) notification_manager.send_alert(flight_data) except AttributeError: pass # can print an error message here if wanted - it comes up if there is nothing to compare with no flights print('Done') # The program does not always have an output, so may want to print more lines for debugging, but I commented them out # for less clutter. At this stage, I thought just this one statement would be fine, but add back in if needed or wanted
#This file will need to use the DataManager,FlightSearch, FlightData, NotificationManager classes to achieve the program requirements. from notification_manager import NotificationManager from flight_search import FlightSearch from flight_data import FlightData from data_manager import DataManager notification_manager = NotificationManager() flight_search = FlightSearch() flight_data = FlightData() data_manger = DataManager() destination_list = data_manger.get_data() for city in destination_list: city_id = city['id'] lowest_price = city['lowestPrice'] fly_to = city['iataCode'] price_data = flight_search.get_data(fly_to) is_cheap_deal = flight_data.compare(price_data, lowest_price) if is_cheap_deal: flight_details = flight_data.get_data() data_manger.update_data(city_id, flight_data.min_price) notification_manager.send_alert(flight_details)
#This file will need to use the DataManager,FlightSearch, FlightData, NotificationManager classes to achieve the program requirements. from notification_manager import NotificationManager from flight_search import FlightSearch from flight_data import FlightData from data_manager import DataManager notification_manager = NotificationManager() flight_search = FlightSearch() flight_data = FlightData() data_manger = DataManager() user_list = data_manger.get_users() destination_list = data_manger.get_data() for city in destination_list: city_id = city['id'] lowest_price = city['lowestPrice'] fly_to = city['iataCode'] price_data = flight_search.get_data(fly_to) # Check if no flights available if not price_data: continue is_cheap_deal = flight_data.compare(price_data, lowest_price) if is_cheap_deal: flight_details = flight_data.get_data() data_manger.update_data(city_id, flight_data.min_price) notification_manager.send_alert(flight_details, user_list)