<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiShared\Types\PriceLevel;

use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class PriceLevel
{
    public function __construct(
        private readonly \KupShop\CatalogBundle\PriceLevel $priceLevel,
    ) {
    }

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

    #[Field(description: 'Název.')]
    public function getName(): string
    {
        return $this->priceLevel->getName();
    }

    #[Field(description: 'Sleva pro veškeré zboží.')]
    public function getDiscount(): PriceLevelDiscount
    {
        return new PriceLevelDiscount(
            [
                'discount' => (float) $this->priceLevel->discount,
                'unit' => $this->priceLevel->unit,
            ]
        );
    }
}
