Refactor: Standardize method names across clients
Renamed methods across multiple client classes for consistency, shortening and aligning naming conventions (e.g., `CheckAttachmentsAsync` → `CheckAsync`, `ValidatePdfAsync` → `ValidateAsync`). Updated corresponding interfaces, unit tests, and documentation to reflect the new method names. Standardized method signatures to support both `Stream` and `byte[]` overloads consistently. Improved error handling in tests and updated examples in the README for batch processing and validation scenarios. Enhanced API endpoint overview for clarity.
This commit is contained in:
@@ -14,7 +14,7 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Attachment check result with metadata</returns>
|
||||
Task<AttachmentCheckResult> CheckAttachmentsAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<AttachmentCheckResult> CheckAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if PDF contains attachments (Base64).
|
||||
@@ -22,7 +22,7 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Attachment check result with metadata</returns>
|
||||
Task<AttachmentCheckResult> CheckAttachmentsAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<AttachmentCheckResult> CheckAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all embedded attachments from a PDF (multipart).
|
||||
@@ -31,7 +31,7 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Dictionary of file name ? content stream for each extracted attachment</returns>
|
||||
Task<Dictionary<string, Stream>> ExtractAttachmentsAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<Dictionary<string, Stream>> ExtractAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all embedded attachments from a PDF (Base64).
|
||||
@@ -40,7 +40,7 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Dictionary of file name ? content stream for each extracted attachment</returns>
|
||||
Task<Dictionary<string, Stream>> ExtractAttachmentsAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<Dictionary<string, Stream>> ExtractAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds attachments to PDF (multipart). ?? Not implemented yet in API.
|
||||
@@ -50,7 +50,7 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Modified PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> AddAttachmentsAsync(Stream pdfStream, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
Task<Stream> AddAsync(Stream pdfStream, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds attachments to PDF (Base64). ?? Not implemented yet in API.
|
||||
@@ -60,5 +60,5 @@ public interface IPdfAttachmentClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Modified PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> AddAttachmentsAsync(byte[] pdfBytes, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
Task<Stream> AddAsync(byte[] pdfBytes, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public interface IPdfConversionClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>PDF/A document as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> ConvertToPdfAAsync(Stream pdfStream, string pdfALevel = "PDF/A-3b", CancellationToken cancellationToken = default);
|
||||
Task<Stream> ToPdfAAsync(Stream pdfStream, string pdfALevel = "PDF/A-3b", CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a standard PDF to PDF/A format (Base64).
|
||||
@@ -27,7 +27,7 @@ public interface IPdfConversionClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>PDF/A document as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> ConvertToPdfAAsync(byte[] pdfBytes, string pdfALevel = "PDF/A-3b", CancellationToken cancellationToken = default);
|
||||
Task<Stream> ToPdfAAsync(byte[] pdfBytes, string pdfALevel = "PDF/A-3b", CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a PDF/A document to standard PDF (multipart).
|
||||
@@ -36,7 +36,7 @@ public interface IPdfConversionClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Standard PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> ConvertFromPdfAAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<Stream> FromPdfAAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a PDF/A document to standard PDF (Base64).
|
||||
@@ -45,5 +45,5 @@ public interface IPdfConversionClient
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Standard PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> ConvertFromPdfAAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<Stream> FromPdfAAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface IPdfValidationClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Validation result with metadata</returns>
|
||||
Task<PdfValidationResult> ValidatePdfAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<PdfValidationResult> ValidateAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a PDF from byte array (Base64 JSON).
|
||||
@@ -21,7 +21,7 @@ public interface IPdfValidationClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Validation result with metadata</returns>
|
||||
Task<PdfValidationResult> ValidatePdfAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<PdfValidationResult> ValidateAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a PDF/A from stream (multipart upload).
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface ISwissQrCodeClient
|
||||
/// <param name="raw">If true, returns raw QR text lines instead of parsed Bill object</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Swiss QR Code extraction result</returns>
|
||||
Task<SwissQrCodeExtractionResult> ExtractSwissQrCodeAsync(Stream pdfStream, bool raw = false, CancellationToken cancellationToken = default);
|
||||
Task<SwissQrCodeExtractionResult> ExtractAsync(Stream pdfStream, bool raw = false, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts Swiss QR Code from PDF (Base64).
|
||||
@@ -23,6 +23,6 @@ public interface ISwissQrCodeClient
|
||||
/// <param name="raw">If true, returns raw QR text lines instead of parsed Bill object</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Swiss QR Code extraction result</returns>
|
||||
Task<SwissQrCodeExtractionResult> ExtractSwissQrCodeAsync(byte[] pdfBytes, bool raw = false, CancellationToken cancellationToken = default);
|
||||
Task<SwissQrCodeExtractionResult> ExtractAsync(byte[] pdfBytes, bool raw = false, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,29 +29,29 @@ public interface IWorkflowsClient
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown when the PDF fails validation and <paramref name="throwIfInvalid"/> is <c>true</c>.
|
||||
/// </exception>
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeValidatedAsync(
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeAsync(
|
||||
byte[] pdfBytes,
|
||||
bool raw = false,
|
||||
bool throwIfInvalid = true,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)"/>
|
||||
/// <inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)"/>
|
||||
/// <param name="pdfStream">PDF file as a stream.</param>
|
||||
/// <param name="raw"><inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='raw']"/></param>
|
||||
/// <param name="throwIfInvalid"><inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='throwIfInvalid']"/></param>
|
||||
/// <param name="raw"><inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='raw']"/></param>
|
||||
/// <param name="throwIfInvalid"><inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='throwIfInvalid']"/></param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeValidatedAsync(
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeAsync(
|
||||
Stream pdfStream,
|
||||
bool raw = false,
|
||||
bool throwIfInvalid = true,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)"/>
|
||||
/// <inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)"/>
|
||||
/// <param name="filePath">Absolute or relative path to the PDF file.</param>
|
||||
/// <param name="raw"><inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='raw']"/></param>
|
||||
/// <param name="throwIfInvalid"><inheritdoc cref="ExtractSwissQrCodeValidatedAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='throwIfInvalid']"/></param>
|
||||
/// <param name="raw"><inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='raw']"/></param>
|
||||
/// <param name="throwIfInvalid"><inheritdoc cref="ExtractSwissQrCodeAsync(byte[], bool, bool, CancellationToken)" path="/param[@name='throwIfInvalid']"/></param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeValidatedAsync(
|
||||
Task<SwissQrCodeExtractionResult?> ExtractSwissQrCodeAsync(
|
||||
string filePath,
|
||||
bool raw = false,
|
||||
bool throwIfInvalid = true,
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface IZugferdClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>ZUGFeRD check result</returns>
|
||||
Task<ZugferdCheckResult> HasZugferdAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<ZugferdCheckResult> CheckAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a PDF contains a ZUGFeRD XML attachment (Base64).
|
||||
@@ -22,7 +22,7 @@ public interface IZugferdClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>ZUGFeRD check result</returns>
|
||||
Task<ZugferdCheckResult> HasZugferdAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<ZugferdCheckResult> CheckAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the ZUGFeRD XML from a PDF and returns the raw XML stream (multipart).
|
||||
@@ -30,7 +30,7 @@ public interface IZugferdClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>ZUGFeRD XML content as stream</returns>
|
||||
Task<Stream> ExtractZugferdAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<Stream> ExtractAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the ZUGFeRD XML from a PDF and returns the raw XML stream (Base64).
|
||||
@@ -38,7 +38,7 @@ public interface IZugferdClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>ZUGFeRD XML content as stream</returns>
|
||||
Task<Stream> ExtractZugferdAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<Stream> ExtractAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts ZUGFeRD metadata and XML content as a structured result (multipart).
|
||||
@@ -46,7 +46,7 @@ public interface IZugferdClient
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Structured ZUGFeRD extraction result</returns>
|
||||
Task<ZugferdExtractionResult> ExtractZugferdAsResultAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
Task<ZugferdExtractionResult> ExtractAsResultAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts ZUGFeRD metadata and XML content as a structured result (Base64).
|
||||
@@ -54,5 +54,5 @@ public interface IZugferdClient
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Structured ZUGFeRD extraction result</returns>
|
||||
Task<ZugferdExtractionResult> ExtractZugferdAsResultAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
Task<ZugferdExtractionResult> ExtractAsResultAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user