<?php
namespace Products\NotificationsBundle\Entity\ContactAttempts;
use Doctrine\ORM\Mapping as ORM;
use Products\NotificationsBundle\Entity\AbstractContactAttempt;
use Products\NotificationsBundle\Entity\Recipients\PhoneRecipient;
/**
* Class SmsContactAttempt
* @package Products\NotificationsBundle\Entity\ContactAttepmts
*
* @method PhoneRecipient getRecipient()
*
* @ORM\Entity(
* repositoryClass = "Products\NotificationsBundle\Doctrine\Repository\ContactAttempts\SmsContactAttemptRepository",
* )
*/
class SmsContactAttempt extends AbstractTransactionalContactAttempt
{
const DISCR = 'sms';
/**
* @see https://support.twilio.com/hc/en-us/articles/223134347-What-are-the-Possible-SMS-and-MMS-Message-Statuses-and-What-do-They-Mean-
* @see https://www.twilio.com/docs/sms/api/message-resource#message-status-values
*/
const STATUSES = [
...self::PENDING_STATUSES,
...self::SUCCESSFUL_STATUSES,
...self::FAILED_STATUSES,
];
const PENDING_STATUSES = [
...AbstractContactAttempt::PENDING_STATUSES,
'sms.accepted',
'sms.scheduled',
'sms.queued',
'sms.sending',
'sms.sent',
'sms.delivery_unknown',
];
const SUCCESSFUL_STATUSES = [
...AbstractContactAttempt::SUCCESSFUL_STATUSES,
'sms.delivered',
];
const FAILED_STATUSES = [
...AbstractContactAttempt::FAILED_STATUSES,
'sms.blocked',
'sms.undelivered',
'sms.failed',
];
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $code = null;
/**
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string|null $code
* @return $this
*/
public function setCode(?string $code): self
{
$this->code = $code ?: null;
return $this;
}
}