<?php

declare(strict_types=1);

namespace App\Entity\Organization;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Traits\CreatedOnAndByTrait;
use App\Enum\Organization\SettingsProductEnum;
use App\Repository\Organization\SettingsRepository;
// use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use Doctrine\ORM\Mapping as ORM;

/**
 * Caractéristiques d'une Organization (produits, options...etc).
 */
#[ApiResource(operations: [])]
// #[Auditable]
#[ORM\Entity(repositoryClass: SettingsRepository::class)]
class Settings
{
    use CreatedOnAndByTrait;

    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\OneToOne(inversedBy: 'settings', cascade: ['persist', 'remove'])]
    #[ORM\JoinColumn(nullable: false)]
    private Organization $organization;

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

    /** @var mixed[]|null */
    #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
    private ?array $modules = [];

    /** @var mixed[]|null */
    #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
    private ?array $actions = [];

    #[ORM\Column(length: 255, options: ['default' => 'FRANCE'])]
    private string $country;

    #[ORM\Column(nullable: true)]
    private ?bool $trialActive = false;

    #[ORM\Column(type: 'date', nullable: true)]
    private ?\DateTimeInterface $lastTrialStartDate = null;

    #[ORM\Column(length: 50, nullable: true, enumType: SettingsProductEnum::class)]
    private ?SettingsProductEnum $productBeforeTrial;

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

    public function getOrganization(): ?Organization
    {
        return $this->organization;
    }

    public function setOrganization(Organization $organization): self
    {
        $this->organization = $organization;

        return $this;
    }

    public function getProduct(): SettingsProductEnum
    {
        return $this->product;
    }

    public function setProduct(SettingsProductEnum $product): self
    {
        $this->product = $product;

        return $this;
    }

    /**
     * @return mixed[]|null
     */
    public function getModules(): ?array
    {
        return $this->modules;
    }

    /**
     * @param mixed[]|null $modules
     *
     * @return $this
     */
    public function setModules(?array $modules): self
    {
        $this->modules = $modules;

        return $this;
    }

    /**
     * @return mixed[]|null
     */
    public function getActions(): ?array
    {
        return $this->actions;
    }

    /**
     * @param mixed[]|null $actions
     *
     * @return $this
     */
    public function setActions(?array $actions): self
    {
        $this->actions = $actions;

        return $this;
    }

    public function getCountry(): string
    {
        return $this->country;
    }

    public function setCountry(string $country): self
    {
        $this->country = $country;

        return $this;
    }

    public function isTrialActive(): ?bool
    {
        return $this->trialActive;
    }

    public function setTrialActive(?bool $trialActive): self
    {
        $this->trialActive = $trialActive;

        return $this;
    }

    public function getlLastTrialStartDate(): ?\DateTimeInterface
    {
        return $this->lastTrialStartDate;
    }

    public function setLastTrialStartDate(?\DateTimeInterface $lastTrialStartDate): self
    {
        $this->lastTrialStartDate = $lastTrialStartDate;

        return $this;
    }

    public function getProductBeforeTrial(): ?SettingsProductEnum
    {
        return $this->productBeforeTrial;
    }

    public function setProductBeforeTrial(?SettingsProductEnum $productBeforeTrial): self
    {
        $this->productBeforeTrial = $productBeforeTrial;

        return $this;
    }

    public function getCreateDate(): ?\DateTimeInterface
    {
        return $this->createDate;
    }

    public function setCreateDate(?\DateTimeInterface $createDate): self
    {
        $this->createDate = $createDate;

        return $this;
    }
}
