<?php

namespace KupShop\GraphQLBundle\ApiPos\Types;

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

#[Type]
class PosTerminal
{
    public function __construct(protected ?array $data)
    {
    }

    #[Field]
    public function getActive(): bool
    {
        return $this->data && ($this->data['active'] == 'Y');
    }

    #[Field]
    public function getIp(): string
    {
        return !empty($this->data['ip']) ? $this->data['ip'] : '';
    }

    #[Field]
    public function getPort(): int
    {
        return !empty($this->data['port']) ? $this->data['port'] : 6090;
    }

    #[Field]
    public function getCustomTerminalPrint(): bool
    {
        return ($this->data['custom_terminal_print'] ?? false) === 'Y';
    }
}
