<?php
namespace ZapierApi\Entity;
use App\Utility\DateTimeUtility;
use App\Utility\ReflectionHelper;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="zapier_api_webhook_subscriptions"
* )
*/
class ZapierWebhookSubscription
{
public const CONTEXT_ID_OUTGOING_WHATSAPP_MESSAGE = 0;
public function __construct(
int $contextId,
string $hookUrl,
string $zapId
) {
if (!ReflectionHelper::hasConstWithValue(
self::class,
'CONTEXT_ID_',
$contextId)
) {
throw new InvalidArgumentException("Value '$contextId' not allowed for contextId.");
}
$this->createdAt = DateTimeUtility::createDateTimeUtc();
$this->contextId = $contextId;
$this->hookUrl = $hookUrl;
$this->zapId = $zapId;
}
/**
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
*
* @ORM\Column(name="id", type="guid")
*
* @ORM\Id
*/
private ?string $id;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private DateTime $createdAt;
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
/**
* @ORM\Column(type="smallint", name="context_id", nullable=false, options={"unsigned"=true})
*/
private int $contextId;
public function getContextId(): int
{
return $this->contextId;
}
/**
* @ORM\Column(name="hook_url", type="text", length=512, nullable=false)
*/
private string $hookUrl;
public function getHookUrl(): string
{
return $this->hookUrl;
}
/**
* @ORM\Column(name="zap_id", type="text", length=512, nullable=false)
*/
private string $zapId;
public function getZapId(): string
{
return $this->zapId;
}
}