package handlers

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

// APIResponse is the unified response envelope for all API responses.
type APIResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   interface{} `json:"error,omitempty"`
}

// RespondSuccess sends a success response with the standard envelope.
// If data is nil, the "data" field will be omitted (or null depending on helper, here omitempty).
func RespondSuccess(c *gin.Context, code int, data interface{}) {
	c.JSON(code, APIResponse{
		Success: true,
		Data:    data,
		Error:   nil,
	})
}
