Coverage for opt/mealie/lib/python3.12/site-packages/mealie/schema/response/responses.py: 100%
20 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
1from pydantic import BaseModel
3from mealie.schema._mealie import MealieModel
6class ErrorResponse(BaseModel):
7 message: str
8 error: bool = True
9 exception: str | None = None
11 @classmethod
12 def respond(cls, message: str, exception: str | None = None) -> dict:
13 """
14 This method is an helper to create an object and convert to a dictionary
15 in the same call, for use while providing details to a HTTPException
16 """
17 return cls(message=message, exception=exception).model_dump()
20class SuccessResponse(BaseModel):
21 message: str
22 error: bool = False
24 @classmethod
25 def respond(cls, message: str = "") -> dict:
26 """
27 This method is an helper to create an object and convert to a dictionary
28 in the same call, for use while providing details to a HTTPException
29 """
30 return cls(message=message).model_dump()
33class FileTokenResponse(MealieModel):
34 file_token: str
36 @classmethod
37 def respond(cls, token: str) -> dict:
38 """
39 This method is an helper to create an object and convert to a dictionary
40 in the same call, for use while providing details to a HTTPException
41 """
42 return cls(file_token=token).model_dump()