DolibarrAccount.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Dolibarr;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8. * Données de l'organization retournées par l'API Dolibarr
  9. * (aussi nommé 'ThirdParty' ou 'Society' dans dolibarr)
  10. */
  11. #[ApiResource(
  12. itemOperations: [
  13. 'get' => [
  14. 'security' => '(is_granted("ROLE_ADMIN_CORE") or
  15. is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or
  16. is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or
  17. is_granted("ROLE_FINANCIAL_MANAGER_CORE")
  18. ) and object.getOrganizationId() == user.getOrganization().getId()',
  19. 'method' => 'GET',
  20. 'path' => '/dolibarr/account/{organizationId}',
  21. 'requirements' => ['organizationId' => '\d+'],
  22. 'normalization_context' => [
  23. 'groups' => ['dolibarr_get']
  24. ],
  25. ],
  26. ],
  27. compositeIdentifier: false,
  28. )]
  29. class DolibarrAccount
  30. {
  31. #[ApiProperty(identifier: true)]
  32. #[Groups('dolibarr_get')]
  33. private int $organizationId;
  34. /**
  35. * Dolibarr societies pk
  36. */
  37. #[Groups('dolibarr_get')]
  38. private int $socId;
  39. /**
  40. * Opentalent client ref
  41. */
  42. #[Groups('dolibarr_get')]
  43. private string $clientNumber = "";
  44. /**
  45. * Opentalent product owned
  46. */
  47. #[Groups('dolibarr_get')]
  48. private string $product = "";
  49. /**
  50. * Contract and services currently active
  51. */
  52. #[Groups('dolibarr_get')]
  53. private ?object $contract = null;
  54. /**
  55. * Last bills
  56. */
  57. #[Groups('dolibarr_get')]
  58. private array $bills = [];
  59. public function getOrganizationId(): int
  60. {
  61. return $this->organizationId;
  62. }
  63. public function setOrganizationId(int $organizationId): void
  64. {
  65. $this->organizationId = $organizationId;
  66. }
  67. public function getSocId(): int
  68. {
  69. return $this->socId;
  70. }
  71. public function setSocId(int $socId): void
  72. {
  73. $this->socId = $socId;
  74. }
  75. public function getClientNumber(): string
  76. {
  77. return $this->clientNumber;
  78. }
  79. public function setClientNumber(string $clientNumber): void
  80. {
  81. $this->clientNumber = $clientNumber;
  82. }
  83. public function getProduct(): string
  84. {
  85. return $this->product;
  86. }
  87. public function setProduct(string $product): void
  88. {
  89. $this->product = $product;
  90. }
  91. public function getContract(): ?object
  92. {
  93. return $this->contract;
  94. }
  95. public function setContract(?object $contract): void
  96. {
  97. $this->contract = $contract;
  98. }
  99. public function getBills(): array
  100. {
  101. return $this->bills;
  102. }
  103. public function setBills(array $bills): void
  104. {
  105. $this->bills = $bills;
  106. }
  107. public function addBill(DolibarrBill $bill): void
  108. {
  109. $this->bills[] = $bill;
  110. }
  111. }