<?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\ChapterContextProvider;
use Symfony\Component\Serializer\Annotation\Groups;

#[ApiResource(
    shortName: 'Reader',
    operations: [
        new Get(
            uriTemplate: '/reader/chapter/{chapterId}',
            openapiContext: [
                'summary' => 'Récupère le contexte d\'un chapitre',
                'description' => 'Retourne les métadonnées du chapitre et sa navigation',
                'parameters' => [
                    [
                        'name' => 'chapterId',
                        'in' => 'path',
                        'required' => true,
                        'schema' => ['type' => 'string'],
                    ],
                ],
                'responses' => [
                    '200' => [
                        'description' => 'Contexte du chapitre',
                        'content' => [
                            'application/json' => [
                                'schema' => [
                                    'type' => 'object',
                                    'properties' => [
                                        'id' => ['type' => 'string'],
                                        'title' => ['type' => 'string'],
                                        'number' => ['type' => 'string'],
                                        'manga' => [
                                            'type' => 'object',
                                            'properties' => [
                                                'id' => ['type' => 'string'],
                                                'title' => ['type' => 'string']
                                            ]
                                        ],
                                        'navigation' => [
                                            'type' => 'object',
                                            'properties' => [
                                                'previous' => [
                                                    'type' => 'object',
                                                    'nullable' => true,
                                                    'properties' => [
                                                        'id' => ['type' => 'string'],
                                                        'number' => ['type' => 'string']
                                                    ]
                                                ],
                                                'next' => [
                                                    'type' => 'object',
                                                    'nullable' => true,
                                                    'properties' => [
                                                        'id' => ['type' => 'string'],
                                                        'number' => ['type' => 'string']
                                                    ]
                                                ]
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ],
                    '404' => [
                        'description' => 'Chapitre non trouvé'
                    ]
                ]
            ],
            provider: ChapterContextProvider::class
        ),
    ],
)]
class ChapterContextResource
{
    public function __construct()
    {
    }
}
