<?php

namespace WPDesk\FakturyKSEF\Services;

use WPDesk\FakturyKSEF\Controller\DownloadXMLController;

class DownloadXMLUrlGenerator {

	public function generate_by_id( int $document_id ): string {
		$nonce        = wp_create_nonce( 'ksef_download_xml_action' );
		$download_url = admin_url(
			sprintf(
				'admin-ajax.php?action=%s&document_id=%d&%s=%s',
				DownloadXMLController::ACTION,
				$document_id,
				DownloadXMLController::NONCE_FIELD,
				$nonce
			)
		);

		return $download_url;
	}
}
