<?php

declare(strict_types=1);

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

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\Domain\Reader\Infrastructure\ApiPlatform\State\Provider\ChapterPageProvider;

#[ApiResource(
    shortName: 'Reader',
    operations: [
        new Get(
            uriTemplate: '/reader/chapter/{chapterId}/page/{pageNumber}',
            openapiContext: [
                'summary' => 'Récupère une page spécifique d\'un chapitre',
                'description' => 'Retourne le contenu d\'une page en base64 avec ses métadonnées',
                'parameters' => [
                    [
                        'name' => 'chapterId',
                        'in' => 'path',
                        'required' => true,
                        'schema' => ['type' => 'string'],
                        'description' => 'L\'identifiant du chapitre'
                    ],
                    [
                        'name' => 'pageNumber',
                        'in' => 'path',
                        'required' => true,
                        'schema' => ['type' => 'integer', 'minimum' => 1],
                        'description' => 'Le numéro de la page à récupérer'
                    ],
                ],
                'responses' => [
                    '200' => [
                        'description' => 'Page du chapitre',
                        'content' => [
                            'application/json' => [
                                'schema' => [
                                    'type' => 'object',
                                    'properties' => [
                                        'id' => ['type' => 'string'],
                                        'pageNumber' => ['type' => 'integer'],
                                        'base64Content' => ['type' => 'string', 'description' => 'Contenu de l\'image en base64'],
                                        'mimeType' => ['type' => 'string', 'example' => 'image/jpeg'],
                                        'dimensions' => [
                                            'type' => 'object',
                                            'properties' => [
                                                'width' => ['type' => 'integer'],
                                                'height' => ['type' => 'integer']
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ],
                    '404' => [
                        'description' => 'Chapitre ou page non trouvé'
                    ]
                ]
            ],
            provider: ChapterPageProvider::class
        ),
    ],
)]
class ChapterPageResource
{
    public function __construct()
    {
    }
} 