Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Incorrect filtering #377

@gonewiththeway

Description

@gonewiththeway

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions