Refactor DTOs and tests; add framework-specific handling
Refactored the codebase to use shared DTOs from `DocumentService.Application.Common.DTOs`, removing inline DTO definitions in client interfaces and tests. Introduced conditional compilation to handle framework-specific differences in DTOs and handlers. Updated test cases to align with the new DTO structures, including `SwissQrCodeExtractionResult`, `PdfValidationResult`, and `ZugferdExtractionResult`. Adjusted test data to match updated DTO properties. Cleaned up solution and project files, ensuring proper references and organization. Removed unused files and fixed project references in `DocumentService.Tests.csproj`. Improved maintainability and consistency across the codebase.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Client.Interfaces;
|
||||
using DocumentService.Client.Models.Requests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Client.Interfaces;
|
||||
using DocumentService.Client.Models.Requests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Client.Interfaces;
|
||||
using DocumentService.Client.Models.Requests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Application.ExtractZugferd;
|
||||
using DocumentService.Client.Interfaces;
|
||||
using DocumentService.Client.Models.Requests;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Client.Models.Requests;
|
||||
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
@@ -60,30 +61,4 @@ public interface IPdfAttachmentClient
|
||||
/// <returns>Modified PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> AddAttachmentsAsync(byte[] pdfBytes, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for attachment check result
|
||||
/// </summary>
|
||||
public record AttachmentCheckResult
|
||||
{
|
||||
/// <summary>Whether the document contains any embedded file attachments.</summary>
|
||||
public bool HasAttachments { get; init; }
|
||||
/// <summary>Number of embedded file attachments found.</summary>
|
||||
public int AttachmentCount { get; init; }
|
||||
/// <summary>Metadata for each attachment found in the document.</summary>
|
||||
public List<AttachmentMetadata> Attachments { get; init; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for attachment metadata
|
||||
/// </summary>
|
||||
public record AttachmentMetadata
|
||||
{
|
||||
/// <summary>Name of the embedded file.</summary>
|
||||
public string FileName { get; init; } = string.Empty;
|
||||
/// <summary>MIME type of the embedded file (e.g. "application/xml"), or <c>null</c> if unknown.</summary>
|
||||
public string? MimeType { get; init; }
|
||||
/// <summary>Size of the embedded file in bytes.</summary>
|
||||
public long Size { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,40 +38,4 @@ public interface IPdfValidationClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>PDF/A validation result with conformance level and errors</returns>
|
||||
Task<PdfAValidationResult> ValidatePdfAAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for PDF validation result
|
||||
/// </summary>
|
||||
public record PdfValidationResult
|
||||
{
|
||||
/// <summary>Total number of pages in the document.</summary>
|
||||
public int PageCount { get; init; }
|
||||
/// <summary>File size in bytes.</summary>
|
||||
public long FileSizeBytes { get; init; }
|
||||
/// <summary>PDF specification version (e.g. "1.7").</summary>
|
||||
public string PdfVersion { get; init; } = string.Empty;
|
||||
/// <summary>Whether the document is password-protected.</summary>
|
||||
public bool IsEncrypted { get; init; }
|
||||
/// <summary>Whether the document contains embedded file attachments.</summary>
|
||||
public bool HasAttachments { get; init; }
|
||||
/// <summary>Number of embedded file attachments.</summary>
|
||||
public int AttachmentCount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for PDF/A validation result
|
||||
/// </summary>
|
||||
public record PdfAValidationResult
|
||||
{
|
||||
/// <summary>Whether the document is fully PDF/A conformant.</summary>
|
||||
public bool IsValid { get; init; }
|
||||
/// <summary>Detected PDF/A conformance level (e.g. "PDF/A-3b"), or <c>null</c> if not a PDF/A document.</summary>
|
||||
public string? PdfAVersion { get; init; }
|
||||
/// <summary>Total number of pages in the document.</summary>
|
||||
public int PageCount { get; init; }
|
||||
/// <summary>List of conformance errors found during validation.</summary>
|
||||
public List<string> Errors { get; init; } = new();
|
||||
/// <summary>List of conformance warnings found during validation.</summary>
|
||||
public List<string> Warnings { get; init; } = new();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
@@ -24,13 +26,3 @@ public interface ISwissQrCodeClient
|
||||
Task<SwissQrCodeExtractionResult> ExtractSwissQrCodeAsync(byte[] pdfBytes, bool raw = false, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for Swiss QR Code extraction result
|
||||
/// </summary>
|
||||
public record SwissQrCodeExtractionResult
|
||||
{
|
||||
/// <summary>Parsed Swiss QR bill object. <c>null</c> when <c>raw=true</c> was requested.</summary>
|
||||
public object? Bill { get; init; }
|
||||
/// <summary>Raw QR code text lines. Populated when <c>raw=true</c> was requested.</summary>
|
||||
public List<string> RawLines { get; init; } = new();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Application.ExtractZugferd;
|
||||
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
@@ -53,27 +56,3 @@ public interface IZugferdClient
|
||||
/// <returns>Structured ZUGFeRD extraction result</returns>
|
||||
Task<ZugferdExtractionResult> ExtractZugferdAsResultAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>DTO for ZUGFeRD detection result</summary>
|
||||
public record ZugferdCheckResult
|
||||
{
|
||||
/// <summary>Whether the document contains a ZUGFeRD XML attachment.</summary>
|
||||
public bool HasZugferd { get; init; }
|
||||
/// <summary>Detected ZUGFeRD version (e.g. "2.1"), or <c>null</c> if not present.</summary>
|
||||
public string? Version { get; init; }
|
||||
/// <summary>ZUGFeRD profile name (e.g. "EN 16931"), or <c>null</c> if not present.</summary>
|
||||
public string? Profile { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>DTO for ZUGFeRD extraction result</summary>
|
||||
public record ZugferdExtractionResult
|
||||
{
|
||||
/// <summary>File name of the extracted XML attachment (e.g. "factur-x.xml").</summary>
|
||||
public string FileName { get; init; } = string.Empty;
|
||||
/// <summary>Full XML content of the ZUGFeRD attachment.</summary>
|
||||
public string XmlContent { get; init; } = string.Empty;
|
||||
/// <summary>ZUGFeRD version (e.g. "2.1"), or <c>null</c> if not detected.</summary>
|
||||
public string? Version { get; init; }
|
||||
/// <summary>ZUGFeRD profile name (e.g. "EN 16931"), or <c>null</c> if not detected.</summary>
|
||||
public string? Profile { get; init; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user