amadeus4dev / amadeus-code-examples

Self-contained examples for Amadeus REST APIs
MIT License
81 stars 35 forks source link

Unable to disable returnDate parameter in shopping.flight_offers_search.get. #19

Closed spyglass24 closed 2 years ago

spyglass24 commented 2 years ago

Hi, Here is my function for flight search. How I can disable day_return parametr ? day_return=None , "null", "" , are not working. If there is value for day_return it's working. But what if there is no value, like say oneWay flight?


def flt_search(origin, destination, day_origin, day_return=None, stopover=None):

try:
    response = amadeus.shopping.flight_offers_search.get(
        originLocationCode=origin,
        destinationLocationCode=destination,
        departureDate=day_origin,
        returnDate=day_return,
        adults=1,
        max=3,
        nonStop=stopover
    )
    message = response.data
    pprint.pprint(message)
    print(len(message))
    return message, origin, destination

except ResponseError as error:
    return error
tsolakoua commented 2 years ago

When you are looking for flights with no return, you shouldn't pass in the API the returnDate at all. Even if you try with None and null the backend still receives a returnDate with invalid inputs, since the expected input is in format YYYY-MM-DD.