<?php
/**
 * Class PreavisoContact
 *
 * @package DhlPolska\API\WebApi\Struct
 */

namespace DhlPolska\API\WebApi\Struct;

use JsonSerializable;

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

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

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

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

	/**
	 * PreavisoContact constructor.
	 *
	 * @param string|null $person_name
	 * @param string|null $phone_number
	 * @param string|null $email_address
	 */
	public function __construct( ?string $person_name, ?string $phone_number, ?string $email_address ) {
		$this->person_name   = $person_name;
		$this->phone_number  = $phone_number;
		$this->email_address = $email_address;
	}

	/**
	 * @return array
	 */
	public function jsonSerialize(): array {
		return array_filter(
			[
				'personName'   => $this->person_name,
				'phoneNumber'  => $this->phone_number,
				'emailAddress' => $this->email_address,
			],
			static fn ( $value ) => $value !== null
		);
	}
}
