<?php

namespace App\Http\Responses;

use App\Core\Response;

class ApiResponse
{
    public static function success(mixed $data = null, int $status = 200, ?string $message = null): Response
    {
        $body = ['success' => true, 'data' => $data, 'error' => null];
        if ($message !== null) {
            $body['message'] = $message;
        }

        return Response::json($body, $status);
    }

    public static function error(string $message, int $status = 400, array $details = []): Response
    {
        return Response::json([
            'success' => false,
            'data' => null,
            'error' => [
                'message' => $message,
                'details' => $details,
            ],
        ], $status);
    }
}
