<?php


namespace PixelioCartAbandonRecoveryMore\Admin\Services\Tracking;

if (!defined('ABSPATH')) exit;

class Pixelio_Cart_Abandon_Recovery_More_Event_Dto
{
    public string $event_type;
    public ?string $uuid;
    public ?int $product_id;
    public ?int $parent_product_id;
    public ?string $page_url;
    public ?string $page_type;
    public int $visit_duration;
    public int $scroll_percent;
    public String $tracking_mode;

    public function __construct(array $data = [])
    {
        $this->event_type = $data['event_type'] ?? 'page_view';
        $this->uuid = $data['uuid'] ?? null;
        $this->product_id = isset($data['product_id']) ? (int)$data['product_id'] : null;
        $this->parent_product_id = isset($data['parent_product_id']) ? (int)$data['parent_product_id'] : null;
        $this->page_url = $data['page_url'] ?? null;
        $this->page_type = $data['page_type'] ?? 'unknown';
        $this->visit_duration = isset($data['visit_duration']) ? (int)$data['visit_duration'] : 0;
        $this->scroll_percent = isset($data['scroll_percent']) ? (int)$data['scroll_percent'] : 0;
        $this->tracking_mode =   isset($data['tracking_mode']) ? $data['tracking_mode'] : "";
    }
}
