<?php

namespace App\Game\BetBy;

class BonusItem
{
    public $id;
    public $templateId;
    public $name;
    public $type;
    public $playerId;
    public $externalPlayerId;
    public $brandId;
    public $eventScheduled;
    public $receiptDate;
    public $issueType;
    public $restrictions;
    public $viewed;
    public $activationDate;
    public $endingDate;
    public $status;
    public $fromTime;
    public $toTime;
    public $freebetData;
    public $comboboostData;

    public function __construct(array $data)
    {
        $this->id = $data['id'];
        $this->templateId = $data['template_id'];
        $this->name = $data['name'];
        $this->type = $data['type'];
        $this->playerId = $data['player_id'];
        $this->externalPlayerId = $data['external_player_id'];
        $this->brandId = $data['brand_id'];
        $this->eventScheduled = $data['event_scheduled'];
        $this->receiptDate = $data['receipt_date'];
        $this->issueType = $data['issue_type'];
        $this->restrictions = array_map(function($restriction) {
            return new RestrictionItem($restriction);
        }, $data['restrictions'] ?? []);
        $this->viewed = $data['viewed'];
        $this->activationDate = $data['activation_date'];
        $this->endingDate = $data['ending_date'];
        $this->status = $data['status'];
        $this->fromTime = $data['from_time'];
        $this->toTime = $data['to_time'];
        $this->freebetData = $data['freebet_data'] ? new FreebetDataItem($data['freebet_data']) : null;
        $this->comboboostData = $data['comboboost_data'] ? new ComboboostDataItem($data['comboboost_data']) : null;
    }
}
