<?php

namespace DhlPolskaVendor\Octolize\DhlPolska\API\WebApi\Method;

use JsonSerializable;
use DhlPolskaVendor\Octolize\DhlPolska\API\AuthDataInterface;
/**
 * GetNearestServicepoints structure.
 */
class GetNearestServicepoints implements JsonSerializable
{
    /**
     * @var AuthDataInterface
     */
    private AuthDataInterface $auth_data;
    /**
     * @var string
     */
    private string $country;
    /**
     * @var string
     */
    private string $postcode;
    /**
     * @var string|null
     */
    private ?string $city;
    /**
     * @var int
     */
    private int $radius;
    /**
     * GetNearestServicepoints constructor.
     *
     * @param AuthDataInterface $auth_data
     * @param string            $country
     * @param string            $postcode
     * @param int               $radius
     * @param string|null       $city
     */
    public function __construct(AuthDataInterface $auth_data, string $country, string $postcode, int $radius, ?string $city = null)
    {
        $this->auth_data = $auth_data;
        $this->country = $country;
        $this->postcode = $postcode;
        $this->city = $city;
        $this->radius = $radius;
    }
    /**
     * @return array
     */
    public function jsonSerialize(): array
    {
        return ['authData' => $this->auth_data, 'structure' => array_filter(['country' => $this->country, 'postcode' => $this->postcode, 'city' => $this->city, 'radius' => $this->radius], static fn($value) => $value !== null)];
    }
}
