There are a lot of popular destinations that our customers will want to go to that don't have direct flights. e.g. London to Bali would have to be via, say, Singapore.


Requirements

If a direct flight is not found, search Amadeus one more time for that destination to see if there are indirect flights (flights with 1 stop or 2 stops) instead. Capture the cheapest flight price for a flight with a stopover.


Technical Specification

You'll need to modify the main.py, flight_search.py and the flight_data.py files so that you:

* Search for indirect flights only if there are no direct flights.

* Modify the check_flights() function so that it has a parameter called is_direct that has a default value of True  :


def check_flights(self, origin_city_code, destination_city_code, from_time, to_time, is_direct=True):


* Look at the flight_search.py. The Amadeus API has a query parameter called "nonStop". Set this to the string "true" and "false" depending on your needs.

* In the flight_data.py, add a variable called stops to your __init__() method to capture how many stops a flight has.

* Update the  destination so that you get the airport code from the final destination, not just from the stopover. Hint: In Amadeus an itinerary with a single segment is a direct flight. If there is more than 1 segment then the flight has stopovers.


SOLUTION