<?php
/*
 * @package    ECLCDEK shipping plugin СДЭК to RadicalMart
 * @subpackage    ECLCDEK
 * @version    1.0.1
 * @author Econsult Lab.
 * @copyright  Copyright (c) 2025 Econsult Lab. All rights reserved.
 * @license    GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
 * @link       https://econsultlab.ru
 */

declare(strict_types=1);

namespace Joomla\Plugin\RadicalMartShipping\ECLCDEK\CDEK;

use CdekSDK2\Dto\TariffListItem;

class ECLTariffListItem extends TariffListItem
{
	/**
	 * Признак, что тариф выбран в доставке
	 * @type ("boolean")
	 * @var bool
	 * @since 1.0.0
	 */
	public bool $checked = false;

	/**
	 * Символ валюты тарифа
	 * @var string
	 * @since 1.0.2
	 */
	public string $currency = "";

	/**
	 * @param   TariffListItem|null  $item
	 *
	 * @since 1.0.0
	 */
	public function __construct(TariffListItem|null $item = null)
	{
		if (!is_null($item))
		{
			$this->tariff_code        = $item->tariff_code;
			$this->tariff_name        = $item->tariff_name;
			$this->delivery_sum       = $item->delivery_sum;
			$this->calendar_max       = $item->calendar_max;
			$this->calendar_min       = $item->calendar_min;
			$this->delivery_mode      = $item->delivery_mode;
			$this->period_max         = $item->period_max;
			$this->period_min         = $item->period_min;
			$this->tariff_description = $item->tariff_description;
			$this->currency = $item->tariff_description?? "";
		}
	}


}
