feat: Add specialized client implementations for PDF operations

This commit is contained in:
2026-08-11 10:29:24 +02:00
parent 14250f0b4b
commit 058cb9327d
7 changed files with 711 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
using DocumentService.Client.Interfaces;
using DocumentService.Client.Models.Requests;
using Microsoft.Extensions.Logging;
using System.Net.Http;
namespace DocumentService.Client.Clients;
/// <summary>
/// Implementation of PDF validation client.
/// </summary>
public class PdfValidationClient(HttpClient httpClient, ILogger<PdfValidationClient> logger) : BaseDocumentClient(httpClient, logger), IPdfValidationClient
{
/// <inheritdoc />
public async Task<PdfValidationResult> ValidatePdfAsync(Stream pdfStream, CancellationToken cancellationToken = default)
{
var result = await SendMultipartAsync<PdfValidationResult>(
"/api/pdf/validation/validate",
pdfStream,
"document.pdf",
cancellationToken);
return result ?? throw new InvalidOperationException("API returned null response");
}
/// <inheritdoc />
public async Task<PdfValidationResult> ValidatePdfAsync(byte[] pdfBytes, CancellationToken cancellationToken = default)
{
var request = new ValidatePdfBase64Request
{
Base64Pdf = ToBase64(pdfBytes)
};
var result = await SendJsonAsync<ValidatePdfBase64Request, PdfValidationResult>(
"/api/pdf/validation/validate",
request,
cancellationToken);
return result ?? throw new InvalidOperationException("API returned null response");
}
/// <inheritdoc />
public async Task<PdfAValidationResult> ValidatePdfAAsync(Stream pdfStream, CancellationToken cancellationToken = default)
{
var result = await SendMultipartAsync<PdfAValidationResult>(
"/api/pdf/validation/validate-pdfa",
pdfStream,
"document.pdf",
cancellationToken);
return result ?? throw new InvalidOperationException("API returned null response");
}
/// <inheritdoc />
public async Task<PdfAValidationResult> ValidatePdfAAsync(byte[] pdfBytes, CancellationToken cancellationToken = default)
{
var request = new ValidatePdfABase64Request
{
Base64Pdf = ToBase64(pdfBytes)
};
var result = await SendJsonAsync<ValidatePdfABase64Request, PdfAValidationResult>(
"/api/pdf/validation/validate-pdfa",
request,
cancellationToken);
return result ?? throw new InvalidOperationException("API returned null response");
}
}