<?php

declare(strict_types=1);

namespace App\ApiResources\Organization;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use App\State\Processor\Organization\OrganizationDeletionRequestProcessor;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Requête de création d'une nouvelle organisation.
 */
#[ApiResource(
    operations: [
        new Post(
            uriTemplate: '/internal/organization/delete',
        ),
    ],
    processor: OrganizationDeletionRequestProcessor::class
)]
class OrganizationDeletionRequest
{
    public const STATUS_PENDING = 'pending';
    public const STATUS_OK = 'ok';
    public const STATUS_OK_WITH_ERRORS = 'ok with errors';

    /**
     * Id 'bidon' ajouté par défaut pour permettre la construction
     * de l'IRI par api platform.
     */
    #[ApiProperty(identifier: true)]
    private int $id = 0;

    private int $organizationId;

    /**
     * A quelle adresse email notifier la création de l'organisation, ou d'éventuelles erreurs ?
     */
    #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
    private ?string $sendConfirmationEmailAt = null;

    /**
     * Statut de l'opération.
     */
    private string $status = self::STATUS_PENDING;

    /**
     * For testing purposes only.
     */
    private bool $async = true;

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

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

        return $this;
    }

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

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

        return $this;
    }

    public function getSendConfirmationEmailAt(): ?string
    {
        return $this->sendConfirmationEmailAt;
    }

    public function setSendConfirmationEmailAt(?string $sendConfirmationEmailAt): self
    {
        $this->sendConfirmationEmailAt = $sendConfirmationEmailAt;

        return $this;
    }

    public function getStatus(): string
    {
        return $this->status;
    }

    public function setStatus(string $status): self
    {
        $this->status = $status;

        return $this;
    }

    public function isAsync(): bool
    {
        return $this->async;
    }

    public function setAsync(bool $async): self
    {
        $this->async = $async;

        return $this;
    }
}
