<?php

declare(strict_types=1);

/*
 * This file is part of the VitiCore 2.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\SocialNetwork\Model;

use ApiPlatform\Metadata\ApiProperty;
use CpCreation\VitiCore\Behavior\HasTimestamp;
use CpCreation\VitiCore\Behavior\Impl\Timestamp;
use CpCreation\VitiCore\SocialNetwork\Repository\SocialNetworkRepository;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: SocialNetworkRepository::class)]
#[ORM\Table(name: 'socialnetwork_socialnetwork')]
#[ORM\HasLifecycleCallbacks]
class SocialNetwork implements HasTimestamp
{
    use Timestamp;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid')]
    #[ORM\GeneratedValue(strategy: 'NONE')]
    #[ApiProperty(iris: ['https://schema.org/identifier'])]
    private UuidInterface $id;

    #[ORM\Column(type: 'string')]
    #[Assert\NotBlank(groups: ['step1'])]
    private ?string $network = null;

    #[ORM\Column(type: 'json', nullable: true)]
    #[Assert\NotBlank(groups: ['step2'])]
    private ?array $configuration = null;

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

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

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

    public function __construct()
    {
        $this->id = Uuid::uuid4();
        $this->data = [];
    }

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

    public function getNetwork(): ?string
    {
        return $this->network;
    }

    public function setNetwork(?string $network): void
    {
        $this->network = $network;
    }

    public function getConfiguration(): ?array
    {
        return $this->configuration;
    }

    public function setConfiguration(?array $configuration): void
    {
        $this->configuration = $configuration;
    }

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

    public function setToken(?string $token = null): void
    {
        $this->token = $token;
    }

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

    public function setTokenAt(?\DateTimeInterface $tokenAt = null): void
    {
        $this->tokenAt = $tokenAt;
    }

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

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