Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect filtering #377

Open
gonewiththeway opened this issue Feb 13, 2024 · 0 comments
Open

Incorrect filtering #377

gonewiththeway opened this issue Feb 13, 2024 · 0 comments

Comments

@gonewiththeway
Copy link

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:

if set(travel_slice.keys()) != set(


 @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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant