<?php
namespace App\Service\CIC\Legacy\Batchmailer;
class EmailQueueItem implements \Serializable, \JsonSerializable
{
private $id;
private $cid;
private $queue;
private $createdAt;
private $recipients = [];
private $senderName = NULL;
private $replacements = [];
private $releaseAt = NULL;
private $statusCode = NULL;
private $statusText = NULL;
private $firstAttemptedAt = NULL;
private $lastAttemptedAt = NULL;
private $attempts = 0;
private $send_log = NULL;
private $send_code = NULL;
private $mta = 'unknown';
private $thawAt = NULL;
private $trackingCode = NULL;
private $referenceCode = NULL;
private $referenceType = NULL;
private $attachment_uri = NULL;
private $extra = NULL;
private $extraData = [];
public function __construct(?string $data=null) {
if($data)
$this->unserialize($data);
if (empty($this->cid))
$this->cid = bin2hex(random_bytes(16));
if (empty($this->createdOn))
$this->createdAt = new \DateTime();
if (empty($this->releaseAt))
$this->releaseAt = new \DateTime();
if (empty($this->firstAttemptedAt))
$this->firstAttemptedAt = new \DateTime();
if (empty($this->lastAttemptedAt))
$this->lastAttemptedAt = new \DateTime();
if (empty($this->thawAt))
$this->thawAt = new \DateTime();
if (empty($this->trackingCode))
$this->trackingCode = bin2hex(random_bytes(44));
if (empty($this->statusText))
$this->statusText = "STAGGED";
}
public function jsonSerialize()
{
return get_object_vars($this);
}
public function serialize(){
return serialize(get_object_vars($this));
}
public function unserialize($serialized)
{
$properties=get_object_vars($this);
$obj=json_decode($serialized);
if(!is_object($obj))
return;
foreach($properties as $property=>$value) {
if(property_exists($obj,$property)) {
$this->$property=$obj->$property;
}
}
}
public function __toString()
{
return json_encode($this);
}
public function getId(): ?int
{
return $this->id;
}
public function getCid(): ?string
{
return $this->cid;
}
public function getQueue(): ?string
{
return $this->queue;
}
public function setQueue(string $queue): self
{
$this->queue = $queue;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function getRecipients(): ?array
{
return $this->recipients;
}
public function setRecipients(array $recipients): self
{
$this->recipients = $recipients;
return $this;
}
public function getSenderName(): ?string
{
return $this->senderName;
}
public function setSenderName(string $senderName): self
{
$this->senderName = $senderName;
return $this;
}
public function getReplacements(): ?array
{
return $this->replacements;
}
public function setReplacements(array $replacements): self
{
$this->replacements = $replacements;
return $this;
}
public function getReleaseAt(): ?\DateTimeInterface
{
return $this->releaseAt;
}
public function setReleaseAt(\DateTimeInterface $releaseAt): self
{
$this->releaseAt = $releaseAt;
return $this;
}
public function getStatusCode(): ?int
{
return $this->statusCode;
}
public function setStatusCode(int $statusCode): self
{
$this->statusCode = $statusCode;
return $this;
}
public function getStatusText(): ?string
{
return $this->statusText;
}
public function setStatusText(string $statusText): self
{
$this->statusText = $statusText;
return $this;
}
public function getFirstAttemptedAt(): ?\DateTimeInterface
{
return $this->firstAttemptedAt;
}
public function getLastAttemptedAt(): ?\DateTimeInterface
{
return $this->lastAttemptedAt;
}
public function getAttempts(): ?int
{
return $this->attempts;
}
public function getSendLog(): ?string
{
return $this->send_log;
}
public function getSendCode(): ?string
{
return $this->send_code;
}
public function getMta(): ?string
{
return $this->mta;
}
public function setMta(string $mta): self
{
$this->mta = $mta;
return $this;
}
public function getThawAt(): ?\DateTimeInterface
{
return $this->thawAt;
}
public function getTrackingCode(): ?string
{
return $this->trackingCode;
}
public function setTrackingCode(string $trackingCode): self
{
$this->trackingCode = $trackingCode;
return $this;
}
public function getReferenceCode(): ?string
{
return $this->referenceCode;
}
public function setReferenceCode(string $referenceCode): self
{
$this->referenceCode = $referenceCode;
return $this;
}
public function getReferenceType(): ?string
{
return $this->referenceType;
}
public function setReferenceType(string $referenceType): self
{
$this->referenceType = $referenceType;
return $this;
}
public function setFirstAttemptedAt($firstAttemptedAt): self
{
$this->firstAttemptedAt = $firstAttemptedAt;
return $this;
}
public function setLastAttemptedAt($lastAttemptedAt): self
{
$this->lastAttemptedAt = $lastAttemptedAt;
return $this;
}
public function setAttempts(int $attempts): self
{
$this->attempts = $attempts;
return $this;
}
public function setSendLog($send_log): self
{
$this->send_log = $send_log;
return $this;
}
public function setSendCode($send_code): self
{
$this->send_code = $send_code;
return $this;
}
public function setThawAt($thawAt): self
{
$this->thawAt = $thawAt;
return $this;
}
public function setId($id): self
{
$this->id = $id;
return $this;
}
public function setCid($cid): self
{
$this->cid = $cid;
return $this;
}
public function setCreatedAt(\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getAttachmentUri()
{
return $this->attachment_uri;
}
public function setAttachmentUri($attachment_uri): self
{
$this->attachment_uri = $attachment_uri;
return $this;
}
public function getExtra()
{
return $this->extra;
}
public function setExtra($extra): self
{
$this->extra = $extra;
return $this;
}
public function getExtraData(): array
{
return $this->extraData;
}
public function setExtraData(array $extraData): self
{
$this->extraData = $extraData;
return $this;
}
}