<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiAdmin\Types\User;

use KupShop\GraphQLBundle\ApiAdmin\Types\User\Enum\BonusPointStatus;
use KupShop\GraphQLBundle\ApiShared\ApiUtil;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class UserBonusPoint
{
    public function __construct(
        public array $bonusPoint,
    ) {
    }

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

    #[Field(description: 'ID uživetele, ke kterému patří daný záznam bodů.')]
    public function getUserId(): int
    {
        return $this->bonusPoint['id_user'];
    }

    #[Field(description: 'ID objednávky, kde body vznikly.')]
    public function getOrderId(): ?int
    {
        return $this->bonusPoint['id_order'];
    }

    #[Field(description: 'Datum vytvoření.')]
    public function getDateCreated(): \DateTimeInterface
    {
        return ApiUtil::prepareDateTimeFromDB(
            $this->bonusPoint['date_created']
        );
    }

    #[Field(description: 'Počet bodů.')]
    public function getPoints(): float
    {
        return (float) $this->bonusPoint['points'];
    }

    #[Field(description: 'Poznámka.')]
    public function getNote(): string
    {
        return $this->bonusPoint['note'];
    }

    #[Field(description: 'Stav bodů.')]
    public function getStatus(): BonusPointStatus
    {
        return BonusPointStatus::from(
            $this->bonusPoint['status']
        );
    }
}
