<?php

declare(strict_types=1);

namespace CpCreation\AltchaBundle\Model;

final readonly class VerificationRequest
{
    public function __construct(
        public string $payload,
        public string $scope,
        public string $host,
        public string $clientIp,
        public string $formToken,
        public ?string $subjectHash = null,
    ) {
    }

    /** @return array<string, int|string> */
    public function toArray(): array
    {
        $data = [
            'host' => $this->host,
            'scope' => $this->scope,
            'clientIp' => $this->clientIp,
            'formToken' => $this->formToken,
            'payload' => $this->payload,
        ];

        if (null !== $this->subjectHash && '' !== $this->subjectHash) {
            $data['subjectHash'] = $this->subjectHash;
        }

        return $data;
    }
}
