| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- declare(strict_types=1);
- namespace App\ApiResources\Dolibarr;
- use ApiPlatform\Core\Annotation\ApiProperty;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\ApiResources\ApiResourcesInterface;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use JetBrains\PhpStorm\Pure;
- use Symfony\Component\Serializer\Annotation\Groups;
- /**
- * Données de l'organization retournées par l'API Dolibarr
- * (aussi nommé 'ThirdParty' ou 'Society' dans dolibarr)
- */
- #[ApiResource(
- collectionOperations:[],
- itemOperations: [
- 'get' => [
- 'security' => '(is_granted("ROLE_ADMIN_CORE") or
- is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or
- is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or
- is_granted("ROLE_FINANCIAL_MANAGER_CORE")
- ) and object.getOrganizationId() == user.getOrganization().getId()',
- 'method' => 'GET',
- 'path' => '/dolibarr/account/{organizationId}',
- 'requirements' => ['organizationId' => '\d+'],
- 'normalization_context' => [
- 'groups' => ['dolibarr_get']
- ],
- ],
- ],
- compositeIdentifier: false,
- )]
- class DolibarrAccount implements ApiResourcesInterface
- {
- #[ApiProperty(identifier: true)]
- #[Groups('dolibarr_get')]
- private int $organizationId;
- /**
- * Dolibarr societies pk
- */
- #[Groups('dolibarr_get')]
- private ?int $socId = null;
- /**
- * Opentalent client ref
- */
- #[Groups('dolibarr_get')]
- private string $clientNumber = "";
- /**
- * Opentalent product owned
- */
- #[Groups('dolibarr_get')]
- private string $product = "";
- /**
- * Contract and services currently active
- */
- #[Groups('dolibarr_get')]
- private ?DolibarrContract $contract = null;
- /**
- * Last bills
- */
- #[Groups('dolibarr_get')]
- private Collection $bills;
- #[Pure]
- public function __construct()
- {
- $this->bills = new ArrayCollection();
- }
- public function getOrganizationId(): int
- {
- return $this->organizationId;
- }
- public function setOrganizationId(int $organizationId): self
- {
- $this->organizationId = $organizationId;
- return $this;
- }
- public function getSocId(): ?int
- {
- return $this->socId;
- }
- public function setSocId(?int $socId): self
- {
- $this->socId = $socId;
- return $this;
- }
- public function getClientNumber(): string
- {
- return $this->clientNumber;
- }
- public function setClientNumber(string $clientNumber): self
- {
- $this->clientNumber = $clientNumber;
- return $this;
- }
- public function getProduct(): string
- {
- return $this->product;
- }
- public function setProduct(string $product): self
- {
- $this->product = $product;
- return $this;
- }
- public function getContract(): ?object
- {
- return $this->contract;
- }
- public function setContract(?object $contract): self
- {
- $this->contract = $contract;
- return $this;
- }
- public function getBills(): Collection
- {
- return $this->bills;
- }
- public function addBill(DolibarrBill $bill): self
- {
- $this->bills[] = $bill;
- return $this;
- }
- public function removeBill(DolibarrBill $bill): self
- {
- $this->bills->removeElement($bill);
- return $this;
- }
- }
|