<?php

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

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use App\Domain\Manga\Infrastructure\ApiPlatform\Controller\ImportVolumeController;
use Symfony\Component\HttpFoundation\File\File;

#[ApiResource(
    shortName: 'ImportVolume',
    operations: [
        new Post(
            uriTemplate: '/volumes/import',
            controller: ImportVolumeController::class,
            deserialize: false,
            openapiContext: [
                'summary' => 'Import a volume from CBZ file',
                'description' => 'Imports a CBZ file for an existing volume and updates all chapters',
                'requestBody' => [
                    'content' => [
                        'multipart/form-data' => [
                            'schema' => [
                                'type' => 'object',
                                'required' => ['mangaId', 'volumeNumber', 'file'],
                                'properties' => [
                                    'mangaId' => [
                                        'type' => 'string',
                                        'format' => 'uuid',
                                        'description' => 'The manga UUID'
                                    ],
                                    'volumeNumber' => [
                                        'type' => 'integer',
                                        'description' => 'The volume number'
                                    ],
                                    'file' => [
                                        'type' => 'string',
                                        'format' => 'binary',
                                        'description' => 'CBZ file to import (max 500MB)'
                                    ]
                                ]
                            ]
                        ]
                    ]
                ],
                'responses' => [
                    '200' => [
                        'description' => 'Volume imported successfully',
                        'content' => [
                            'application/json' => [
                                'schema' => [
                                    'type' => 'object',
                                    'properties' => [
                                        'message' => ['type' => 'string'],
                                        'mangaId' => ['type' => 'string'],
                                        'volumeNumber' => ['type' => 'integer']
                                    ]
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        )
    ]
)]
class ImportVolumeResource
{
    public ?string $mangaId = null;

    public ?int $volumeNumber = null;

    public ?File $file = null;
}
