using IdokladSdk.Enums;
using Microsoft.AspNetCore.Mvc;
using Idoklad.Services;
namespace Idoklad.Controllers;
///
/// Document PDF exports (iDoklad Reports). Each endpoint returns the document as a
/// Base64-encoded string (the iDoklad API's native representation). Requires iDoklad credentials
/// (headers or environment defaults).
///
[ApiController]
[Route("reports")]
[Produces("application/json")]
[Tags("Reports")]
public sealed class ReportsController : ControllerBase
{
private readonly ReportsService _service;
public ReportsController(ReportsService service) => _service = service;
/// Export an issued invoice as a Base64-encoded PDF.
/// Optional report language: Cz, Sk, En or De.
/// When true, the returned PDF is compressed.
[HttpGet("issued-invoices/{id:int}/pdf")]
public async Task IssuedInvoicePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.IssuedInvoicePdfAsync(id, language, compressed, ct));
/// Export a proforma (advance) invoice as a Base64-encoded PDF.
[HttpGet("proforma-invoices/{id:int}/pdf")]
public async Task ProformaInvoicePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.ProformaInvoicePdfAsync(id, language, compressed, ct));
/// Export a credit note as a Base64-encoded PDF.
[HttpGet("credit-notes/{id:int}/pdf")]
public async Task CreditNotePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.CreditNotePdfAsync(id, language, compressed, ct));
}