feat(weather): wehaer value sky model instead of text cloudness

This commit is contained in:
2024-07-26 18:25:15 +03:00
parent f711b2d77b
commit 48a6cce569
6 changed files with 135 additions and 47 deletions

View File

@@ -1,21 +1,60 @@
import datetime
from enum import Enum
from pydantic import BaseModel
class WeatherValue(BaseModel):
class Model(BaseModel):
class Config:
use_enum_values = True
class Cloudness(str, Enum):
CLEAR = "clear"
PARTLY_CLOUDY = "party_cloudy"
CLOUDY = "cloudy"
MAINLY_CLOUDY = "mainly_cloudy"
class Precipitation(str, Enum):
NO = "no"
SMALL_RAIN = "small_rain"
RAIN = "rain"
SHOWER = "shower"
class Sky(Model):
cloudness: Cloudness
precipitation: Precipitation
thunder: bool
fog: bool
class WindDirection(str, Enum):
CALM = "calm"
N = "N"
NO = "NO"
O = "O"
SO = "SO"
S = "S"
SW = "SW"
W = "W"
NW = "NW"
class WeatherValue(Model):
date: datetime.datetime
cloudness: str
sky: Sky
temperature: int
wind_speed: int
wind_gust: int
wind_direction: str
wind_direction: WindDirection
precipitation: float
pressure: int
humidity: int
class WeatherResponse(BaseModel):
class WeatherResponse(Model):
location: str
date: datetime.date
period: str