<?php
namespace App\V4\Model\Listing;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Model\IriNormalizableInterface;
use App\Model\NormalizeAsIRITrait;
use App\Model\Traits\ImportableObjectTrait;
use App\V4\Model\ListingItem\ListingItem;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* shortName="V4/Listing",
* attributes={
* "api_allow_update": true
* },
* collectionOperations={
* "get": {
* "normalization_context": {
* "groups": {"listing:list"}
* },
* },
* "get_form": {
* "method": "GET",
* "path": "/v4/listings/form",
* "controller": App\V4\Controller\Listing\GetListingFormAction::class
* },
* "post_listing": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
* "path": "/v4/listings",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"listing:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* },
* itemOperations={
* "get": {
* "normalization_context": {
* "groups": {"listing:list"}
* },
* },
* "get_form": {
* "method": "GET",
* "path": "/v4/listings/{id}/form",
* "controller": App\V4\Controller\Listing\GetListingFormAction::class,
* },
* "put_listing": {
* "method": "POST",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
* "path": "/v4/listings/{id}",
* "input_formats": {
* "multipart": {"multipart/form-data"}
* },
* "normalization_context": {
* "groups": {"listing:read"}
* },
* "denormalization_context": {
* "groups": {}
* }
* },
* "delete_listing": {
* "method": "DELETE",
* "deserialize": false,
* "write": false,
* "controller": "App\V4\Controller\Listing\ListingDataPersisterAction",
* "path": "/v4/listings/{id}",
* }
* }
* )
*/
class Listing implements IriNormalizableInterface
{
use ImportableObjectTrait;
use NormalizeAsIRITrait;
const CODE_LISTING_ORIGIN = 'Origine';
const CODE_LISTING_TYPE = 'Type';
const CODE_LISTING_FORM_JURIDIQUE = 'Forme Juridique';
const CODE_LISTING_STRUCTURE_TYPE = 'Structure Type';
const CODE_LISTING_WORKFORCE = 'Workforce';
const CODE_LISTING_NAF = 'Naf';
const CODE_LISTING_TVA = 'TVA';
const CODE_LISTING_SERVICE = 'Service';
const CODE_LISTING_POTENTIAL = 'Potential';
const CODE_LISTING_CIVILITY = 'Civility';
const CODE_LISTING_QUOTE_SECTION = 'QuoteSection';
const NAME_LISTING_QUOTE_SECTION = 'Section Devis';
/**
* @ApiProperty(identifier=true)
*
* @var string
*
* @Groups({"listing:list", "listing:read"})
*/
private $id;
/**
* @var string
*
* @Assert\NotNull()
*
* @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
*/
private $code;
/**
* @var string
*
* @Assert\NotNull()
*
* @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
*/
private $name;
/**
* @var string
*
* @Groups({"listing:list", "listing:read", "listing:write"})
*/
private $customerId;
/**
* @var bool
*
* @Assert\NotNull()
*
* @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
*/
private $isActive = true;
/**
* @var ListingItem[]|ArrayCollection
*
* @Groups({"listing:list", "listing:read", "listing:write", "listing:update"})
*/
private $listingItems;
/**
* @var array
*/
private $fields = [];
public function __construct()
{
$this->listingItems = new ArrayCollection();
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return Listing
*/
public function setId(?string $id): self
{
$this->id = $id;
return $this;
}
/**
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string|null $code
*
* @return Listing
*/
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*
* @return Listing
*/
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getCustomerId(): ?string
{
return $this->customerId;
}
/**
* @param string|null $customerId
*
* @return Listing
*/
public function setCustomerId(?string $customerId): self
{
$this->customerId = $customerId;
return $this;
}
/**
* @return bool
*/
public function getIsActive(): bool
{
return $this->isActive;
}
/**
* @param bool $isActive
*
* @return Listing
*/
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @param ListingItem $listingItem
*
* @return Listing
*/
public function addListingItem(ListingItem $listingItem): self
{
if (!$this->listingItems->contains($listingItem)) {
$this->listingItems[] = $listingItem;
}
return $this;
}
/**
* @return ListingItem[]|Collection
*/
public function getListingItems(): Collection
{
return $this->listingItems;
}
/**
* @param ListingItem $listingItem
*
* @return Listing
*/
public function removeListingItem(ListingItem $listingItem): self
{
if (!$this->listingItems->contains($listingItem)) {
$this->listingItems->removeElement($listingItem);
}
return $this;
}
/**
* @return array|null
*/
public function getFields(): ?array
{
return $this->fields;
}
/**
* @param array|null $fields
*
* @return Listing
*/
public function setFields(?array $fields): self
{
$this->fields = $fields;
return $this;
}
/**
* @return string
*/
public function __toString(): string
{
return $this->getId() ?? '';
}
}