MobytUserStatus.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Mobyt;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8. * Statut de l'utilisateur Mobyt correspondant à l'organization donnée en paramètre
  9. */
  10. #[ApiResource(
  11. itemOperations: [
  12. 'get' => [
  13. 'security' => 'is_granted("ROLE_TEXTO") and object.getOrganizationId() == user.getOrganization().getId()',
  14. 'method' => 'GET',
  15. 'path' => '/mobyt/status/{organizationId}',
  16. 'requirements' => ['organizationId' => '\d+'],
  17. 'normalization_context' => [
  18. 'groups' => ['mobyt_get']
  19. ],
  20. ],
  21. ]
  22. )]
  23. class MobytUserStatus
  24. {
  25. #[ApiProperty(identifier: true)]
  26. #[Groups('mobyt_get')]
  27. private int $organizationId;
  28. /**
  29. * Is there a Mobyt account active for this user
  30. */
  31. #[Groups('mobyt_get')]
  32. private bool $active = false;
  33. /**
  34. * Amount of sms remaining
  35. */
  36. #[Groups('mobyt_get')]
  37. private int $amount = 0;
  38. /**
  39. * Money remaining
  40. */
  41. #[Groups('mobyt_get')]
  42. private float $money = 0;
  43. public function getOrganizationId(): int
  44. {
  45. return $this->organizationId;
  46. }
  47. public function setOrganizationId(int $organizationId): void
  48. {
  49. $this->organizationId = $organizationId;
  50. }
  51. public function isActive(): bool
  52. {
  53. return $this->active;
  54. }
  55. public function setActive(bool $active): void
  56. {
  57. $this->active = $active;
  58. }
  59. public function getAmount(): int
  60. {
  61. return $this->amount;
  62. }
  63. public function setAmount(int $amount): void
  64. {
  65. $this->amount = $amount;
  66. }
  67. public function getMoney(): float
  68. {
  69. return $this->money;
  70. }
  71. public function setMoney(float $money): void
  72. {
  73. $this->money = $money;
  74. }
  75. }