From 1fa65f97b4d925437d72687da0578b7d76e7f106 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Mon, 22 Jan 2024 11:23:04 +0100 Subject: [PATCH] #19 Driver model --- amarillo/app/models/Carpool.py | 49 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/amarillo/app/models/Carpool.py b/amarillo/app/models/Carpool.py index e57f6da..e0900bd 100644 --- a/amarillo/app/models/Carpool.py +++ b/amarillo/app/models/Carpool.py @@ -176,6 +176,26 @@ class RidesharingInfo(BaseModel): min_length=1, max_length=48) +class Driver(BaseModel): + driver_id: Optional[str] = Field( + None, + description="Identifies the driver.", + min_length=1, + max_length=256, + pattern='^[a-zA-Z0-9_-]+$', + examples=["789"]) + profile_picture: Optional[HttpUrl] = Field( + None, + description="URL that contains the profile picture", + examples=["https://mfdz.de/driver/789/picture"]) + rating: Optional[int] = Field( + None, + description="Rating of the driver from 1 to 5." + "0 no rating yet", + ge=0, + le=5, + examples=[5]) + class Agency(BaseModel): id: str = Field( description="ID of the agency.", @@ -243,7 +263,6 @@ class Agency(BaseModel): #""" }) -# TODO: add driver model class and add it to carpool as an optional field class Carpool(BaseModel): id: str = Field( description="ID of the carpool. Should be supplied and managed by the " @@ -262,24 +281,16 @@ class Carpool(BaseModel): pattern='^[a-zA-Z0-9]+$', examples=["mfdz"]) - driver_id: Optional[str] = Field( - None, - description="Identifies the driver.", - min_length=1, - max_length=256, - pattern='^[a-zA-Z0-9_-]+$', - examples=["789"]) - driver_profile_picture: Optional[HttpUrl] = Field( - None, - description="URL that contains the profile picture", - examples=["https://mfdz.de/driver/789/picture"]) - driver_rating: Optional[int] = Field( - None, - description="Rating of the driver from 1 to 5." - "0 no rating yet", - ge=0, - le=5, - examples=[5]) + driver: Optional[Driver] = Field( + None, + description="Driver data", + examples=[""" + { + "driver_id": "123", + "profile_picture": "https://mfdz.de/driver/789/picture", + "rating": 5 + } + """]) deeplink: HttpUrl = Field( description="Link to an information page providing detail information "