diff --git a/duffel_api/models/airline.py b/duffel_api/models/airline.py index 110b1f0..a6f6a9c 100644 --- a/duffel_api/models/airline.py +++ b/duffel_api/models/airline.py @@ -11,6 +11,8 @@ class Airline: id: str name: str iata_code: Optional[str] + logo_lockup_url: Optional[str] + logo_symbol_url: Optional[str] @classmethod def from_json(cls, json: dict): @@ -19,4 +21,6 @@ def from_json(cls, json: dict): id=json["id"], name=json["name"], iata_code=json.get("iata_code"), + logo_lockup_url=json.get("logo_lockup_url"), + logo_symbol_url=json.get("logo_symbol_url"), ) diff --git a/duffel_api/models/offer.py b/duffel_api/models/offer.py index 9ae33bf..86430c2 100644 --- a/duffel_api/models/offer.py +++ b/duffel_api/models/offer.py @@ -221,6 +221,32 @@ def from_json(cls, json: dict): ) +@dataclass +class OfferSliceSegmentStop: + """Additional segment-specific information about the stops, if any, included in the segment""" + + id: str + duration: str + arriving_at: datetime + departing_at: datetime + airport: Airport + + @classmethod + def from_json(cls, json: dict): + """Construct a class instance from a JSON response.""" + return cls( + id=json["id"], + arriving_at=get_and_transform( + json, "arriving_at", parse_datetime + ), + departing_at=get_and_transform( + json, "departing_at", parse_datetime + ), + airport=Airport.from_json(json["airport"]), + duration=json.get("duration"), + ) + + @dataclass class OfferSliceSegment: """The segments - that is, specific flights - that the airline is offering @@ -242,6 +268,7 @@ class OfferSliceSegment: operating_carrier: Airline operating_carrier_flight_number: Optional[str] passengers: Sequence[OfferSliceSegmentPassenger] + stops: Sequence[OfferSliceSegmentStop] @classmethod def from_json(cls, json: dict): @@ -270,6 +297,15 @@ def from_json(cls, json: dict): ], [], ), + stops=get_and_transform( + json, + "stops", + lambda value: [ + OfferSliceSegmentStop.from_json(stop) + for stop in value + ], + [], + ), )