Add Swiss QR Code extraction endpoint
Added a new `/extract-swiss-qr-code` endpoint to extract and parse Swiss QR Codes from the last page of a PDF document. Implemented the `ExtractSwissQrCode` handler method, along with helper methods to map domain value objects (`SwissQrCodeData` and `AddressData`) to DTOs. Updated `ExceptionHandlingMiddleware` to handle the new `SwissQrCodeNotFoundException` with a 404 Not Found response. Added integration tests in `ExtractSwissQrCodeEndpointTests` to validate the endpoint's behavior for valid requests, invalid Base64 input, empty references, and empty PDFs. Introduced a helper method to load embedded PDF resources as Base64 strings for testing. Updated `using` directives to include necessary namespaces for the new feature and exception handling.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DocumentOperator.Domain.Common.Exceptions;
|
||||
using DocumentOperator.Domain.Exceptions;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
@@ -94,6 +95,19 @@ public class ExceptionHandlingMiddleware
|
||||
}
|
||||
),
|
||||
|
||||
// Swiss QR Code Not Found Exception (404 Not Found)
|
||||
SwissQrCodeNotFoundException qrNotFoundEx => (
|
||||
HttpStatusCode.NotFound,
|
||||
new ProblemDetails
|
||||
{
|
||||
Type = "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4",
|
||||
Title = "Swiss QR Code Not Found",
|
||||
Status = (int)HttpStatusCode.NotFound,
|
||||
Detail = qrNotFoundEx.Message,
|
||||
Instance = context.Request.Path
|
||||
}
|
||||
),
|
||||
|
||||
// PDF Processing Exception (500 Internal Server Error)
|
||||
PdfProcessingException pdfEx => (
|
||||
HttpStatusCode.InternalServerError,
|
||||
|
||||
Reference in New Issue
Block a user