Files
mealie/mealie/schema/response/responses.py
Hayden 82dc586bac chores: updates-and-linters (#1868)
* switch to ruff

* add ruff

* run ruff --fix

* update ruff

* resolve ruff errors

* drop isort from CI

* fix decorator order
2022-11-30 20:20:28 -09:00

43 lines
1.2 KiB
Python

from pydantic import BaseModel
from mealie.schema._mealie import MealieModel
class ErrorResponse(BaseModel):
message: str
error: bool = True
exception: str | None = None
@classmethod
def respond(cls, message: str, exception: str | None = None) -> dict:
"""
This method is an helper to create an object and convert to a dictionary
in the same call, for use while providing details to a HTTPException
"""
return cls(message=message, exception=exception).dict()
class SuccessResponse(BaseModel):
message: str
error: bool = False
@classmethod
def respond(cls, message: str) -> dict:
"""
This method is an helper to create an object and convert to a dictionary
in the same call, for use while providing details to a HTTPException
"""
return cls(message=message).dict()
class FileTokenResponse(MealieModel):
file_token: str
@classmethod
def respond(cls, token: str) -> dict:
"""
This method is an helper to create an object and convert to a dictionary
in the same call, for use while providing details to a HTTPException
"""
return cls(file_token=token).dict()