src/Products/NotificationsBundle/Entity/ContactAttempts/VoiceContactAttempt.php line 20

Open in your IDE?
  1. <?php
  2. namespace Products\NotificationsBundle\Entity\ContactAttempts;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Products\NotificationsBundle\Entity\AbstractContactAttempt;
  5. use Products\NotificationsBundle\Entity\Recipients\PhoneRecipient;
  6. use Products\NotificationsBundle\Entity\Recording;
  7. /**
  8.  * Class VoiceContactAttempt
  9.  * @package Products\NotificationsBundle\Entity\ContactAttempts
  10.  *
  11.  * @method PhoneRecipient getRecipient()
  12.  *
  13.  * @ORM\Entity(
  14.  *     repositoryClass = "Products\NotificationsBundle\Doctrine\Repository\ContactAttempts\VoiceContactAttemptRepository",
  15.  * )
  16.  */
  17. class VoiceContactAttempt extends AbstractTransactionalContactAttempt
  18. {
  19.     const DISCR 'voice';
  20.     /**
  21.      * @see https://support.twilio.com/hc/en-us/articles/223132547-What-are-the-Possible-Call-Statuses-and-What-do-They-Mean-
  22.      * @see https://www.twilio.com/docs/voice/api/call-resource#statuscallback
  23.      * @see https://www.twilio.com/docs/voice/twiml#callstatus-values
  24.      */
  25.     const STATUSES = [
  26.         ...self::PENDING_STATUSES,
  27.         ...self::SUCCESSFUL_STATUSES,
  28.         ...self::FAILED_STATUSES,
  29.     ];
  30.     const PENDING_STATUSES = [
  31.         ...AbstractContactAttempt::PENDING_STATUSES,
  32.         'voice.queued',
  33.         'voice.initiated',
  34.         'voice.ringing',
  35.         'voice.in-progress',
  36.     ];
  37.     const SUCCESSFUL_STATUSES = [
  38.         ...AbstractContactAttempt::SUCCESSFUL_STATUSES,
  39.         'voice.completed',
  40.     ];
  41.     const FAILED_STATUSES = [
  42.         ...AbstractContactAttempt::FAILED_STATUSES,
  43.         'voice.busy',
  44.         'voice.no-answer',
  45.         'voice.canceled',
  46.         'voice.failed',
  47.     ];
  48.     /**
  49.      * @var string|null
  50.      *
  51.      * @ORM\Column(
  52.      *     type = "string",
  53.      *     nullable = true,
  54.      * )
  55.      */
  56.     protected ?string $country null;
  57.     /**
  58.      * @var string|null
  59.      *
  60.      * @ORM\Column(
  61.      *     type = "string",
  62.      *     nullable = true,
  63.      * )
  64.      */
  65.     protected ?string $state null;
  66.     /**
  67.      * @var string|null
  68.      *
  69.      * @ORM\Column(
  70.      *     type = "string",
  71.      *     nullable = true,
  72.      * )
  73.      */
  74.     protected ?string $city null;
  75.     /**
  76.      * @var string|null
  77.      *
  78.      * @ORM\Column(
  79.      *     type = "string",
  80.      *     nullable = true,
  81.      * )
  82.      */
  83.     protected ?string $zip null;
  84.     /**
  85.      * @var int|null
  86.      *
  87.      * @ORM\Column(
  88.      *     type = "integer",
  89.      *     nullable = true,
  90.      * )
  91.      */
  92.     protected ?int $duration null;
  93.     /**
  94.      * @var string|null
  95.      *
  96.      * @ORM\Column(
  97.      *     type = "string",
  98.      *     nullable = true,
  99.      * )
  100.      */
  101.     protected ?string $answer null;
  102.     /**
  103.      * @var int|null
  104.      *
  105.      * @ORM\Column(
  106.      *     type = "integer",
  107.      *     nullable = true,
  108.      * )
  109.      */
  110.     protected ?int $sequenceNumber null;
  111.     /**
  112.      * @return string|null
  113.      */
  114.     public function getCountry(): ?string
  115.     {
  116.         return $this->country;
  117.     }
  118.     /**
  119.      * @param string|null $country
  120.      * @return $this
  121.      */
  122.     public function setCountry(?string $country): self
  123.     {
  124.         $this->country $country;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return string|null
  129.      */
  130.     public function getState(): ?string
  131.     {
  132.         return $this->state;
  133.     }
  134.     /**
  135.      * @param string|null $state
  136.      * @return $this
  137.      */
  138.     public function setState(?string $state): self
  139.     {
  140.         $this->state $state;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return string|null
  145.      */
  146.     public function getCity(): ?string
  147.     {
  148.         return $this->city;
  149.     }
  150.     /**
  151.      * @param string|null $city
  152.      * @return $this
  153.      */
  154.     public function setCity(?string $city): self
  155.     {
  156.         $this->city $city;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return string|null
  161.      */
  162.     public function getZip(): ?string
  163.     {
  164.         return $this->zip;
  165.     }
  166.     /**
  167.      * @param string|null $zip
  168.      * @return $this
  169.      */
  170.     public function setZip(?string $zip): self
  171.     {
  172.         $this->zip $zip;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return int|null
  177.      */
  178.     public function getDuration(): ?int
  179.     {
  180.         return $this->duration;
  181.     }
  182.     /**
  183.      * @param int|null $duration
  184.      * @return $this
  185.      */
  186.     public function setDuration(?int $duration): self
  187.     {
  188.         $this->duration $duration;
  189.         return $this;
  190.     }
  191.     /**
  192.      * {@inheritDoc}
  193.      */
  194.     public function getExtras(): array
  195.     {
  196.         return [
  197.             'answer' => $this->getAnswer(),
  198.             'duration' => $this->getDuration(),
  199.             'county' => $this->getCountry(),
  200.             'state' => $this->getState(),
  201.             'city' => $this->getCity(),
  202.             'zip' => $this->getZip(),
  203.         ];
  204.     }
  205.     /**
  206.      * @return string|null
  207.      */
  208.     public function getAnswer(): ?string
  209.     {
  210.         return $this->answer;
  211.     }
  212.     /**
  213.      * @param string|null $answer
  214.      * @return $this
  215.      */
  216.     public function setAnswer(?string $answer): self
  217.     {
  218.         $this->answer $answer;
  219.         return $this;
  220.     }
  221.     /**
  222.      * @return int|null
  223.      */
  224.     public function getSequenceNumber(): ?int
  225.     {
  226.         return $this->sequenceNumber;
  227.     }
  228.     /**
  229.      * @param int|null $sequenceNumber
  230.      * @return $this
  231.      */
  232.     public function setSequenceNumber(?int $sequenceNumber): self
  233.     {
  234.         $this->sequenceNumber $sequenceNumber;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return bool
  239.      */
  240.     public function hasRecording(): bool
  241.     {
  242.         $recording $this->getMessage()->getRecording();
  243.         return $recording instanceof Recording && $recording->isRecorded();
  244.     }
  245. }