DolibarrContract.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Dolibarr;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use App\ApiResources\ApiResourcesInterface;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use JetBrains\PhpStorm\Pure;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. /**
  13. * Contract of a society, retrieved from dolibarr.
  14. */
  15. #[ApiResource(
  16. operations: [
  17. new Get(),
  18. ]
  19. )]
  20. class DolibarrContract implements ApiResourcesInterface
  21. {
  22. /**
  23. * Reference of the dolibarr contract.
  24. */
  25. #[ApiProperty(identifier: true)]
  26. #[Groups('dolibarr_get')]
  27. private string $ref;
  28. /**
  29. * Id of the society.
  30. */
  31. #[Groups('dolibarr_get')]
  32. private int $socId;
  33. /**
  34. * Lines (services) included in the current contract.
  35. */
  36. #[Groups('dolibarr_get')]
  37. private Collection $lines;
  38. #[Pure]
  39. public function __construct()
  40. {
  41. $this->lines = new ArrayCollection();
  42. }
  43. public function getRef(): string
  44. {
  45. return $this->ref;
  46. }
  47. public function setRef(string $ref): self
  48. {
  49. $this->ref = $ref;
  50. return $this;
  51. }
  52. public function getSocId(): int
  53. {
  54. return $this->socId;
  55. }
  56. public function setSocId(int $socId): self
  57. {
  58. $this->socId = $socId;
  59. return $this;
  60. }
  61. public function getLines(): Collection
  62. {
  63. return $this->lines;
  64. }
  65. public function addLine(DolibarrContractLine $line): self
  66. {
  67. $this->lines[] = $line;
  68. return $this;
  69. }
  70. public function removeBill(DolibarrContractLine $line): self
  71. {
  72. $this->lines->removeElement($line);
  73. return $this;
  74. }
  75. }