<?php
declare(strict_types=1);

namespace App\ApiResources\Cotisation;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\ApiResources\ApiResourcesInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Classe resource qui contient les informations des cotisations de la 5.9
 */
#[ApiResource(
    collectionOperations:[],
    itemOperations: [
        'get' => [
            'method' => 'GET',
            'path' => '/cotisations/{organizationId}',
            'security' => 'is_granted("ROLE_COTISATION", object) and object.getOrganizationId() == user.getOrganization().getId()',
        ]
    ]
)]
class Cotisation implements ApiResourcesInterface
{
    #[ApiProperty(identifier: true)]
    private int $organizationId;

    #[Assert\Choice(callback: ['\App\Enum\Cotisation\AlertStateEnum', 'toArray'], message: 'invalid-alert-state-enum')]
    private ?string $alertState = null;

    private ?int $cotisationYear = null;

    public function getOrganizationId(): ?int
    {
        return $this->organizationId;
    }

    public function setOrganizationId(?int $organizationId): self
    {
        $this->organizationId = $organizationId;
        return $this;
    }

    public function getAlertState(): ?string
    {
        return $this->alertState;
    }

    public function setAlertState(?string $alertState): self
    {
        $this->alertState = $alertState;
        return $this;
    }

    public function getCotisationYear(): ?int
    {
        return $this->cotisationYear;
    }

    public function setCotisationYear(?int $cotisationYear): self
    {
        $this->cotisationYear = $cotisationYear;

        return $this;
    }
}
