<?php

declare(strict_types=1);

namespace App\Entity\Shop;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use App\Enum\Shop\ShopRequestStatus;
use App\Enum\Shop\ShopRequestType;
use App\State\Processor\Shop\NewStructureArtistPremiumTrialRequestProcessor;
use App\State\Provider\Shop\ShopRequestProvider;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use DateTimeImmutable;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Une demande effectuée par un client via la boutique en ligne (ex: demande d'essai premium)
 */
#[ApiResource(operations: [
    new Get(
        uriTemplate: '/public/shop/validate/{token}',
        provider: ShopRequestProvider::class,
    )
])]
#[ORM\Entity]
class ShopRequest
{
    #[ORM\Id]
    #[ORM\Column(type: 'guid')]
    private string $token;

    #[ORM\Column(type: 'datetime_immutable')]
    private DateTimeImmutable $submissionDate;

    #[ORM\Column(length: 50, enumType: ShopRequestStatus::class)]
    private ShopRequestStatus $status;

    #[ORM\Column(length: 50, enumType: ShopRequestType::class)]
    private ShopRequestType $type;

    #[ORM\Column(type: Types::JSON)]
    private array $data = [];

    public function __construct()
    {
        $this->submissionDate = new DateTimeImmutable();
        $this->status = ShopRequestStatus::PENDING;
    }

    public function getToken(): string
    {
        return $this->token;
    }

    public function setToken(string $token): self
    {
        $this->token = $token;

        return $this;
    }

    public function getSubmissionDate(): DateTimeImmutable
    {
        return $this->submissionDate;
    }

    public function setSubmissionDate(DateTimeImmutable $submissionDate): self
    {
        $this->submissionDate = $submissionDate;

        return $this;
    }

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

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

        return $this;
    }

    public function getType(): ShopRequestType
    {
        return $this->type;
    }

    public function setType(ShopRequestType $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function getData(): array
    {
        return $this->data;
    }

    public function setData(array $data): self
    {
        $this->data = $data;

        return $this;
    }
}
