<?php

namespace Opencart\Extension\Alsendo\Models;

class ShippingSettingsTemplate
{
    private int $id;
    private string $name;
    private string $defaultService;
    private string $packageType;
    private int $length;
    private int $width;
    private int $height;
    private int $weight;
    private string $defaultContent;
    private bool $nonStandard;
    private bool $main;
    private ?int $cashOnDelivery;
    private ?int $declaredValue;
    private ?string $pickupType;
    private ?string $defaultContentCustomText;


    public function __construct(array $data = [])
    {
        $this->id = (int)($data['id'] ?? 0);
        $this->name = $data['name'] ?? '';
        $this->defaultService = $data['default_service'] ?? '';
        $this->packageType = $data['package_type'] ?? 'medium';
        $this->length = (int)($data['length'] ?? 0);
        $this->width = (int)($data['width'] ?? 0);
        $this->height = (int)($data['height'] ?? 0);
        $this->weight = (int)($data['weight'] ?? 0);
        $this->defaultContent = $data['default_content'] ?? '';
        $this->defaultContentCustomText = $data['default_content_custom_text'] ?? null;
        $this->nonStandard = (bool)($data['non_standard'] ?? false);
        $this->main = (bool)($data['main'] ?? false);
        $this->cashOnDelivery = $data['cash_on_delivery'];
        $this->declaredValue = $data['declared_value'];
        $this->pickupType = $data['pickup_type'];
    }

    public function getId(): int
    {
        return $this->id;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function getPickupType(): ?string
    {
        return $this->pickupType;
    }

    public function getDefaultService(): string
    {
        return $this->defaultService;
    }

    public function getPackageType(): string
    {
        return $this->packageType;
    }

    public function getLength(): int
    {
        return $this->length;
    }

    public function getWidth(): int
    {
        return $this->width;
    }

    public function getHeight(): int
    {
        return $this->height;
    }

    public function getWeight(): int
    {
        return $this->weight;
    }

    public function getDefaultContent(): string
    {
        return $this->defaultContent;
    }

    public function isNonStandard(): bool
    {
        return $this->nonStandard;
    }

    public function isMain(): bool
    {
        return $this->main;
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'default_service' => $this->defaultService,
            'package_type' => $this->packageType,
            'length' => $this->length,
            'width' => $this->width,
            'height' => $this->height,
            'weight' => $this->weight,
            'shipment_content' => $this->defaultContent,
            'default_content_custom_text' => $this->defaultContentCustomText,
            'pickup_type' => $this->pickupType,
            'cash_on_delivery' => $this->cashOnDelivery,
            'declared_value' => $this->declaredValue,
            'main' => $this->main,
            'non_standard' => $this->nonStandard,
        ];
    }
} 