<?php

namespace WPDesk\FakturyKSEF\Api\Requests;

class SendEncryptedInvoiceRequest implements KsefRequestInterface {

	private string $sesstion_ref_number;

	private string $invoice_hash;

	private int $invoice_size;

	private string $encrypted_invoice_hash;

	private int $encrypted_invoice_size;

	private string $encrypted_invoice_content;

	public function __construct(
		string $sesstion_ref_number,
		string $invoice_hash,
		int $invoice_size,
		string $encrypted_invoice_hash,
		int $encrypted_invoice_size,
		string $encrypted_invoice_content
	) {
		$this->encrypted_invoice_content = $encrypted_invoice_content;
		$this->encrypted_invoice_size    = $encrypted_invoice_size;
		$this->encrypted_invoice_hash    = $encrypted_invoice_hash;
		$this->invoice_size              = $invoice_size;
		$this->invoice_hash              = $invoice_hash;
		$this->sesstion_ref_number       = $sesstion_ref_number;
	}

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

	public function get_uri(): string {
		return sprintf( '/v2/sessions/online/%s/invoices', $this->sesstion_ref_number );
	}

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

	public function get_body(): array {
		return [
			'invoiceHash'             => $this->invoice_hash,
			'invoiceSize'             => $this->invoice_size,
			'encryptedInvoiceHash'    => $this->encrypted_invoice_hash,
			'encryptedInvoiceSize'    => $this->encrypted_invoice_size,
			'encryptedInvoiceContent' => $this->encrypted_invoice_content,
		];
	}
}
