<?php

namespace WPDesk\FakturyKSEF\Api\Requests;

class GetKSeFAuthTokenRequest implements KsefRequestInterface {

	private string $vat_number;

	private string $challenge;

	private string $encrypted_token_base64;

	public function __construct( string $vat_number, string $challenge, string $encrypted_token_base64 ) {
		$this->encrypted_token_base64 = $encrypted_token_base64;
		$this->challenge              = $challenge;
		$this->vat_number             = $vat_number;
	}

	public function get_method(): string {
		return 'POST';
	}

	public function get_uri(): string {
		return '/v2/auth/ksef-token';
	}

	public function get_body(): array {
		return [
			'challenge'         => $this->challenge,
			'contextIdentifier' => [
				'type'  => 'Nip',
				'value' => $this->vat_number,
			],
			'encryptedToken'    => $this->encrypted_token_base64,
		];
	}

	public function requires_auth(): bool {
		return false;
	}
}
