<?php
namespace Products\NotificationsBundle\Entity\ContactAttempts;
use Doctrine\ORM\Mapping as ORM;
use Products\NotificationsBundle\Entity\AbstractContactAttempt;
use Products\NotificationsBundle\Entity\Recipients\PhoneRecipient;
use Products\NotificationsBundle\Entity\Recording;
/**
* Class VoiceContactAttempt
* @package Products\NotificationsBundle\Entity\ContactAttempts
*
* @method PhoneRecipient getRecipient()
*
* @ORM\Entity(
* repositoryClass = "Products\NotificationsBundle\Doctrine\Repository\ContactAttempts\VoiceContactAttemptRepository",
* )
*/
class VoiceContactAttempt extends AbstractTransactionalContactAttempt
{
const DISCR = 'voice';
/**
* @see https://support.twilio.com/hc/en-us/articles/223132547-What-are-the-Possible-Call-Statuses-and-What-do-They-Mean-
* @see https://www.twilio.com/docs/voice/api/call-resource#statuscallback
* @see https://www.twilio.com/docs/voice/twiml#callstatus-values
*/
const STATUSES = [
...self::PENDING_STATUSES,
...self::SUCCESSFUL_STATUSES,
...self::FAILED_STATUSES,
];
const PENDING_STATUSES = [
...AbstractContactAttempt::PENDING_STATUSES,
'voice.queued',
'voice.initiated',
'voice.ringing',
'voice.in-progress',
];
const SUCCESSFUL_STATUSES = [
...AbstractContactAttempt::SUCCESSFUL_STATUSES,
'voice.completed',
];
const FAILED_STATUSES = [
...AbstractContactAttempt::FAILED_STATUSES,
'voice.busy',
'voice.no-answer',
'voice.canceled',
'voice.failed',
];
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $country = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $state = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $city = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $zip = null;
/**
* @var int|null
*
* @ORM\Column(
* type = "integer",
* nullable = true,
* )
*/
protected ?int $duration = null;
/**
* @var string|null
*
* @ORM\Column(
* type = "string",
* nullable = true,
* )
*/
protected ?string $answer = null;
/**
* @var int|null
*
* @ORM\Column(
* type = "integer",
* nullable = true,
* )
*/
protected ?int $sequenceNumber = null;
/**
* @return string|null
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @param string|null $country
* @return $this
*/
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
/**
* @return string|null
*/
public function getState(): ?string
{
return $this->state;
}
/**
* @param string|null $state
* @return $this
*/
public function setState(?string $state): self
{
$this->state = $state;
return $this;
}
/**
* @return string|null
*/
public function getCity(): ?string
{
return $this->city;
}
/**
* @param string|null $city
* @return $this
*/
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
/**
* @return string|null
*/
public function getZip(): ?string
{
return $this->zip;
}
/**
* @param string|null $zip
* @return $this
*/
public function setZip(?string $zip): self
{
$this->zip = $zip;
return $this;
}
/**
* @return int|null
*/
public function getDuration(): ?int
{
return $this->duration;
}
/**
* @param int|null $duration
* @return $this
*/
public function setDuration(?int $duration): self
{
$this->duration = $duration;
return $this;
}
/**
* {@inheritDoc}
*/
public function getExtras(): array
{
return [
'answer' => $this->getAnswer(),
'duration' => $this->getDuration(),
'county' => $this->getCountry(),
'state' => $this->getState(),
'city' => $this->getCity(),
'zip' => $this->getZip(),
];
}
/**
* @return string|null
*/
public function getAnswer(): ?string
{
return $this->answer;
}
/**
* @param string|null $answer
* @return $this
*/
public function setAnswer(?string $answer): self
{
$this->answer = $answer;
return $this;
}
/**
* @return int|null
*/
public function getSequenceNumber(): ?int
{
return $this->sequenceNumber;
}
/**
* @param int|null $sequenceNumber
* @return $this
*/
public function setSequenceNumber(?int $sequenceNumber): self
{
$this->sequenceNumber = $sequenceNumber;
return $this;
}
/**
* @return bool
*/
public function hasRecording(): bool
{
$recording = $this->getMessage()->getRecording();
return $recording instanceof Recording && $recording->isRecorded();
}
}