<?php

namespace DhlPolska\API\WebApi\Struct;

use JsonSerializable;

/**
 * ServiceDefinition structure.
 */
class ServiceDefinition implements JsonSerializable {

	/** @var string */
	private string $product;

	/** @var bool|null */
	private ?bool $delivery_evening;

	/** @var bool|null */
	private ?bool $delivery_on_saturday;

	/** @var bool|null */
	private ?bool $pickup_on_saturday;

	/** @var bool|null */
	private ?bool $collect_on_delivery;

	/** @var float|null */
	private ?float $collect_on_delivery_value;

	/** @var string|null */
	private ?string $collect_on_delivery_form;

	/** @var string|null */
	private ?string $collect_on_delivery_reference;

	/** @var bool|null */
	private ?bool $insurance;

	/** @var float|null */
	private ?float $insurance_value;

	/** @var bool|null */
	private ?bool $return_on_delivery;

	/** @var string|null */
	private ?string $return_on_delivery_reference;

	/** @var bool|null */
	private ?bool $proof_of_delivery;

	/** @var bool|null */
	private ?bool $self_collect;

	/** @var bool|null */
	private ?bool $predelivery_information;

	/** @var bool|null */
	private ?bool $delivery_to_neighbour;

	/** @var bool|null */
	private ?bool $preaviso;

	/** @var bool|null */
	private ?bool $additional_service;

	/** @var string|null */
	private ?string $erodemail;

	/** @var bool|null */
	private ?bool $age_ver;

	/** @var bool|null */
	private ?bool $vip;

	/**
	 * ServiceDefinition constructor.
	 *
	 * @param string      $product
	 * @param bool|null   $delivery_evening
	 * @param bool|null   $delivery_on_saturday
	 * @param bool|null   $pickup_on_saturday
	 * @param bool|null   $collect_on_delivery
	 * @param float|null  $collect_on_delivery_value
	 * @param string|null $collect_on_delivery_form
	 * @param string|null $collect_on_delivery_reference
	 * @param bool|null   $insurance
	 * @param float|null  $insurance_value
	 * @param bool|null   $return_on_delivery
	 * @param string|null $return_on_delivery_reference
	 * @param bool|null   $proof_of_delivery
	 * @param bool|null   $self_collect
	 * @param bool|null   $predelivery_information
	 * @param bool|null   $delivery_to_neighbour
	 * @param bool|null   $preaviso
	 * @param bool|null   $additional_service
	 * @param string|null $erodemail
	 * @param bool|null   $age_ver
	 * @param bool|null   $vip
	 */
	public function __construct(
		string $product,
		?bool $delivery_evening = null,
		?bool $delivery_on_saturday = null,
		?bool $pickup_on_saturday = null,
		?bool $collect_on_delivery = null,
		?float $collect_on_delivery_value = null,
		?string $collect_on_delivery_form = null,
		?string $collect_on_delivery_reference = null,
		?bool $insurance = null,
		?float $insurance_value = null,
		?bool $return_on_delivery = null,
		?string $return_on_delivery_reference = null,
		?bool $proof_of_delivery = null,
		?bool $self_collect = null,
		?bool $predelivery_information = null,
		?bool $delivery_to_neighbour = null,
		?bool $preaviso = null,
		?bool $additional_service = null,
		?string $erodemail = null,
		?bool $age_ver = null,
		?bool $vip = null
	) {
		$this->product                       = $product;
		$this->delivery_evening              = $delivery_evening;
		$this->delivery_on_saturday          = $delivery_on_saturday;
		$this->pickup_on_saturday            = $pickup_on_saturday;
		$this->collect_on_delivery           = $collect_on_delivery;
		$this->collect_on_delivery_value     = $collect_on_delivery_value;
		$this->collect_on_delivery_form      = $collect_on_delivery_form;
		$this->collect_on_delivery_reference = $collect_on_delivery_reference;
		$this->insurance                     = $insurance;
		$this->insurance_value               = $insurance_value;
		$this->return_on_delivery            = $return_on_delivery;
		$this->return_on_delivery_reference  = $return_on_delivery_reference;
		$this->proof_of_delivery             = $proof_of_delivery;
		$this->self_collect                  = $self_collect;
		$this->predelivery_information       = $predelivery_information;
		$this->delivery_to_neighbour         = $delivery_to_neighbour;
		$this->preaviso                      = $preaviso;
		$this->additional_service            = $additional_service;
		$this->erodemail                     = $erodemail;
		$this->age_ver                       = $age_ver;
		$this->vip                           = $vip;
	}

	/**
	 * @return array
	 */
	public function jsonSerialize(): array {
		return array_filter(
			[
				'product'                    => $this->product,
				'deliveryEvening'            => $this->delivery_evening,
				'deliveryOnSaturday'         => $this->delivery_on_saturday,
				'pickupOnSaturday'           => $this->pickup_on_saturday,
				'collectOnDelivery'          => $this->collect_on_delivery,
				'collectOnDeliveryValue'     => $this->collect_on_delivery_value,
				'collectOnDeliveryForm'      => $this->collect_on_delivery_form,
				'collectOnDeliveryReference' => $this->collect_on_delivery_reference,
				'insurance'                  => $this->insurance,
				'insuranceValue'             => $this->insurance_value,
				'returnOnDelivery'           => $this->return_on_delivery,
				'returnOnDeliveryReference'  => $this->return_on_delivery_reference,
				'proofOfDelivery'            => $this->proof_of_delivery,
				'selfCollect'                => $this->self_collect,
				'predeliveryInformation'     => $this->predelivery_information,
				'deliveryToNeighbour'        => $this->delivery_to_neighbour,
				'preaviso'                   => $this->preaviso,
				'additionalService'          => $this->additional_service,
				'eRodemail'                  => $this->erodemail,
				'ageVer'                     => $this->age_ver,
				'vip'                        => $this->vip,
			],
			static fn ( $value ) => $value !== null
		);
	}
}
