<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Shop\DTO;

use CpCreation\VitiCore\Cart\Model\Cart;
use CpCreation\VitiCore\Shop\Model\DeliveryMethod;

final class ShippingContext
{
    /**
     * @param array<string, float> $quantities
     * @param array<string, float> $quantitiesManual
     * @param array<string, float> $quantitiesAutoFallback
     * @param array<string, float> $quantitiesMinCart
     * @param list<string> $typeSlugs
     * @param array<string, string> $typeNames
     * @param array<string, bool> $freeShippingWithBottle
     * @param array<string, int|null> $minFreeShippingWithBottle
     * @param array<string, list<string>> $zonesFreeShippingWithBottle
     * @param array<string, bool> $disabledShippingAuto
     * @param array<string, bool> $disabledShippingManu
     */
    public function __construct(
        public readonly Cart $cart,
        public readonly string $priceGroupId,
        public readonly ?string $codePriceId,
        public readonly ?string $countryCode,
        public readonly ?string $postalCode,
        public readonly ?string $city,
        public readonly ?DeliveryMethod $deliveryMethod,
        public readonly int $itemsTotalTTC,
        public readonly float $quantityAllAbsolute,
        public readonly float $equivalenceAuto,
        public readonly float $equivalenceDefault,
        public readonly int $equivalenceOff,
        public readonly array $quantities,
        public readonly array $quantitiesManual,
        public readonly array $quantitiesAutoFallback,
        public readonly array $quantitiesMinCart,
        public readonly array $typeSlugs,
        public readonly string $typeDefaultSlug,
        public readonly array $typeNames,
        public readonly array $freeShippingWithBottle,
        public readonly array $minFreeShippingWithBottle,
        public readonly array $zonesFreeShippingWithBottle,
        public readonly array $disabledShippingAuto,
        public readonly array $disabledShippingManu,
    ) {
    }

    public function withDeliveryMethod(?DeliveryMethod $deliveryMethod): self
    {
        return new self(
            cart: $this->cart,
            priceGroupId: $this->priceGroupId,
            codePriceId: $this->codePriceId,
            countryCode: $this->countryCode,
            postalCode: $this->postalCode,
            city: $this->city,
            deliveryMethod: $deliveryMethod,
            itemsTotalTTC: $this->itemsTotalTTC,
            quantityAllAbsolute: $this->quantityAllAbsolute,
            equivalenceAuto: $this->equivalenceAuto,
            equivalenceDefault: $this->equivalenceDefault,
            equivalenceOff: $this->equivalenceOff,
            quantities: $this->quantities,
            quantitiesManual: $this->quantitiesManual,
            quantitiesAutoFallback: $this->quantitiesAutoFallback,
            quantitiesMinCart: $this->quantitiesMinCart,
            typeSlugs: $this->typeSlugs,
            typeDefaultSlug: $this->typeDefaultSlug,
            typeNames: $this->typeNames,
            freeShippingWithBottle: $this->freeShippingWithBottle,
            minFreeShippingWithBottle: $this->minFreeShippingWithBottle,
            zonesFreeShippingWithBottle: $this->zonesFreeShippingWithBottle,
            disabledShippingAuto: $this->disabledShippingAuto,
            disabledShippingManu: $this->disabledShippingManu,
        );
    }
}
