duffel-api-python
duffel-api-python copied to clipboard
Incorrect filtering
Hello. I am trying to use the python library in one of my apps. However, it throws an error if I provide any parameter other than departure_date, destination and origin.
In the documentation, and the example in documentation, its clearly mentioned that arrival_time and departure_time can also be param in slice.
FWIW, I commented the error, and it worked - which means backend is alright, but the python code is not working.
Official Documentation:
from duffel_api import Duffel
duffel = Duffel(access_token=YOUR_ACCESS_TOKEN)
duffel.offer_requests.create().cabin_class("economy")
.passengers([
{
"family_name": "Earhart",
"given_name": "Amelia",
"loyalty_programme_accounts": [
{
"account_number": "12901014",
"airline_iata_code": "BA"
}
],
"type": "adult"
},
{
"age": 14
},
{
"fare_type": "student"
},
{
"age": 5,
"fare_type": "contract_bulk_child"
}
])
.slices([
{
"origin": "LHR",
"destination": "JFK",
"departure_time": {
"to": "17:00",
"from": "09:45"
},
"departure_date": "2020-04-24",
"arrival_time": {
"to": "17:00",
"from": "09:45"
}
}
])
.execute()
Line with Issue: https://github.com/duffelhq/duffel-api-python/blob/fad434467a6e41079a860d729d8661ab7a047bf8/duffel_api/api/booking/offer_requests.py#L87
@staticmethod
def _validate_slices(slices):
"""Validate number of slices and the data provided for each if any were given"""
if len(slices) == 0:
raise OfferRequestCreate.InvalidNumberOfSlices(slices)
for travel_slice in slices:
if set(travel_slice.keys()) != set(
["departure_date", "destination", "origin"]
):
raise OfferRequestCreate.InvalidSlice(travel_slice)