<?php

declare(strict_types=1);

namespace App\Entity\Public;

use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use App\Filter\ApiPlatform\Utils\ArrayFieldFilter;
use App\Filter\ApiPlatform\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',
            paginationItemsPerPage: 16,
        ),
    ]
)]
#[ORM\Entity(repositoryClass: PublicEventRepository::class, readOnly: true)]
#[ORM\Table(name: 'view_public_events')]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'partial', 'city' => 'exact', 'categoryCode' => 'exact', 'origin' => 'exact'])]
#[ApiFilter(filterClass: NumericFilter::class, properties: ['organizationId', 'priceMini', 'price_maxi'])]
#[ApiFilter(filterClass: DateFilter::class, properties: ['datetimeStart', 'datetimeEnd'])]
#[ApiFilter(filterClass: DistanceFilter::class)]
#[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart', 'datetimeEnd'], arguments: ['orderParameterName' => 'order'])]
#[ApiFilter(filterClass: RangeFilter::class, properties: ['priceMini', 'priceMaxi'])]
#[ApiFilter(filterClass: ArrayFieldFilter::class, properties: ['categories', 'gender'])]
class PublicEvent
{
    #[ORM\Id]
    #[ORM\Column]
    private string $uuid;

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

    #[ORM\Column]
    private string $name;

    #[ORM\Column]
    private string $structureName;

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

    #[ORM\Column(nullable: true)]
    private ?string $url;

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

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

    #[ORM\Column(nullable: true)]
    private ?string $city;

    #[ORM\Column(nullable: true)]
    private ?string $postalCode;

    #[ORM\Column(nullable: true)]
    private ?string $streetAddress;

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

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

    #[ORM\Column(nullable: true)]
    private ?string $roomName;

    #[ORM\Column(nullable: true)]
    private ?string $roomDescription;

    #[ORM\Column(nullable: true)]
    private ?string $roomLocalisation;

    #[ORM\Column(nullable: true)]
    private ?string $roomCapacity;

    #[ORM\Column(nullable: true)]
    private ?string $roomFloorSize;

    #[ORM\Column(type: 'float', nullable: true)]
    private ?float $structureLongitude;

    #[ORM\Column(type: 'float', nullable: true)]
    private ?float $structureLatitude;

    #[ORM\Column(nullable: true)]
    private ?string $imageUrl;

    #[ORM\Column(nullable: true)]
    private ?string $thumbnailUrl;

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

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

    #[ORM\Column]
    private string $origin = 'opentalent';

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

    #[ORM\Column]
    private int $priceMini;

    #[ORM\Column]
    private int $priceMaxi;

    #[ORM\Column]
    private int $imgId;

    // categoryCode
    #[ORM\Column(nullable: true)]
    private ?string $categoryCode;

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

    public function setUuid(string $uuid): PublicEvent
    {
        $this->uuid = $uuid;

        return $this;
    }

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

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

        return $this;
    }

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

    public function setName(string $name): PublicEvent
    {
        $this->name = $name;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(?string $description): PublicEvent
    {
        $this->description = $description;

        return $this;
    }

    public function getUrl(): ?string
    {
        return $this->url;
    }

    public function setUrl(?string $url): PublicEvent
    {
        $this->url = $url;

        return $this;
    }

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

    public function setDatetimeStart(\DateTime $datetimeStart): PublicEvent
    {
        $this->datetimeStart = $datetimeStart;

        return $this;
    }

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

    public function setDatetimeEnd(\DateTime $datetimeEnd): PublicEvent
    {
        $this->datetimeEnd = $datetimeEnd;

        return $this;
    }

    public function getCity(): ?string
    {
        return $this->city;
    }

    public function setCity(?string $city): PublicEvent
    {
        $this->city = $city;

        return $this;
    }

    public function getPostalCode(): ?string
    {
        return $this->postalCode;
    }

    public function setPostalCode(?string $postalCode): PublicEvent
    {
        $this->postalCode = $postalCode;

        return $this;
    }

    public function getStreetAddress(): ?string
    {
        return $this->streetAddress;
    }

    public function setStreetAddress(?string $streetAddress): PublicEvent
    {
        $this->streetAddress = $streetAddress;

        return $this;
    }

    public function getLongitude(): ?float
    {
        return $this->longitude;
    }

    public function setLongitude(?float $longitude): PublicEvent
    {
        $this->longitude = $longitude;

        return $this;
    }

    public function getLatitude(): ?float
    {
        return $this->latitude;
    }

    public function setLatitude(?float $latitude): PublicEvent
    {
        $this->latitude = $latitude;

        return $this;
    }

    public function getRoomName(): ?string
    {
        return $this->roomName;
    }

    public function setRoomName(?string $roomName): PublicEvent
    {
        $this->roomName = $roomName;

        return $this;
    }

    public function getRoomDescription(): ?string
    {
        return $this->roomDescription;
    }

    public function setRoomDescription(?string $roomDescription): PublicEvent
    {
        $this->roomDescription = $roomDescription;

        return $this;
    }

    public function getRoomLocalisation(): ?string
    {
        return $this->roomLocalisation;
    }

    public function setRoomLocalisation(?string $roomLocalisation): PublicEvent
    {
        $this->roomLocalisation = $roomLocalisation;

        return $this;
    }

    public function getRoomCapacity(): ?string
    {
        return $this->roomCapacity;
    }

    public function setRoomCapacity(?string $roomCapacity): PublicEvent
    {
        $this->roomCapacity = $roomCapacity;

        return $this;
    }

    public function getRoomFloorSize(): ?string
    {
        return $this->roomFloorSize;
    }

    public function setRoomFloorSize(?string $roomFloorSize): PublicEvent
    {
        $this->roomFloorSize = $roomFloorSize;

        return $this;
    }

    public function getStructureLongitude(): ?float
    {
        return $this->structureLongitude;
    }

    public function setStructureLongitude(?float $structureLongitude): self
    {
        $this->structureLongitude = $structureLongitude;

        return $this;
    }

    public function getStructureLatitude(): ?float
    {
        return $this->structureLatitude;
    }

    public function setStructureLatitude(?float $structureLatitude): self
    {
        $this->structureLatitude = $structureLatitude;

        return $this;
    }

    public function getImageUrl(): ?string
    {
        return $this->imageUrl;
    }

    public function setImageUrl(?string $imageUrl): PublicEvent
    {
        $this->imageUrl = $imageUrl;

        return $this;
    }

    public function getThumbnailUrl(): ?string
    {
        return $this->thumbnailUrl;
    }

    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
     */
    public function setCategories(?array $categories): PublicEvent
    {
        $this->categories = $categories;

        return $this;
    }

    /**
     * @return string[]|null returns a list of gender identifiers as strings
     */
    public function getGender(): ?array
    {
        return $this->gender;
    }

    /**
     * @param string[]|null $gender gender identifiers as a list of strings
     *
     * @return $this
     */
    public function setGender(?array $gender): PublicEvent
    {
        $this->gender = $gender;

        return $this;
    }

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

    public function setOrigin(string $origin): PublicEvent
    {
        $this->origin = $origin;

        return $this;
    }

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

    public function setEntityId(int $entityId): PublicEvent
    {
        $this->entityId = $entityId;

        return $this;
    }

    public function getPriceMini(): int
    {
        return $this->priceMini;
    }

    public function setPriceMini(int $priceMini): PublicEvent
    {
        $this->priceMini = $priceMini;

        return $this;
    }

    public function getPriceMaxi(): int
    {
        return $this->priceMaxi;
    }

    public function setPriceMaxi(int $priceMaxi): PublicEvent
    {
        $this->priceMaxi = $priceMaxi;

        return $this;
    }

    public function getImgId(): int
    {
        return $this->imgId;
    }

    public function setImgId(int $imgId): PublicEvent
    {
        $this->imgId = $imgId;

        return $this;
    }

    public function getCategoryCode(): ?string
    {
        return $this->categoryCode;
    }

    public function setCategoryCode(?string $categoryCode): PublicEvent
    {
        $this->categoryCode = $categoryCode;

        return $this;
    }

    public function getStructureName(): string
    {
        return $this->structureName;
    }

    public function setStructureName(string $structureName): PublicEvent
    {
        $this->structureName = $structureName;

        return $this;
    }
}
