<?php

namespace App\Domain\Manga\Infrastructure\ApiPlatform\Resource;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\OpenApi\Model\Parameter;
use App\Domain\Manga\Infrastructure\ApiPlatform\State\Processor\DeleteChapterProcessor;
use App\Domain\Manga\Infrastructure\ApiPlatform\State\Provider\DeleteChapterProvider;

#[ApiResource(
    shortName: 'Chapters',
    operations: [
        new Delete(
            uriTemplate: '/manga/chapters/{id}',
            provider: DeleteChapterProvider::class,
            processor: DeleteChapterProcessor::class,
            name: 'delete_chapter',
            openapi: new Operation(
                summary: 'Delete a chapter (soft delete)',
                description: 'Marks a chapter as deleted by setting its visibility to false',
                parameters: [
                    new Parameter(
                        name: 'id',
                        in: 'path',
                        required: true,
                        schema: ['type' => 'string'],
                        description: 'The chapter ID'
                    ),
                ],
                responses: [
                    '204' => [
                        'description' => 'Chapter successfully deleted',
                    ],
                    '404' => [
                        'description' => 'Chapter not found',
                    ],
                ]
            )
        ),
    ]
)]
class DeleteChapterResource
{
    public function __construct(
        public string $id,
    ) {
    }
}
