<?php

namespace App\Support;

use Illuminate\Http\JsonResponse;

class ApiResponse
{
    public static function success(mixed $data = null, string $message = 'ok', int $code = 0): JsonResponse
    {
        return response()->json([
            'code' => $code,
            'message' => $message,
            'data' => $data,
            'server_time' => now()->toDateTimeString(),
        ]);
    }

    public static function error(string $message = 'error', int $code = 1, mixed $data = null, int $httpStatus = 400): JsonResponse
    {
        return response()->json([
            'code' => $code,
            'message' => $message,
            'data' => $data,
            'server_time' => now()->toDateTimeString(),
        ], $httpStatus);
    }
}
