32 lines
1.6 KiB
C#
32 lines
1.6 KiB
C#
using IdokladSdk.Enums;
|
|
using IdokladSdk.Models.Report;
|
|
using Idoklad.Client;
|
|
|
|
namespace Idoklad.Services;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public sealed class ReportsService
|
|
{
|
|
private readonly IdokladApiAccessor _accessor;
|
|
|
|
public ReportsService(IdokladApiAccessor accessor) => _accessor = accessor;
|
|
|
|
/// <summary>Export an issued invoice as a Base64-encoded PDF.</summary>
|
|
public async Task<string> IssuedInvoicePdfAsync(int id, Language? language, bool compressed, CancellationToken ct)
|
|
=> (await _accessor.Api.ReportClient.IssuedInvoice.Detail(id).GetAsync(Option(language, compressed), ct)).Unwrap();
|
|
|
|
/// <summary>Export a proforma (advance) invoice as a Base64-encoded PDF.</summary>
|
|
public async Task<string> ProformaInvoicePdfAsync(int id, Language? language, bool compressed, CancellationToken ct)
|
|
=> (await _accessor.Api.ReportClient.ProformaInvoice.Detail(id).GetAsync(Option(language, compressed), ct)).Unwrap();
|
|
|
|
/// <summary>Export a credit note as a Base64-encoded PDF.</summary>
|
|
public async Task<string> 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 };
|
|
}
|