Files
idoklad/Controllers/ReportsController.cs
2026-07-14 06:21:37 +02:00

39 lines
1.9 KiB
C#

using IdokladSdk.Enums;
using Microsoft.AspNetCore.Mvc;
using Idoklad.Services;
namespace Idoklad.Controllers;
/// <summary>
/// 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).
/// </summary>
[ApiController]
[Route("reports")]
[Produces("application/json")]
[Tags("Reports")]
public sealed class ReportsController : ControllerBase
{
private readonly ReportsService _service;
public ReportsController(ReportsService service) => _service = service;
/// <summary>Export an issued invoice as a Base64-encoded PDF.</summary>
/// <param name="language">Optional report language: Cz, Sk, En or De.</param>
/// <param name="compressed">When true, the returned PDF is compressed.</param>
[HttpGet("issued-invoices/{id:int}/pdf")]
public async Task<IActionResult> IssuedInvoicePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.IssuedInvoicePdfAsync(id, language, compressed, ct));
/// <summary>Export a proforma (advance) invoice as a Base64-encoded PDF.</summary>
[HttpGet("proforma-invoices/{id:int}/pdf")]
public async Task<IActionResult> ProformaInvoicePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.ProformaInvoicePdfAsync(id, language, compressed, ct));
/// <summary>Export a credit note as a Base64-encoded PDF.</summary>
[HttpGet("credit-notes/{id:int}/pdf")]
public async Task<IActionResult> CreditNotePdf(int id, [FromQuery] Language? language = null, [FromQuery] bool compressed = false, CancellationToken ct = default)
=> Ok(await _service.CreditNotePdfAsync(id, language, compressed, ct));
}