<?php

namespace WPDesk\FakturyKSEF\Api\Requests;

class OpenSessionRequest implements KsefRequestInterface {

	private string $encrypted_key_base64;

	private string $iv_base64;

	public function __construct(
		string $encrypted_key_base64,
		string $iv_base64
	) {
		$this->iv_base64            = $iv_base64;
		$this->encrypted_key_base64 = $encrypted_key_base64;
	}

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

	public function get_uri(): string {
		return '/v2/sessions/online';
	}

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

	public function get_body(): array {
		return [
			'formCode'   => [
				'systemCode'    => 'FA (3)',
				'schemaVersion' => '1-0E',
				'value'         => 'FA',
			],
			'encryption' => [
				'encryptedSymmetricKey' => $this->encrypted_key_base64,
				'initializationVector'  => $this->iv_base64,
			],
		];
	}
}
