<?php

namespace App\Http\Controllers;

use App\Http\Requests\DeviceTokenRequest;
use App\Services\DeviceTokenService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;

class DeviceTokenController extends Controller
{
    public function __construct(private DeviceTokenService $deviceTokenService) {}

    public function store(DeviceTokenRequest $request): JsonResponse
    {
        Log::info('=== DEVICE TOKEN RECEBIDO ===', $request->validated());
        $this->deviceTokenService->register($request->validated());

        return $this->successResponse(code: 201);
    }

    public function destroy(string $token): JsonResponse
    {
        $this->deviceTokenService->remove($token);

        return $this->successResponse();
    }
}
