<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
/**
* A demand entity represents the public, not necessarily binding, not necessarily exclusive, announcement by an organization or person to seek a certain type of goods or services. For describing demand using this type, the very same properties used for Offer apply.
*
* @see https://schema.org/Demand
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'Endorsement',
itemOperations: [
'get' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'endorsement:item:get',
'enable_max_depth' => true
]
],
'put' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'endorsement:item:put',
'enable_max_depth' => true
],
'denormalization_context' => [
'groups' => 'endorsement:item:put',
'enable_max_depth' => true
]
],
'delete' => [
// 'security' => "is_granted('ROLE_USER')",
]
],
collectionOperations: [
'get' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => ['endorsement:collection:get', 'createdAt'],
'enable_max_depth' => true
]
],
'post' => [
// 'security' => "is_granted('ROLE_USER')",
'normalization_context' => [
'groups' => 'endorsement:collection:post',
'enable_max_depth' => true
],
'denormalization_context' => [
'groups' => 'endorsement:collection:post',
'enable_max_depth' => true
]
],
]
)]
#[ApiFilter(SearchFilter::class, properties: [
'policy' => 'exact',
'endorsementNumber' => 'start',
'endorsementType' => 'exact',
'endorsementValue' => 'start',
'limitValue' => 'start',
'createdAt' => 'start',
])]
#[ApiFilter(OrderFilter::class, properties: [
'endorsementNumber',
'endorsementType',
'endorsementValue',
'limitValue',
'createdAt'
])]
class Endorsement
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(type: 'integer')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?int $id = null;
/**
* @see _:endorsementNumber
*/
#[ORM\Column(type: 'string')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Assert\Type('string')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
'policy:item:get',
])]
private ?string $endorsementNumber = null;
/**
* The beginning of the availability of the product or service included in the offer.
*
* @see https://schema.org/availabilityStarts
*/
#[ORM\Column(type: 'date')]
#[ApiProperty(iri: 'https://schema.org/availabilityStarts')]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?\DateTimeInterface $availabilityStarts = null;
/**
* The end of the availability of the product or service included in the offer.
*
* @see https://schema.org/availabilityEnds
*/
#[ORM\Column(type: 'date')]
#[ApiProperty(iri: 'https://schema.org/availabilityEnds')]
#[Assert\Type(\DateTimeInterface::class)]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?\DateTimeInterface $availabilityEnds = null;
/**
* @see _:endorsementValue
*/
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $endorsementValue = null;
/**
* @see _:endorsementType
*/
#[ORM\Column(type: 'string')]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Assert\Type('string')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?string $endorsementType = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $limitValue = null;
/**
* @see _:observations
*/
#[ORM\Column(type: 'text', nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Text')]
#[Assert\Type('string')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?string $observations = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $eligibleQuantity = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/interestRate')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $interestRate = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $insurancePremium = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $interestFee = null;
#[ORM\Column(type: 'float')]
#[ApiProperty(iri: 'https://schema.org/Number')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private ?float $commission = null;
#[ORM\ManyToOne(targetEntity: Policy::class, inversedBy: 'endorsements')]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private $policy;
#[ORM\OneToOne(inversedBy: 'endorsement', targetEntity: Media::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[Groups([
'endorsement:collection:get',
'endorsement:collection:post',
'endorsement:item:get',
'endorsement:item:put',
])]
private $upload;
public function getId(): ?int
{
return $this->id;
}
/**
* @param string|null $endorsementNumber
*/
public function setEndorsementNumber($endorsementNumber): void
{
$this->endorsementNumber = $endorsementNumber;
}
public function getEndorsementNumber(): ?string
{
return $this->endorsementNumber;
}
public function setAvailabilityStarts(?\DateTimeInterface $availabilityStarts): void
{
$this->availabilityStarts = $availabilityStarts;
}
public function getAvailabilityStarts(): ?\DateTimeInterface
{
return $this->availabilityStarts;
}
public function setAvailabilityEnds(?\DateTimeInterface $availabilityEnds): void
{
$this->availabilityEnds = $availabilityEnds;
}
public function getAvailabilityEnds(): ?\DateTimeInterface
{
return $this->availabilityEnds;
}
/**
* @param float|null $endorsementValue
*/
public function setEndorsementValue($endorsementValue): void
{
$this->endorsementValue = $endorsementValue;
}
public function getEndorsementValue(): ?float
{
return $this->endorsementValue;
}
/**
* @param string|null $endorsementType
*/
public function setEndorsementType($endorsementType): void
{
$this->endorsementType = $endorsementType;
}
public function getEndorsementType(): ?string
{
return $this->endorsementType;
}
/**
* @param string|null $observations
*/
public function setObservations($observations): void
{
$this->observations = $observations;
}
public function getObservations(): ?string
{
return $this->observations;
}
/**
* @param float|null $eligibleQuantity
*/
public function setEligibleQuantity($eligibleQuantity): void
{
$this->eligibleQuantity = $eligibleQuantity;
}
public function getEligibleQuantity(): ?float
{
return $this->eligibleQuantity;
}
/**
* @param float|null $interestRate
*/
public function setInterestRate($interestRate): void
{
$this->interestRate = $interestRate;
}
public function getInterestRate(): ?float
{
return $this->interestRate;
}
/**
* @param float|null $insurancePremium
*/
public function setInsurancePremium($insurancePremium): void
{
$this->insurancePremium = $insurancePremium;
}
public function getInsurancePremium(): ?float
{
return $this->insurancePremium;
}
/**
* @param float|null $interestFee
*/
public function setInterestFee($interestFee): void
{
$this->interestFee = $interestFee;
}
public function getInterestFee(): ?float
{
return $this->interestFee;
}
/**
* @param float|null $commission
*/
public function setCommission($commission): void
{
$this->commission = $commission;
}
public function getCommission(): ?float
{
return $this->commission;
}
public function getPolicy(): ?Policy
{
return $this->policy;
}
public function setPolicy(?Policy $policy): self
{
$this->policy = $policy;
return $this;
}
public function getUpload(): ?Media
{
return $this->upload;
}
public function setUpload(?Media $upload): self
{
$this->upload = $upload;
return $this;
}
public function getLimitValue(): ?float
{
return $this->limitValue;
}
public function setLimitValue(?float $limitValue): self
{
$this->limitValue = $limitValue;
return $this;
}
}