<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiShared\Types\Order;

use KupShop\GraphQLBundle\ApiShared\Types\Enums\OrderHistoryNotifiedEnum;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class OrderHistoryEntry
{
    public function __construct(public array $entry)
    {
    }

    #[Field(description: 'ID.')]
    public function getId(): int
    {
        return $this->entry['id'];
    }

    #[Field(description: 'ID stavu objednávky.')]
    public function getOrderStatus(): string
    {
        return $this->entry['status_text'];
    }

    #[Field(description: 'ID administrátora.')]
    public function getAdminId(): ?int
    {
        return $this->entry['admin'];
    }

    #[Field(description: 'Čas pořízení logu.')]
    public function getDate(): \DateTimeInterface
    {
        return new \DateTimeImmutable($this->entry['date']);
    }

    #[Field(description: 'Komentář.')]
    public function getComment(): ?string
    {
        return $this->entry['comment'];
    }

    #[Field(description: 'Notifikace odesláná uživateli.')]
    public function getNotifyStatus(): OrderHistoryNotifiedEnum
    {
        return OrderHistoryNotifiedEnum::from($this->entry['notified']);
    }

    #[Field(description: 'Data.')]
    public function getData(): ?string
    {
        return json_encode($this->entry['custom_data']);
    }
}
