<?php
declare(strict_types=1);
namespace JanusHercules\IndeedCampaignManagement\Domain\Entity;
use App\Utility\DatabaseIdGenerator;
use App\Utility\DateTimeUtility;
use DateTime;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use JanusHercules\IndeedCampaignManagement\Domain\Enum\CampaignType;
use JanusHercules\IndeedCampaignManagement\Domain\Enum\RecurrentJobsSource;
#[ORM\Entity]
#[ORM\Table(name: 'icm_sync_run_events')]
class SyncRunEvent
{
/**
* @throws Exception
*/
public function __construct(
#[ORM\ManyToOne(targetEntity: SyncRun::class)]
#[ORM\JoinColumn(name: 'icm_sync_runs_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
private readonly SyncRun $syncRun,
#[ORM\Column(type: Types::TEXT, nullable: false)]
private readonly string $message,
#[ORM\Column(type: Types::GUID, nullable: true)]
private readonly ?string $recurrentJobId = null,
#[ORM\Column(type: Types::STRING, nullable: true, enumType: RecurrentJobsSource::class)]
private readonly ?RecurrentJobsSource $recurrentJobsSource = null,
#[ORM\Column(type: Types::STRING, nullable: true, enumType: CampaignType::class)]
private readonly ?CampaignType $campaignType = null,
#[ORM\Column(name: 'customer_internal_id', type: Types::STRING, nullable: true)]
private readonly ?string $customerInternalId = null,
) {
$this->createdAt = DateTimeUtility::createDateTimeUtc();
}
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
#[ORM\Column(type: Types::GUID, unique: true)]
private ?string $id = null;
public function getId(): ?string
{
return $this->id;
}
public function getSyncRun(): SyncRun
{
return $this->syncRun;
}
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
private DateTime $createdAt;
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
public function getMessage(): string
{
return $this->message;
}
public function getRecurrentJobId(): ?string
{
return $this->recurrentJobId;
}
public function getRecurrentJobsSource(): ?RecurrentJobsSource
{
return $this->recurrentJobsSource;
}
public function getCampaignType(): ?CampaignType
{
return $this->campaignType;
}
public function getCustomerInternalId(): ?string
{
return $this->customerInternalId;
}
}