<?php

namespace KupShop\GraphQLBundle\ApiPos\Types\Order;

use KupShop\GraphQLBundle\ApiPos\Types\User\PosUser;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

/**
 * @Type()
 */
class PosOrderHistoryItem
{
    private $data;

    public function __construct(array $data)
    {
        $this->data = $data;
    }

    /**
     * Id.
     *
     * @Field()
     */
    public function getId(): string
    {
        return $this->data['id'];
    }

    /**
     * Datum.
     *
     * @Field()
     */
    public function getDate(): string
    {
        return $this->data['date_created'];
    }

    /**
     * Zákazník.
     *
     * @Field()
     */
    public function getUser(): PosUser
    {
        return new PosUser($this->data['user_id'], $this->data['name'], $this->data['email'], $this->data['surname']);
    }

    /**
     * Zaplacená částka.
     *
     * @Field()
     */
    public function getPaidPrice(): ?string
    {
        return $this->data['paid'];
    }

    /**
     * Celková částka.
     *
     * @Field()
     */
    public function getPrice(): string
    {
        return $this->data['total_price'];
    }

    /**
     * Stornována.
     *
     * @Field()
     */
    public function getStorno(): bool
    {
        return $this->data['status_storno'] == 1;
    }

    /**
     * Kod objednávky.
     *
     * @Field()
     */
    public function getCode(): string
    {
        return $this->data['order_no'];
    }

    /**
     * Kod objednávky.
     *
     * @Field()
     */
    public function getStatus(): string
    {
        return $this->data['status'];
    }

    /**
     * Symbol měny.
     *
     * @Field()
     */
    public function getCurrencySymbol(): string
    {
        return $this->data['currency_symbol'];
    }

    #[Field]
    public function getPaymentMethods(): string
    {
        return $this->data['payment_methods'] ?? '';
    }
}
