<?php

namespace DhlPolskaVendor\Octolize\DhlPolska\API\WebApi\Struct\Services;

use DhlPolskaVendor\Octolize\DhlPolska\API\WebApi\Struct\Service;
/**
 * COD service structure for createShipment.
 */
class CodService implements Service
{
    /** @var float */
    private float $service_value;
    /** @var string|null */
    private ?string $text_instruction;
    /** @var string */
    private string $collect_on_delivery_form;
    /** @var string|null */
    private ?string $erodemail;
    /**
     * CodService constructor.
     *
     * @param float       $service_value
     * @param string      $collect_on_delivery_form
     * @param string|null $text_instruction
     * @param string|null $erodemail
     */
    public function __construct(float $service_value, string $collect_on_delivery_form = 'BANK_TRANSFER', ?string $text_instruction = null, ?string $erodemail = null)
    {
        $this->service_value = $service_value;
        $this->text_instruction = $text_instruction;
        $this->collect_on_delivery_form = $collect_on_delivery_form;
        $this->erodemail = $erodemail;
    }
    /**
     * @return string
     */
    public function get_service_type(): string
    {
        return 'COD';
    }
    /**
     * @return array
     */
    public function jsonSerialize(): array
    {
        return array_filter(['serviceType' => $this->get_service_type(), 'serviceValue' => $this->service_value, 'textInstruction' => $this->text_instruction, 'collectOnDeliveryForm' => $this->collect_on_delivery_form, 'eRodemail' => $this->erodemail], static fn($value) => $value !== null);
    }
}
