MobytUserStatus.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Mobyt;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use App\ApiResources\ApiResourcesInterface;
  8. use App\State\Provider\Mobyt\MobytUserStatusProvider;
  9. /**
  10. * Statut de l'utilisateur Mobyt correspondant à l'organization donnée en paramètre.
  11. */
  12. #[ApiResource(
  13. operations: [
  14. new Get(
  15. uriTemplate: '/mobyt/status/{organizationId}',
  16. requirements: ['organizationId' => '\\d+'],
  17. security: '(is_granted("ROLE_ADMIN_CORE") or
  18. is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or
  19. is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or
  20. is_granted("ROLE_FINANCIAL_MANAGER_CORE") or
  21. is_granted("ROLE_TEXTO")
  22. ) and object.getOrganizationId() == user.getOrganization().getId()',
  23. provider: MobytUserStatusProvider::class
  24. ),
  25. ]
  26. )]
  27. class MobytUserStatus implements ApiResourcesInterface
  28. {
  29. #[ApiProperty(identifier: true)]
  30. private int $organizationId;
  31. /**
  32. * Is there a Mobyt account active for this user.
  33. */
  34. private bool $active = false;
  35. /**
  36. * Amount of sms remaining.
  37. */
  38. private int $amount = 0;
  39. /**
  40. * Money remaining.
  41. */
  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. }