<?php
declare (strict_types=1);

namespace App\ApiResources\Access;

use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use App\ApiResources\ApiResourcesInterface;
use App\State\Processor\Access\AdminAccessProcessor;
use App\State\Provider\Access\AdminAccessProvider;
use JetBrains\PhpStorm\Pure;
use Symfony\Component\Validator\Constraints as Assert;
/**
 * Classe resource qui contient les champs d'un compte admin
 */
#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/admin/{id}',
            defaults: ['id' => 0],
            provider: AdminAccessProvider::class
        ),
        new Put(
            uriTemplate: '/admin/{id}',
            defaults: ['id' => 0],
            processor: AdminAccessProcessor::class
        )
    ]
)]
class AdminAccess implements ApiResourcesInterface
{
    #[ApiProperty(identifier: true)]
    public ?int $id = null;

    private ?string $username = null;

    #[Assert\Email(message: 'invalid-email-format', mode: 'strict')]
    private ?string $email = null;

    #[Pure]
    public function __construct()
    {
    }

    public function getId() : ?int
    {
        return $this->id;
    }

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

    public function getUsername() : ?string
    {
        return $this->username;
    }

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

    public function getEmail() : ?string
    {
        return $this->email;
    }

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