from typing import Any, Dict, Optional


def success_response(
    data: Any = None,
    message: str = "ok",
    code: int = 0,
    success: bool = True,
) -> Dict[str, Any]:
    return {
        "success": success,
        "message": message,
        "data": data,
        "code": code,
    }


def error_response(message: str, code: int, data: Optional[Any] = None) -> Dict[str, Any]:
    payload = {
        "success": False,
        "message": message,
        "code": code,
    }
    if data is not None:
        payload["data"] = data
    return payload
