src/ZapierApi/Entity/ZapierWebhookSubscription.php line 18

Open in your IDE?
  1. <?php
  2. namespace ZapierApi\Entity;
  3. use App\Utility\DateTimeUtility;
  4. use App\Utility\ReflectionHelper;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use InvalidArgumentException;
  8. /**
  9. * @ORM\Entity
  10. *
  11. * @ORM\Table(
  12. * name="zapier_api_webhook_subscriptions"
  13. * )
  14. */
  15. class ZapierWebhookSubscription
  16. {
  17. public const CONTEXT_ID_OUTGOING_WHATSAPP_MESSAGE = 0;
  18. public function __construct(
  19. int $contextId,
  20. string $hookUrl,
  21. string $zapId
  22. ) {
  23. if (!ReflectionHelper::hasConstWithValue(
  24. self::class,
  25. 'CONTEXT_ID_',
  26. $contextId)
  27. ) {
  28. throw new InvalidArgumentException("Value '$contextId' not allowed for contextId.");
  29. }
  30. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  31. $this->contextId = $contextId;
  32. $this->hookUrl = $hookUrl;
  33. $this->zapId = $zapId;
  34. }
  35. /**
  36. * @ORM\GeneratedValue(strategy="CUSTOM")
  37. *
  38. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  39. *
  40. * @ORM\Column(name="id", type="guid")
  41. *
  42. * @ORM\Id
  43. */
  44. private ?string $id;
  45. /**
  46. * @ORM\Column(name="created_at", type="datetime", nullable=false)
  47. */
  48. private DateTime $createdAt;
  49. public function getCreatedAt(): DateTime
  50. {
  51. return $this->createdAt;
  52. }
  53. /**
  54. * @ORM\Column(type="smallint", name="context_id", nullable=false, options={"unsigned"=true})
  55. */
  56. private int $contextId;
  57. public function getContextId(): int
  58. {
  59. return $this->contextId;
  60. }
  61. /**
  62. * @ORM\Column(name="hook_url", type="text", length=512, nullable=false)
  63. */
  64. private string $hookUrl;
  65. public function getHookUrl(): string
  66. {
  67. return $this->hookUrl;
  68. }
  69. /**
  70. * @ORM\Column(name="zap_id", type="text", length=512, nullable=false)
  71. */
  72. private string $zapId;
  73. public function getZapId(): string
  74. {
  75. return $this->zapId;
  76. }
  77. }