<?php

namespace App\Http\Controllers;

use App\Services\ProviderCalendarService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;

class ProviderCalendarController extends Controller
{
    public function __construct(private readonly ProviderCalendarService $service) {}

    public function index(): JsonResponse
    {
        try {
            $dados = $this->service->getCalendar();

            return $this->successResponse(payload: $dados);
        } catch (\Exception $e) {
            Log::error('Error fetching provider calendar: '.$e->getMessage());

            return $this->errorResponse(message: __('messages.error_fetching_data'), code: 500);
        }
    }
}
