<?php

namespace App\Game\BetBy;

class TemplateItem
{
    public $id;
    public $name;
    public $isActive;
    public $maxBonusNumber;
    public $type;
    public $operatorId;
    public $eventScheduled;
    public $brandId;
    public $fromTime;
    public $toTime;
    public $daysToUse;
    /**
     * @var RestrictionItem[]
     */
    public $restrictions;
    /**
     * @var FreebetDataItem|null
     */
    public $freebetData;
    /**
     * @var ComboboostDataItem|null
     */
    public $comboboostData;
    public $descriptions;

    public function __construct(array $data)
    {
        $this->id = $data['id'];
        $this->name = $data['name'];
        $this->isActive = $data['is_active'];
        $this->maxBonusNumber = $data['max_bonus_number'];
        $this->type = $data['type'];
        $this->operatorId = $data['operator_id'];
        $this->eventScheduled = $data['event_scheduled'];
        $this->brandId = $data['brand_id'];
        $this->fromTime = $data['from_time'];
        $this->toTime = $data['to_time'];
        $this->daysToUse = $data['days_to_use'];
        $this->restrictions = array_map(function($restriction) {
            return new RestrictionItem($restriction);
        }, $data['restrictions']['restriction_events'] ?? []);
        $this->freebetData = $data['freebet_data'] ? new FreebetDataItem($data['freebet_data']) : null;
        $this->comboboostData = $data['comboboost_data'] ? new ComboboostDataItem($data['comboboost_data']) : null;
        $this->descriptions = $data['descriptions'];
    }
}
