Implement fetching of certain data from OpenF1
This commit is contained in:
@ -20,7 +20,10 @@ class ApiSession():
|
||||
"year": int
|
||||
}
|
||||
|
||||
def __init__(self, response: dict[str, str]):
|
||||
def __init__(self, response: dict[str, str] | None):
|
||||
if response is None:
|
||||
return
|
||||
|
||||
for key in response:
|
||||
if not hasattr(self, key):
|
||||
raise Exception(f"Mismatch between response data and {type(self).__name__} (key={key})")
|
||||
@ -32,6 +35,13 @@ class ApiSession():
|
||||
|
||||
print("ApiSession:", self.__dict__)
|
||||
|
||||
def to_params(self) -> Dict[str, str]:
|
||||
params: Dict[str, str] = dict()
|
||||
for key in self.__dict__:
|
||||
params[str(key)] = str(self.__dict__[key])
|
||||
|
||||
return params
|
||||
|
||||
location: str = None # type: ignore
|
||||
country_key: int = None # type: ignore
|
||||
country_code: str = None # type: ignore
|
||||
|
Reference in New Issue
Block a user