Consolidated DTOs under `DocumentService.Application.Common.DTOs.Requests` to centralize and align them with the application layer. Introduced `PdfBase64RequestBase` to encapsulate shared properties, reducing redundancy across request DTOs. Updated controllers, clients, and tests to use the new DTO structure. Removed redundant DTOs and cleaned up unused namespaces and comments. Improved documentation and ensured consistent naming conventions across the codebase.
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using DocumentService.Application.Common.DTOs;
|
|
using DocumentService.Client.Interfaces;
|
|
using DocumentService.Application.Common.DTOs.Requests;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Net.Http;
|
|
|
|
namespace DocumentService.Client.Clients;
|
|
|
|
/// <summary>
|
|
/// Implementation of Swiss QR Code extraction client.
|
|
/// </summary>
|
|
public class SwissQrCodeClient(HttpClient httpClient, ILogger<SwissQrCodeClient> logger) : BaseDocumentClient(httpClient, logger), ISwissQrCodeClient
|
|
{
|
|
/// <inheritdoc />
|
|
public async Task<SwissQrCodeExtractionResult> ExtractSwissQrCodeAsync(Stream pdfStream, bool raw = false, CancellationToken cancellationToken = default)
|
|
{
|
|
var endpoint = $"/api/pdf/qr-code/extract-swiss?raw={raw}";
|
|
|
|
var result = await SendMultipartAsync<SwissQrCodeExtractionResult>(
|
|
endpoint,
|
|
pdfStream,
|
|
"document.pdf",
|
|
cancellationToken);
|
|
|
|
return result ?? throw new InvalidOperationException("API returned null response");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<SwissQrCodeExtractionResult> ExtractSwissQrCodeAsync(byte[] pdfBytes, bool raw = false, CancellationToken cancellationToken = default)
|
|
{
|
|
var endpoint = $"/api/pdf/qr-code/extract-swiss?raw={raw}";
|
|
|
|
var request = new ExtractSwissQrCodeBase64Request
|
|
{
|
|
Base64Pdf = ToBase64(pdfBytes)
|
|
};
|
|
|
|
var result = await SendJsonAsync<ExtractSwissQrCodeBase64Request, SwissQrCodeExtractionResult>(
|
|
endpoint,
|
|
request,
|
|
cancellationToken);
|
|
|
|
return result ?? throw new InvalidOperationException("API returned null response");
|
|
}
|
|
}
|