Refactor WorkflowsClient for unified result handling
Refactored `ExtractSwissQrCodeAsync` to `InspectSwissQrCodeAsync`, introducing `SwissQrCodeResult` to encapsulate both validation and extraction results. Removed `throwIfInvalid` parameter, ensuring validation details are always returned without exceptions. Added extension methods for file path handling to improve usability. Updated tests to reflect the new behavior, ensuring extraction is never attempted on invalid documents and validation results are always populated. Simplified API surface by removing redundant overloads and improving stream handling. Enhanced documentation and performed general code cleanup for better maintainability.
This commit is contained in:
21
DocumentService.Client/Models/Results/SwissQrCodeResult.cs
Normal file
21
DocumentService.Client/Models/Results/SwissQrCodeResult.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
|
||||
namespace DocumentService.Client.Models.Results;
|
||||
|
||||
/// <summary>
|
||||
/// Combined result of a PDF validation followed by a Swiss QR Code extraction.
|
||||
/// Both operations are always executed; <see cref="QrCode"/> is <c>null</c> when
|
||||
/// the document fails validation.
|
||||
/// </summary>
|
||||
/// <param name="QrCode">
|
||||
/// Extracted Swiss QR Code data, or <c>null</c> if the PDF was invalid or did not
|
||||
/// contain a recognisable Swiss QR Code.
|
||||
/// </param>
|
||||
/// <param name="Validation">
|
||||
/// PDF validation result. Always populated regardless of whether extraction succeeded.
|
||||
/// Use <see cref="DocumentService.Application.Common.DTOs.PdfValidationResult.IsValid"/>
|
||||
/// to determine whether the extraction was attempted.
|
||||
/// </param>
|
||||
public record SwissQrCodeResult(
|
||||
SwissQrCodeExtractionResult? QrCode,
|
||||
PdfValidationResult Validation);
|
||||
Reference in New Issue
Block a user