<?php
declare (strict_types=1);

namespace App\Entity\Public;

use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use App\Filter\Utils\DistanceFilter;
use App\Repository\Public\PublicEventRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * Évènements publics tels que publiés sur l'agenda du site opentalent ou les sites des structures
 *
 * Fichier source de la view : ./sql/schema-extensions/001-view_public_events.sql
 */
#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/public/events/{uuid}'
        ),
        new GetCollection(
            uriTemplate: '/public/events'
        )
    ]
)]
#[ORM\Entity(repositoryClass: PublicEventRepository::class, readOnly: true)]
#[ORM\Table(name: "view_public_events")]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial', 'city' => 'exact'])]
#[ApiFilter(filterClass: NumericFilter::class, properties: ['organizationId'])]
#[ApiFilter(filterClass: DateFilter::class, properties: ['datetimeStart', 'datetimeEnd'])]
#[ApiFilter(filterClass: DistanceFilter::class)]
#[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart', 'datetimeEnd'], arguments: ['orderParameterName' => 'order'])]
class PublicEvent
{
    #[ORM\Id]
    #[ORM\Column]
    private string $uuid;

    #[ORM\Column(type: 'integer')]
    private ?int $organizationId;

    #[ORM\Column]
    private string $name;

    #[ORM\Column(type: 'string')]
    private ?string $description;

    #[ORM\Column]
    private ?string $url;

    #[ORM\Column(type: 'datetime')]
    private \DateTime $datetimeStart;

    #[ORM\Column(type: 'datetime')]
    private \DateTime $datetimeEnd;

    #[ORM\Column]
    private ?string $city;

    #[ORM\Column]
    private ?string $postalCode;

    #[ORM\Column]
    private ?string $streetAddress;

    #[ORM\Column(type: 'float')]
    private ?float $longitude;

    #[ORM\Column(type: 'float')]
    private ?float $latitude;

    #[ORM\Column]
    private ?string $roomName;

    #[ORM\Column]
    private ?string $roomDescription;

    #[ORM\Column]
    private ?string $roomLocalisation;

    #[ORM\Column]
    private ?string $roomCapacity;

    #[ORM\Column]
    private ?string $roomFloorSize;

    #[ORM\Column]
    private ?string $imageUrl;

    #[ORM\Column]
    private ?string $thumbnailUrl;

    /** @var list<string>|null  */
    #[ORM\Column(type: 'simple_array')]
    private ?array $categories;

    #[ORM\Column]
    private string $origin = 'opentalent';
    #[ORM\Column(type: 'integer')]
    private int $entityId;

    /**
     * @return string
     */
    public function getUuid(): string
    {
        return $this->uuid;
    }

    /**
     * @param string $uuid
     * @return PublicEvent
     */
    public function setUuid(string $uuid): PublicEvent
    {
        $this->uuid = $uuid;
        return $this;
    }

    /**
     * @return int|null
     */
    public function getOrganizationId(): ?int
    {
        return $this->organizationId;
    }

    /**
     * @param int|null $organizationId
     * @return PublicEvent
     */
    public function setOrganizationId(?int $organizationId): PublicEvent
    {
        $this->organizationId = $organizationId;
        return $this;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return PublicEvent
     */
    public function setName(string $name): PublicEvent
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getDescription(): ?string
    {
        return $this->description;
    }

    /**
     * @param string|null $description
     * @return PublicEvent
     */
    public function setDescription(?string $description): PublicEvent
    {
        $this->description = $description;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getUrl(): ?string
    {
        return $this->url;
    }

    /**
     * @param string|null $url
     * @return PublicEvent
     */
    public function setUrl(?string $url): PublicEvent
    {
        $this->url = $url;
        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getDatetimeStart(): \DateTime
    {
        return $this->datetimeStart;
    }

    /**
     * @param \DateTime $datetimeStart
     * @return PublicEvent
     */
    public function setDatetimeStart(\DateTime $datetimeStart): PublicEvent
    {
        $this->datetimeStart = $datetimeStart;
        return $this;
    }

    /**
     * @return \DateTime
     */
    public function getDatetimeEnd(): \DateTime
    {
        return $this->datetimeEnd;
    }

    /**
     * @param \DateTime $datetimeEnd
     * @return PublicEvent
     */
    public function setDatetimeEnd(\DateTime $datetimeEnd): PublicEvent
    {
        $this->datetimeEnd = $datetimeEnd;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getCity(): ?string
    {
        return $this->city;
    }

    /**
     * @param string|null $city
     * @return PublicEvent
     */
    public function setCity(?string $city): PublicEvent
    {
        $this->city = $city;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getPostalCode(): ?string
    {
        return $this->postalCode;
    }

    /**
     * @param string|null $postalCode
     * @return PublicEvent
     */
    public function setPostalCode(?string $postalCode): PublicEvent
    {
        $this->postalCode = $postalCode;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getStreetAddress(): ?string
    {
        return $this->streetAddress;
    }

    /**
     * @param string|null $streetAddress
     * @return PublicEvent
     */
    public function setStreetAddress(?string $streetAddress): PublicEvent
    {
        $this->streetAddress = $streetAddress;
        return $this;
    }

    /**
     * @return float|null
     */
    public function getLongitude(): ?float
    {
        return $this->longitude;
    }

    /**
     * @param float|null $longitude
     * @return PublicEvent
     */
    public function setLongitude(?float $longitude): PublicEvent
    {
        $this->longitude = $longitude;
        return $this;
    }

    /**
     * @return float|null
     */
    public function getLatitude(): ?float
    {
        return $this->latitude;
    }

    /**
     * @param float|null $latitude
     * @return PublicEvent
     */
    public function setLatitude(?float $latitude): PublicEvent
    {
        $this->latitude = $latitude;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getRoomName(): ?string
    {
        return $this->roomName;
    }

    /**
     * @param string|null $roomName
     * @return PublicEvent
     */
    public function setRoomName(?string $roomName): PublicEvent
    {
        $this->roomName = $roomName;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getRoomDescription(): ?string
    {
        return $this->roomDescription;
    }

    /**
     * @param string|null $roomDescription
     * @return PublicEvent
     */
    public function setRoomDescription(?string $roomDescription): PublicEvent
    {
        $this->roomDescription = $roomDescription;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getRoomLocalisation(): ?string
    {
        return $this->roomLocalisation;
    }

    /**
     * @param string|null $roomLocalisation
     * @return PublicEvent
     */
    public function setRoomLocalisation(?string $roomLocalisation): PublicEvent
    {
        $this->roomLocalisation = $roomLocalisation;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getRoomCapacity(): ?string
    {
        return $this->roomCapacity;
    }

    /**
     * @param string|null $roomCapacity
     * @return PublicEvent
     */
    public function setRoomCapacity(?string $roomCapacity): PublicEvent
    {
        $this->roomCapacity = $roomCapacity;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getRoomFloorSize(): ?string
    {
        return $this->roomFloorSize;
    }

    /**
     * @param string|null $roomFloorSize
     * @return PublicEvent
     */
    public function setRoomFloorSize(?string $roomFloorSize): PublicEvent
    {
        $this->roomFloorSize = $roomFloorSize;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getImageUrl(): ?string
    {
        return $this->imageUrl;
    }

    /**
     * @param string|null $imageUrl
     * @return PublicEvent
     */
    public function setImageUrl(?string $imageUrl): PublicEvent
    {
        $this->imageUrl = $imageUrl;
        return $this;
    }

    /**
     * @return string|null
     */
    public function getThumbnailUrl(): ?string
    {
        return $this->thumbnailUrl;
    }

    /**
     * @param string|null $thumbnailUrl
     * @return PublicEvent
     */
    public function setThumbnailUrl(?string $thumbnailUrl): PublicEvent
    {
        $this->thumbnailUrl = $thumbnailUrl;
        return $this;
    }

    /**
     * @return list<string>|null
     */
    public function getCategories(): ?array
    {
        return $this->categories;
    }

    /**
     * @param list<string>|null $categories
     * @return PublicEvent
     */
    public function setCategories(?array $categories): PublicEvent
    {
        $this->categories = $categories;
        return $this;
    }

    /**
     * @return string
     */
    public function getOrigin(): string
    {
        return $this->origin;
    }

    /**
     * @param string $origin
     * @return PublicEvent
     */
    public function setOrigin(string $origin): PublicEvent
    {
        $this->origin = $origin;
        return $this;
    }

    /**
     * @return int
     */
    public function getEntityId(): int
    {
        return $this->entityId;
    }

    /**
     * @param int $entityId
     * @return PublicEvent
     */
    public function setEntityId(int $entityId): PublicEvent
    {
        $this->entityId = $entityId;
        return $this;
    }
}
