<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Index(columns: ['submission_id'], name: 'idx_docuseal_event_submission')]
#[ORM\Index(columns: ['submitter_id'], name: 'idx_docuseal_event_submitter')]
#[ORM\Index(columns: ['event_type'], name: 'idx_docuseal_event_type')]
class DocusealEvent
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 30)]
    private string $type;

    #[ORM\Column(length: 30)]
    private string $eventType;

    #[ORM\Column(nullable: true)]
    private ?int $submissionId = null;

    #[ORM\Column(nullable: true)]
    private ?int $submitterId = null;

    #[ORM\Column(type: 'text', nullable: true)]
    private ?string $payload = null;

    #[ORM\Column]
    private \DateTimeImmutable $createdAt;

    public function __construct(string $type, string $eventType, ?int $submissionId = null, ?int $submitterId = null, ?string $payload = null)
    {
        $this->type = $type;
        $this->eventType = $eventType;
        $this->submissionId = $submissionId;
        $this->submitterId = $submitterId;
        $this->payload = $payload;
        $this->createdAt = new \DateTimeImmutable();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getType(): string
    {
        return $this->type;
    }

    public function getEventType(): string
    {
        return $this->eventType;
    }

    public function getSubmissionId(): ?int
    {
        return $this->submissionId;
    }

    public function getSubmitterId(): ?int
    {
        return $this->submitterId;
    }

    public function getPayload(): ?string
    {
        return $this->payload;
    }

    public function getCreatedAt(): \DateTimeImmutable
    {
        return $this->createdAt;
    }
}
