using IdokladSdk.Enums; using IdokladSdk.Models.Report; using Idoklad.Client; namespace Idoklad.Services; /// /// Document PDF exports (iDoklad Reports). Each method returns the report as a Base64-encoded /// string — the iDoklad API's native representation; decode it to obtain the raw PDF bytes. /// public sealed class ReportsService { private readonly IdokladApiAccessor _accessor; public ReportsService(IdokladApiAccessor accessor) => _accessor = accessor; /// Export an issued invoice as a Base64-encoded PDF. public async Task IssuedInvoicePdfAsync(int id, Language? language, bool compressed, CancellationToken ct) => (await _accessor.Api.ReportClient.IssuedInvoice.Detail(id).GetAsync(Option(language, compressed), ct)).Unwrap(); /// Export a proforma (advance) invoice as a Base64-encoded PDF. public async Task ProformaInvoicePdfAsync(int id, Language? language, bool compressed, CancellationToken ct) => (await _accessor.Api.ReportClient.ProformaInvoice.Detail(id).GetAsync(Option(language, compressed), ct)).Unwrap(); /// Export a credit note as a Base64-encoded PDF. public async Task CreditNotePdfAsync(int id, Language? language, bool compressed, CancellationToken ct) => (await _accessor.Api.ReportClient.CreditNote.Detail(id).GetAsync(Option(language, compressed), ct)).Unwrap(); private static ExtendedReportOption Option(Language? language, bool compressed) => new() { Language = language, Compressed = compressed }; }