# -*- coding: utf-8 -*-
from fastapi import status
from fastapi.responses import JSONResponse
from typing import Union


def resp_200(*, data: Union[list, dict, str]) -> JSONResponse:
    return JSONResponse(
        status_code=status.HTTP_200_OK,
        content={"code": 200, "message": "success", "data": data}
    )


def resp_400(*, message: str = "Bad Request", data: Union[list, dict, str] = None) -> JSONResponse:
    return JSONResponse(
        status_code=status.HTTP_400_BAD_REQUEST,
        content={"code": 400, "message": message, "data": data}
    )

def resp_401(*, message: str = "The token has expired", data: Union[list, dict, str] = None) -> JSONResponse:
    return JSONResponse(
        status_code=status.HTTP_401_UNAUTHORIZED,
        content={"code": 401, "message": message, "data": data}
    )

def resp_404(*, message: str = "Not Found", data: Union[list, dict, str] = None) -> JSONResponse:
    return JSONResponse(
        status_code=status.HTTP_404_NOT_FOUND,
        content={"code": 404, "message": message, "data": data}
    )


def resp_500(*, message: str = "Internal Server Error", data: Union[list, dict, str] = None) -> JSONResponse:
    return JSONResponse(
        status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
        content={"code": 500, "message": message, "data": data}
    )