package models

import (
	"github.com/gin-gonic/gin"
)

type SuccessResponse struct {
	Data interface{} `json:"data"`
}

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

type ErrorDetail struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Detail  string `json:"detail"`
}

func Success(c *gin.Context, data interface{}) {
	c.JSON(200, SuccessResponse{Data: data})
}

func Error(c *gin.Context, code int, message string, detail string) {
	c.JSON(code, ErrorResponse{Error: ErrorDetail{Code: code, Message: message, Detail: detail}})
}
