<?php

declare(strict_types=1);

namespace App\Module\Integration\Infrastructure\ApiPlatform\Resource;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use App\Module\Integration\Infrastructure\ApiPlatform\State\BookStackSearchResultProvider;
use App\Module\ProjectManagement\Domain\Entity\Task;
use Symfony\Component\Serializer\Attribute\Groups;

#[ApiResource(
    operations: [
        new GetCollection(
            uriTemplate: '/tasks/{taskId}/bookstack/search',
            uriVariables: [
                'taskId' => new Link(fromClass: Task::class, identifiers: ['id']),
            ],
            normalizationContext: ['groups' => ['bookstack_search:read']],
            provider: BookStackSearchResultProvider::class,
            security: "is_granted('ROLE_USER')",
        ),
    ],
)]
final class BookStackSearchResult
{
    #[Groups(['bookstack_search:read'])]
    public int $id = 0;

    #[Groups(['bookstack_search:read'])]
    public string $type = '';

    #[Groups(['bookstack_search:read'])]
    public string $name = '';

    #[Groups(['bookstack_search:read'])]
    public string $url = '';
}
