This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Claven
committed
Jan 20, 2022
1 parent
ae4f90b
commit a91b2c5
Showing
52 changed files
with
2,175 additions
and
945 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Aircraft: | ||
"""Aircraft are used to describe what passengers will fly in for a given trip""" | ||
|
||
def __init__(self, json): | ||
for key in json: | ||
setattr(self, key, json[key]) | ||
id: str | ||
iata_code: str | ||
name: str | ||
|
||
@classmethod | ||
def from_json(cls, json: dict): | ||
"""Construct a class instance from a JSON response.""" | ||
return cls( | ||
id=json["id"], | ||
iata_code=json["iata_code"], | ||
name=json["name"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Airline: | ||
"""Airlines are used to identify the air travel companies selling and operating | ||
flights | ||
""" | ||
|
||
def __init__(self, json): | ||
for key in json: | ||
setattr(self, key, json[key]) | ||
id: str | ||
name: str | ||
iata_code: str | ||
|
||
@classmethod | ||
def from_json(cls, json: dict): | ||
"""Construct a class instance from a JSON response.""" | ||
return cls( | ||
id=json["id"], | ||
name=json["name"], | ||
iata_code=json["iata_code"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,36 @@ | ||
class Airport: | ||
"""Airports are used to identify origins and destinations in journey slices""" | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
from duffel_api.models import City | ||
from duffel_api.utils import get_and_transform | ||
|
||
def __init__(self, json): | ||
for key in json: | ||
value = json[key] | ||
if key == "city" and value: | ||
setattr(self, key, City(value)) | ||
else: | ||
setattr(self, key, value) | ||
|
||
@dataclass | ||
class Airport: | ||
"""Airports are used to identify origins and destinations in journey | ||
slices""" | ||
|
||
class City: | ||
"""The metropolitan area where the airport is located. | ||
Only present for airports which are registered with IATA as | ||
belonging to a metropolitan area. | ||
""" | ||
id: str | ||
name: str | ||
iata_code: Optional[str] | ||
icao_code: Optional[str] | ||
country_code: str | ||
latitude: float | ||
longitude: float | ||
time_zone: str | ||
city: Optional[City] | ||
|
||
def __init__(self, json): | ||
for key in json: | ||
setattr(self, key, json[key]) | ||
@classmethod | ||
def from_json(cls, json: dict): | ||
"""Construct a class instance from a JSON response.""" | ||
return cls( | ||
id=json["id"], | ||
name=json["name"], | ||
iata_code=json.get("iata_code"), | ||
icao_code=json.get("icao_code"), | ||
country_code=json["country_code"], | ||
latitude=json["latitude"], | ||
longitude=json["longitude"], | ||
time_zone=json["time_zone"], | ||
city=get_and_transform(json, "city", City.from_json), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class City: | ||
"""The metropolitan area where the airport is located. | ||
Only present for airports which are registered with IATA as | ||
belonging to a metropolitan area. | ||
""" | ||
|
||
id: str | ||
name: str | ||
iata_code: str | ||
iata_country_code: str | ||
|
||
@classmethod | ||
def from_json(cls, json: dict): | ||
"""Construct a class instance from a JSON response.""" | ||
return cls( | ||
id=json["id"], | ||
name=json["name"], | ||
iata_code=json["iata_code"], | ||
iata_country_code=json["iata_country_code"], | ||
) |
Oops, something went wrong.