mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-20 07:51:21 -05:00
* docs: fix typos * typos: fix typos found by `codespell` across the codebase * docs: fix `macOS` spelling * docs: fix `authentification` terminology "Authentification" is not a thing. * docs: fix `localhost` typo in example link * typos: fix in-code typos These are potentially higher risk, but no other mentions of these typos show up in the codebase.
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from mealie.schema._mealie import MealieModel
|
|
|
|
|
|
class ErrorResponse(BaseModel):
|
|
message: str
|
|
error: bool = True
|
|
exception: Optional[str] = None
|
|
|
|
@classmethod
|
|
def respond(cls, message: str, exception: Optional[str] = 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()
|