Files
mealie/mealie/schema/response/responses.py
Ben Boeckel 2e6b877ba9 docs: fix typos (#1665)
* 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.
2022-09-25 15:17:27 -08:00

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()