<?php

namespace App\Helpers;

use Illuminate\Http\JsonResponse;

class APIResponse
{
    /**
     * API Success Response Helper
     *
     * @param array $data
     * @param string $message
     * @return JsonResponse
     */
    public static function success(array $data = [], string $message = ''): JsonResponse
    {
        return response()->json([
            'result' => $data,
            'message' => $message
        ]);
    }

    /**
     * API Error Response Helper
     *
     * @param array $data
     * @param string $message
     * @param int $status
     * @return JsonResponse
     */
    public static function error(string $message = '', array $data = [], $status = 422): JsonResponse
    {
        return response()->json([
            'result' => $data,
            'message' => $message,
        ], $status);
    }
}
