<?php

declare(strict_types=1);

namespace App\Scolarite\Infrastructure\Api\Resource;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Put;
use App\Scolarite\Infrastructure\Api\Processor\SaveCompetencyResultsProcessor;
use App\Scolarite\Infrastructure\Api\Provider\CompetencyResultCollectionProvider;

#[ApiResource(
    shortName: 'CompetencyResult',
    operations: [
        new GetCollection(
            uriTemplate: '/evaluations/{evaluationId}/competency-results',
            uriVariables: ['evaluationId'],
            provider: CompetencyResultCollectionProvider::class,
            name: 'get_competency_result_list',
        ),
        new Put(
            uriTemplate: '/evaluations/{evaluationId}/competency-results',
            uriVariables: ['evaluationId'],
            read: false,
            processor: SaveCompetencyResultsProcessor::class,
            name: 'save_competency_results',
        ),
    ],
)]
final class CompetencyResultResource
{
    #[ApiProperty(identifier: true)]
    public ?string $id = null;

    public ?string $evaluationId = null;

    public ?string $competencyEvaluationId = null;

    public ?string $competencyId = null;

    public ?string $competencyCode = null;

    public ?string $competencyName = null;

    public ?string $studentId = null;

    public ?string $studentName = null;

    public ?string $levelCode = null;

    public ?string $levelName = null;

    /** @var array<array{studentId: string, competencyEvaluationId: string, levelCode: string}>|null */
    public ?array $results = null;
}
