<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\Api\DestroyPushSubscriptionRequest;
use App\Http\Requests\Api\StorePushSubscriptionRequest;
use App\Services\PushSubscriptionService;
use Illuminate\Http\JsonResponse;

class PushSubscriptionController extends Controller
{
    public function __construct(
        private PushSubscriptionService $service,
    ) {}

    public function store(StorePushSubscriptionRequest $request): JsonResponse
    {
        return $this->service->store(
            $request->user(),
            $request->endpoint,
            $request->public_key,
            $request->auth_token,
            $request->content_encoding,
        );
    }

    public function destroy(DestroyPushSubscriptionRequest $request): JsonResponse
    {
        return $this->service->destroy(
            $request->user(),
            $request->endpoint,
        );
    }
}
