<?php

namespace Opencart\Extension\Alsendo\Models;

class OrderShipmentPackage
{
    private ?int $id;
    private int $orderShipmentId;
    private ?int $shippingSettingsTemplateId;
    private ?string $templateName;
    private string $packageType;
    private ?string $pickupType;
    private int $length;
    private int $width;
    private int $height;
    private int $weight;
    private ?float $cashOnDelivery;
    private ?float $declaredValue;
    private ?string $contentText;
    private string $createdAt;
    private string $updatedAt;

    public function __construct(
        ?int $id = null,
        int $orderShipmentId = 0,
        ?int $shippingSettingsTemplateId = null,
        ?string $templateName = null,
        string $packageType = 'box',
        ?string $pickupType = null,
        int $length = 0,
        int $width = 0,
        int $height = 0,
        int $weight = 0,
        ?float $cashOnDelivery = null,
        ?float $declaredValue = null,
        ?string $contentText = null,
        ?string $createdAt = null,
        ?string $updatedAt = null
    ) {
        $this->id = $id;
        $this->shippingSettingsTemplateId = $shippingSettingsTemplateId;
        $this->templateName = $templateName;
        $this->orderShipmentId = $orderShipmentId;
        $this->packageType = $packageType;
        $this->pickupType = $pickupType;
        $this->length = $length;
        $this->width = $width;
        $this->height = $height;
        $this->weight = $weight;
        $this->cashOnDelivery = $cashOnDelivery;
        $this->declaredValue = $declaredValue;
        $this->contentText = $contentText;
        $this->createdAt = $createdAt ?? date('Y-m-d H:i:s');
        $this->updatedAt = $updatedAt ?? date('Y-m-d H:i:s');
    }

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

    public function setId(int $id): void
    {
        $this->id = $id;
    }

    public function getOrderShipmentId(): int
    {
        return $this->orderShipmentId;
    }

    public function setOrderShipmentId(int $orderShipmentId): void
    {
        $this->orderShipmentId = $orderShipmentId;
    }

    public function getShippingSettingsTemplateId(): ?int
    {
        return $this->shippingSettingsTemplateId;
    }

    public function setShippingSettingsTemplateId(?int $shippingSettingsTemplateId): void
    {
        $this->shippingSettingsTemplateId = $shippingSettingsTemplateId;
    }

    public function getTemplateName(): ?string
    {
        return $this->templateName;
    }

    public function setTemplateName(string $templateName): void
    {
        $this->templateName = $templateName;
    }


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

    public function setPackageType(string $packageType): void
    {
        $this->packageType = $packageType;
    }

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

    public function setPickupType(?string $pickupType): void
    {
        $this->pickupType = $pickupType;
    }

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

    public function setLength(int $length): void
    {
        $this->length = $length;
    }

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

    public function setWidth(int $width): void
    {
        $this->width = $width;
    }

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

    public function setHeight(int $height): void
    {
        $this->height = $height;
    }

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

    public function setWeight(int $weight): void
    {
        $this->weight = $weight;
    }

    public function getCashOnDelivery(): ?float
    {
        return $this->cashOnDelivery;
    }

    public function getDeclaredValue(): ?float
    {
        return $this->declaredValue;
    }

    public function getContentText(): ?string
    {
        return $this->contentText;
    }

    public function setContentText(?string $contentText): void
    {
        $this->contentText = $contentText;
    }

    public function getCreatedAt(): string
    {
        return $this->createdAt;
    }

    public function setCreatedAt(string $createdAt): void
    {
        $this->createdAt = $createdAt;
    }

    public function getUpdatedAt(): string
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt(string $updatedAt): void
    {
        $this->updatedAt = $updatedAt;
    }

    public function summaryString(): string {
        return sprintf(
            '%sx%sx%scm, %skg',
            $this->width,
            $this->length,
            $this->height,
            $this->weight
        );
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'order_shipment_id' => $this->orderShipmentId,
            'shipping_settings_template_id' => $this->shippingSettingsTemplateId,
            'template_name' => $this->templateName,
            'package_type' => $this->packageType,
            'pickup_type' => $this->pickupType,
            'length' => $this->length,
            'width' => $this->width,
            'height' => $this->height,
            'weight' => $this->weight,
            'cash_on_delivery' => $this->cashOnDelivery,
            'declared_value' => $this->declaredValue,
            'content_text' => $this->contentText,
            'created_at' => $this->createdAt,
            'updated_at' => $this->updatedAt
        ];
    }
}
