48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from uuid import UUID
|
||
|
|
|
||
|
|
from pydantic import Field
|
||
|
|
|
||
|
|
from .common import ApiEnvelope, RouteContract, SchemaModel
|
||
|
|
|
||
|
|
HTTP_METHOD = 'POST'
|
||
|
|
ROUTE_PATH = '/api/economy/overview/'
|
||
|
|
|
||
|
|
|
||
|
|
class EconomyOverviewRequest(SchemaModel):
|
||
|
|
farm_uuid: UUID
|
||
|
|
|
||
|
|
|
||
|
|
class EconomyDataItem(SchemaModel):
|
||
|
|
title: str
|
||
|
|
value: str
|
||
|
|
subtitle: str | None = None
|
||
|
|
avatarIcon: str | None = None
|
||
|
|
avatarColor: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class ChartSeriesItem(SchemaModel):
|
||
|
|
name: str
|
||
|
|
data: list[float] = Field(default_factory=list)
|
||
|
|
|
||
|
|
|
||
|
|
class EconomyOverviewResponseData(SchemaModel):
|
||
|
|
farm_uuid: str
|
||
|
|
source: str | None = None
|
||
|
|
economicData: list[EconomyDataItem] = Field(default_factory=list)
|
||
|
|
chartSeries: list[ChartSeriesItem] = Field(default_factory=list)
|
||
|
|
chartCategories: list[str] = Field(default_factory=list)
|
||
|
|
|
||
|
|
|
||
|
|
class EconomyOverviewResponse(ApiEnvelope[EconomyOverviewResponseData]):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
CONTRACT = RouteContract(
|
||
|
|
method=HTTP_METHOD,
|
||
|
|
path=ROUTE_PATH,
|
||
|
|
request_model=EconomyOverviewRequest.__name__,
|
||
|
|
response_model=EconomyOverviewResponse.__name__,
|
||
|
|
)
|