<?php

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

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use App\Domain\Manga\Infrastructure\ApiPlatform\State\Processor\DeleteCbzProcessor;
use App\Domain\Manga\Infrastructure\ApiPlatform\State\Provider\DeleteCbzProvider;

#[ApiResource(
    shortName: 'Cbz',
    operations: [
        new Delete(
            uriTemplate: '/manga/chapters/{id}/cbz',
            provider: DeleteCbzProvider::class,
            processor: DeleteCbzProcessor::class,
            name: 'delete_cbz',
            openapiContext: [
                'summary' => 'Delete chapter CBZ file',
                'description' => 'Removes the CBZ file for a specific chapter and updates the chapter accordingly',
                'parameters' => [
                    [
                        'name' => 'id',
                        'in' => 'path',
                        'required' => true,
                        'schema' => [
                            'type' => 'string'
                        ],
                        'description' => 'The chapter ID'
                    ]
                ],
                'responses' => [
                    '204' => [
                        'description' => 'CBZ file successfully deleted'
                    ],
                    '404' => [
                        'description' => 'Chapter or CBZ file not found'
                    ]
                ]
            ]
        )
    ]
)]
class DeleteCbzResource
{
    public function __construct(
        public string $id
    ) {
    }
}
