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

Open in your IDE?
  1. <?php
  2. namespace Products\NotificationsBundle\Entity\ContactAttempts;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Products\NotificationsBundle\Entity\AbstractContactAttempt;
  6. use Products\NotificationsBundle\Entity\Recipients\EmailRecipient;
  7. /**
  8.  * Class EmailContactAttempt
  9.  * @package Products\NotificationsBundle\Entity\ContactAttempts
  10.  *
  11.  * @method EmailRecipient getRecipient()
  12.  *
  13.  * @ORM\Entity(
  14.  *     repositoryClass = "Products\NotificationsBundle\Doctrine\Repository\ContactAttempts\EmailContactAttemptRepository",
  15.  * )
  16.  */
  17. class EmailContactAttempt extends AbstractTransactionalContactAttempt
  18. {
  19.     const DISCR 'email';
  20.     /**
  21.      * @see https://sendgrid.com/docs/for-developers/tracking-events/event/
  22.      */
  23.     const STATUSES = [
  24.         ...self::PENDING_STATUSES,
  25.         ...self::SUCCESSFUL_STATUSES,
  26.         ...self::FAILED_STATUSES,
  27.     ];
  28.     const PENDING_STATUSES = [
  29.         ...AbstractContactAttempt::PENDING_STATUSES,
  30.         'email.processed',
  31.         'email.deferred',
  32.     ];
  33.     const SUCCESSFUL_STATUSES = [
  34.         ...AbstractContactAttempt::SUCCESSFUL_STATUSES,
  35.         'email.delivered',
  36.     ];
  37.     const FAILED_STATUSES = [
  38.         ...AbstractContactAttempt::FAILED_STATUSES,
  39.         'email.dropped',
  40.         'email.bounce',
  41.     ];
  42.     /**
  43.      * @var string|null
  44.      *
  45.      * @ORM\Column(
  46.      *     type = "string",
  47.      *     nullable = true,
  48.      * )
  49.      */
  50.     protected ?string $reason null;
  51.     /**
  52.      * @var string|null
  53.      *
  54.      * @ORM\Column(
  55.      *     type = "string",
  56.      *     nullable = true,
  57.      * )
  58.      */
  59.     protected ?string $type null;
  60.     /**
  61.      * @var string|null
  62.      *
  63.      * @ORM\Column(
  64.      *     type = "string",
  65.      *     nullable = true,
  66.      * )
  67.      */
  68.     protected ?string $code null;
  69.     /**
  70.      * @var string|null
  71.      *
  72.      * @ORM\Column(
  73.      *     type = "string",
  74.      *     nullable = true,
  75.      * )
  76.      */
  77.     protected ?string $response null;
  78.     /**
  79.      * @var string|null
  80.      *
  81.      * @ORM\Column(
  82.      *     type = "string",
  83.      *     nullable = true,
  84.      * )
  85.      */
  86.     protected ?string $attempt null;
  87.     /**
  88.      * @var DateTime|null
  89.      *
  90.      * @ORM\Column(
  91.      *     type = "datetime",
  92.      *     nullable = true,
  93.      * )
  94.      */
  95.     protected ?DateTime $openedAt null;
  96.     /**
  97.      * @var DateTime|null
  98.      *
  99.      * @ORM\Column(
  100.      *     type = "datetime",
  101.      *     nullable = true,
  102.      * )
  103.      */
  104.     protected ?DateTime $spammedAt null;
  105.     /**
  106.      * @return string|null
  107.      */
  108.     public function getReason(): ?string
  109.     {
  110.         return $this->reason;
  111.     }
  112.     /**
  113.      * @param string $reason
  114.      * @return $this
  115.      */
  116.     public function setReason(string $reason): self
  117.     {
  118.         $this->reason $reason;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return string|null
  123.      */
  124.     public function getType(): ?string
  125.     {
  126.         return $this->type;
  127.     }
  128.     /**
  129.      * @param string $type
  130.      * @return $this
  131.      */
  132.     public function setType(string $type): self
  133.     {
  134.         $this->type $type;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return string|null
  139.      */
  140.     public function getCode(): ?string
  141.     {
  142.         return $this->code;
  143.     }
  144.     /**
  145.      * @param string $code
  146.      * @return $this
  147.      */
  148.     public function setCode(string $code): self
  149.     {
  150.         $this->code $code;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @return string|null
  155.      */
  156.     public function getResponse(): ?string
  157.     {
  158.         return $this->response;
  159.     }
  160.     /**
  161.      * @param string $response
  162.      * @return $this
  163.      */
  164.     public function setResponse(string $response): self
  165.     {
  166.         $this->response $response;
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return string|null
  171.      */
  172.     public function getAttempt(): ?string
  173.     {
  174.         return $this->attempt;
  175.     }
  176.     /**
  177.      * @param string $attempt
  178.      * @return $this
  179.      */
  180.     public function setAttempt(string $attempt): self
  181.     {
  182.         $this->attempt $attempt;
  183.         return $this;
  184.     }
  185.     /**
  186.      * {@inheritDoc}
  187.      */
  188.     public function getExtras(): array
  189.     {
  190.         return [
  191.             'opened' => $this->getOpenedAt() ? $this->getOpenedAt()->format('Y-m-d h:i:sA') : null,
  192.             'spammed' => $this->getSpammedAt() ? $this->getSpammedAt()->format('Y-m-d h:i:sA') : null,
  193.             'response' => $this->getResponse(),
  194.             'code' => $this->getCode(),
  195.             'type' => $this->getType(),
  196.             'reason' => $this->getReason(),
  197.             'attempt' => $this->getAttempt(),
  198.         ];
  199.     }
  200.     /**
  201.      * @return DateTime|null
  202.      */
  203.     public function getOpenedAt(): ?DateTime
  204.     {
  205.         return $this->openedAt;
  206.     }
  207.     /**
  208.      * @param DateTime|null $openedAt
  209.      * @return self
  210.      */
  211.     public function setOpenedAt(?DateTime $openedAt): self
  212.     {
  213.         $this->openedAt $openedAt;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return DateTime|null
  218.      */
  219.     public function getSpammedAt(): ?DateTime
  220.     {
  221.         return $this->spammedAt;
  222.     }
  223.     /**
  224.      * @param DateTime|null $spammedAt
  225.      * @return self
  226.      */
  227.     public function setSpammedAt(?DateTime $spammedAt): self
  228.     {
  229.         $this->spammedAt $spammedAt;
  230.         return $this;
  231.     }
  232. }