From 1a6e48aabf201f5987f2a53f9a768c9f55e5efbf Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Tue, 17 Feb 2026 17:58:10 +0100
Subject: [PATCH 01/33] :recycle: completely separate v1 and v2 code
---
src/Mindee.Cli/Commands/V1/PredictCommand.cs | 1 +
.../ClientOptions/AsyncPollingOptions.cs | 77 +++++++++++++++++++
src/Mindee/Parsing/BaseLocalResponse.cs | 70 -----------------
src/Mindee/V1/Client.cs | 2 +
src/Mindee/V2/Client.cs | 1 +
.../Mindee.IntegrationTests/V1/ClientTest.cs | 1 +
tests/Mindee.UnitTests/V1/ClientTest.cs | 1 +
tests/Mindee.UnitTests/V2/ClientTest.cs | 1 +
8 files changed, 84 insertions(+), 70 deletions(-)
create mode 100644 src/Mindee/ClientOptions/AsyncPollingOptions.cs
delete mode 100644 src/Mindee/Parsing/BaseLocalResponse.cs
diff --git a/src/Mindee.Cli/Commands/V1/PredictCommand.cs b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
index 790b5831a..12b22ff5a 100644
--- a/src/Mindee.Cli/Commands/V1/PredictCommand.cs
+++ b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
@@ -1,5 +1,6 @@
using System.CommandLine;
using System.Text.Json;
+using Mindee.ClientOptions;
using Mindee.Input;
using Mindee.V1;
using Mindee.V1.ClientOptions;
diff --git a/src/Mindee/ClientOptions/AsyncPollingOptions.cs b/src/Mindee/ClientOptions/AsyncPollingOptions.cs
new file mode 100644
index 000000000..a0a9a1002
--- /dev/null
+++ b/src/Mindee/ClientOptions/AsyncPollingOptions.cs
@@ -0,0 +1,77 @@
+using System;
+using Mindee.Exceptions;
+
+namespace Mindee.ClientOptions
+{
+ ///
+ /// ResultOptions to pass for asynchronous parsing with polling.
+ ///
+ public sealed class AsyncPollingOptions
+ {
+ ///
+ /// ResultOptions to pass for asynchronous parsing with polling.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public AsyncPollingOptions(double initialDelaySec = 2.0, double intervalSec = 1.5, int maxRetries = 80)
+ {
+ var minInitialDelaySec = 1.0;
+ var minIntervalSec = 1.0;
+ var minRetries = 2;
+ if (initialDelaySec < minInitialDelaySec)
+ {
+ throw new MindeeException(
+ $"Cannot set initial polling delay to less than {Math.Floor(minInitialDelaySec)} second(s).");
+ }
+
+ if (intervalSec < minIntervalSec)
+ {
+ throw new MindeeException(
+ $"Cannot set polling interval to less than {Math.Floor(minIntervalSec)} second(s).");
+ }
+
+ if (maxRetries < minRetries)
+ {
+ throw new MindeeException($"Cannot set async retry to less than {minRetries} attempts.");
+ }
+
+ InitialDelaySec = initialDelaySec;
+ IntervalSec = intervalSec;
+ MaxRetries = maxRetries;
+ InitialDelayMilliSec = (int)Math.Floor(InitialDelaySec * 1000);
+ IntervalMilliSec = (int)Math.Floor(IntervalSec * 1000);
+ }
+
+ ///
+ /// Initial delay before the first polling attempt.
+ ///
+ public double InitialDelaySec { get; }
+
+ ///
+ /// Delay between each polling attempt.
+ ///
+ public double IntervalSec { get; }
+
+ ///
+ /// Total number of polling attempts.
+ ///
+ public int MaxRetries { get; }
+
+ ///
+ /// Wait this many milliseconds between each polling attempt.
+ ///
+ public int InitialDelayMilliSec { get; }
+
+ ///
+ /// Wait this many milliseconds before the first polling attempt.
+ ///
+ public int IntervalMilliSec { get; }
+ }
+}
diff --git a/src/Mindee/Parsing/BaseLocalResponse.cs b/src/Mindee/Parsing/BaseLocalResponse.cs
deleted file mode 100644
index a9e55519f..000000000
--- a/src/Mindee/Parsing/BaseLocalResponse.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.IO;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace Mindee.Parsing
-{
- ///
- /// A Mindee response saved locally.
- ///
- public abstract class BaseLocalResponse
- {
- ///
- /// Load from a string.
- ///
- /// Will be decoded as UTF-8.
- public BaseLocalResponse(string input)
- {
- FileBytes = Encoding.UTF8.GetBytes(input.Replace("\r", "").Replace("\n", ""));
- }
-
- ///
- /// Load from a file.
- ///
- /// Will be decoded as UTF-8.
- public BaseLocalResponse(FileInfo input)
- {
- FileBytes = Encoding.UTF8.GetBytes(
- File.ReadAllText(input.FullName).Replace("\r", "").Replace("\n", ""));
- }
-
- ///
- /// ResultFile as UTF-8 bytes.
- ///
- public byte[] FileBytes { get; }
-
- ///
- /// Get the HMAC signature of the payload.
- ///
- /// Your secret key from the Mindee platform.
- /// The generated HMAC signature.
- public string GetHmacSignature(string secretKey)
- {
- var keyBytes = Encoding.UTF8.GetBytes(secretKey);
- using var hmac = new HMACSHA256(keyBytes);
- var hexString = BitConverter.ToString(hmac.ComputeHash(FileBytes));
- return hexString.Replace("-", "").ToLower();
- }
-
- ///
- /// Verify that the payload's signature matches the one received from the server.
- ///
- /// Your secret key from the Mindee platform.
- /// The signature from the "X-Mindee-Hmac-Signature" HTTP header.
- ///
- public bool IsValidHmacSignature(string secretKey, string signature)
- {
- return GetHmacSignature(secretKey) == signature.ToLower();
- }
-
- ///
- /// Print the file as a UTF-8 string.
- ///
- ///
- public override string ToString()
- {
- return Encoding.UTF8.GetString(FileBytes);
- }
- }
-}
diff --git a/src/Mindee/V1/Client.cs b/src/Mindee/V1/Client.cs
index 3156ec0b3..9b8d0eedc 100644
--- a/src/Mindee/V1/Client.cs
+++ b/src/Mindee/V1/Client.cs
@@ -3,9 +3,11 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Extensions.DependencyInjection;
using Mindee.Input;
+using Mindee.Parsing;
using Mindee.Pdf;
using Mindee.V1.ClientOptions;
using Mindee.V1.Http;
diff --git a/src/Mindee/V2/Client.cs b/src/Mindee/V2/Client.cs
index d103cdb6b..a8253eebd 100644
--- a/src/Mindee/V2/Client.cs
+++ b/src/Mindee/V2/Client.cs
@@ -3,6 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
+using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Extensions.DependencyInjection;
using Mindee.Input;
diff --git a/tests/Mindee.IntegrationTests/V1/ClientTest.cs b/tests/Mindee.IntegrationTests/V1/ClientTest.cs
index 3196d79f8..59a9be2c6 100644
--- a/tests/Mindee.IntegrationTests/V1/ClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V1/ClientTest.cs
@@ -1,3 +1,4 @@
+using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Input;
using Mindee.V1;
diff --git a/tests/Mindee.UnitTests/V1/ClientTest.cs b/tests/Mindee.UnitTests/V1/ClientTest.cs
index 385d4f53a..f21bea1a4 100644
--- a/tests/Mindee.UnitTests/V1/ClientTest.cs
+++ b/tests/Mindee.UnitTests/V1/ClientTest.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging.Abstractions;
using Mindee.Input;
+using Mindee.Parsing;
using Mindee.Pdf;
using Mindee.V1;
using Mindee.V1.Http;
diff --git a/tests/Mindee.UnitTests/V2/ClientTest.cs b/tests/Mindee.UnitTests/V2/ClientTest.cs
index 2123f5bc6..c5a3c40ec 100644
--- a/tests/Mindee.UnitTests/V2/ClientTest.cs
+++ b/tests/Mindee.UnitTests/V2/ClientTest.cs
@@ -1,4 +1,5 @@
using Mindee.Input;
+using Mindee.Parsing;
using Mindee.V2;
using Mindee.V2.Http;
using Mindee.V2.Parsing;
From 2f8eb2eb930f6ae3c617fafeafedbf3029cdc0e6 Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Fri, 20 Feb 2026 17:19:17 +0100
Subject: [PATCH 02/33] :boom: :recycle: Update syntaxes in V2 to accomodate
for generics
---
src/Mindee.Cli/Commands/V1/PredictCommand.cs | 3 +-
.../ClientOptions/AsyncPollingOptions.cs | 77 ----------------
src/Mindee/Parsing/BaseLocalResponse.cs | 70 ++++++++++++++
src/Mindee/V1/Client.cs | 2 -
.../{Inference.cs => ExtractionInference.cs} | 2 +-
.../Product/BarcodeReader/BarcodeReaderV1.cs | 2 +-
src/Mindee/V1/Product/Cropper/CropperV1.cs | 2 +-
.../FinancialDocument/FinancialDocumentV1.cs | 2 +-
.../BankAccountDetailsV1.cs | 2 +-
.../BankAccountDetailsV2.cs | 2 +-
.../V1/Product/Fr/CarteGrise/CarteGriseV1.cs | 2 +-
.../V1/Product/Fr/HealthCard/HealthCardV1.cs | 2 +-
src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs | 2 +-
src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs | 2 +-
src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs | 2 +-
.../V1/Product/Generated/GeneratedV1.cs | 2 +-
.../InternationalId/InternationalIdV2.cs | 2 +-
src/Mindee/V1/Product/Invoice/InvoiceV4.cs | 2 +-
.../InvoiceSplitter/InvoiceSplitterV1.cs | 2 +-
.../MultiReceiptsDetectorV1.cs | 2 +-
src/Mindee/V1/Product/Passport/PassportV1.cs | 2 +-
src/Mindee/V1/Product/Receipt/ReceiptV4.cs | 2 +-
src/Mindee/V1/Product/Receipt/ReceiptV5.cs | 2 +-
.../V1/Product/Us/BankCheck/BankCheckV1.cs | 2 +-
.../PayrollCheckRegisterV1.cs | 2 +-
src/Mindee/V2/Client.cs | 91 ++++++++-----------
src/Mindee/V2/Http/HttpApiV2.cs | 38 ++------
src/Mindee/V2/Http/MindeeApiV2.cs | 58 ++----------
src/Mindee/V2/Parsing/BaseResponse.cs | 10 +-
.../V2/Parsing/Inference/BaseInference.cs | 9 +-
src/Mindee/V2/Parsing/LocalResponse.cs | 5 +-
src/Mindee/V2/Product/BaseProduct.cs | 25 +++++
.../V2/Product/Extraction/Extraction.cs | 26 ++++++
.../Product/Extraction/ExtractionResponse.cs | 5 +-
.../Extraction/Params/ExtractionParameters.cs | 4 +-
.../Mindee.IntegrationTests/V1/ClientTest.cs | 1 -
.../Mindee.IntegrationTests/V2/ClientTest.cs | 7 +-
tests/Mindee.UnitTests/V1/ClientTest.cs | 1 -
.../V1/Parsing/Common/FullTextOcrTest.cs | 2 +-
tests/Mindee.UnitTests/V2/ClientTest.cs | 9 +-
.../V2/Input/LocalResponseTest.cs | 6 +-
.../V2/Product/ExtractionTest.cs | 6 +-
42 files changed, 233 insertions(+), 264 deletions(-)
delete mode 100644 src/Mindee/ClientOptions/AsyncPollingOptions.cs
create mode 100644 src/Mindee/Parsing/BaseLocalResponse.cs
rename src/Mindee/V1/Parsing/Common/{Inference.cs => ExtractionInference.cs} (97%)
create mode 100644 src/Mindee/V2/Product/BaseProduct.cs
create mode 100644 src/Mindee/V2/Product/Extraction/Extraction.cs
diff --git a/src/Mindee.Cli/Commands/V1/PredictCommand.cs b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
index 12b22ff5a..46b010b4b 100644
--- a/src/Mindee.Cli/Commands/V1/PredictCommand.cs
+++ b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
@@ -1,6 +1,5 @@
using System.CommandLine;
using System.Text.Json;
-using Mindee.ClientOptions;
using Mindee.Input;
using Mindee.V1;
using Mindee.V1.ClientOptions;
@@ -31,7 +30,7 @@ internal struct ParseOptions(string path, bool allWords, bool fullText, OutputTy
class PredictCommand : Command
where TDoc : IPrediction, new()
where TPage : IPrediction, new()
- where TInferenceModel : Inference, new()
+ where TInferenceModel : ExtractionInference, new()
{
private readonly Option _outputOption;
private readonly Option? _allWordsOption;
diff --git a/src/Mindee/ClientOptions/AsyncPollingOptions.cs b/src/Mindee/ClientOptions/AsyncPollingOptions.cs
deleted file mode 100644
index a0a9a1002..000000000
--- a/src/Mindee/ClientOptions/AsyncPollingOptions.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using Mindee.Exceptions;
-
-namespace Mindee.ClientOptions
-{
- ///
- /// ResultOptions to pass for asynchronous parsing with polling.
- ///
- public sealed class AsyncPollingOptions
- {
- ///
- /// ResultOptions to pass for asynchronous parsing with polling.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public AsyncPollingOptions(double initialDelaySec = 2.0, double intervalSec = 1.5, int maxRetries = 80)
- {
- var minInitialDelaySec = 1.0;
- var minIntervalSec = 1.0;
- var minRetries = 2;
- if (initialDelaySec < minInitialDelaySec)
- {
- throw new MindeeException(
- $"Cannot set initial polling delay to less than {Math.Floor(minInitialDelaySec)} second(s).");
- }
-
- if (intervalSec < minIntervalSec)
- {
- throw new MindeeException(
- $"Cannot set polling interval to less than {Math.Floor(minIntervalSec)} second(s).");
- }
-
- if (maxRetries < minRetries)
- {
- throw new MindeeException($"Cannot set async retry to less than {minRetries} attempts.");
- }
-
- InitialDelaySec = initialDelaySec;
- IntervalSec = intervalSec;
- MaxRetries = maxRetries;
- InitialDelayMilliSec = (int)Math.Floor(InitialDelaySec * 1000);
- IntervalMilliSec = (int)Math.Floor(IntervalSec * 1000);
- }
-
- ///
- /// Initial delay before the first polling attempt.
- ///
- public double InitialDelaySec { get; }
-
- ///
- /// Delay between each polling attempt.
- ///
- public double IntervalSec { get; }
-
- ///
- /// Total number of polling attempts.
- ///
- public int MaxRetries { get; }
-
- ///
- /// Wait this many milliseconds between each polling attempt.
- ///
- public int InitialDelayMilliSec { get; }
-
- ///
- /// Wait this many milliseconds before the first polling attempt.
- ///
- public int IntervalMilliSec { get; }
- }
-}
diff --git a/src/Mindee/Parsing/BaseLocalResponse.cs b/src/Mindee/Parsing/BaseLocalResponse.cs
new file mode 100644
index 000000000..a9e55519f
--- /dev/null
+++ b/src/Mindee/Parsing/BaseLocalResponse.cs
@@ -0,0 +1,70 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Mindee.Parsing
+{
+ ///
+ /// A Mindee response saved locally.
+ ///
+ public abstract class BaseLocalResponse
+ {
+ ///
+ /// Load from a string.
+ ///
+ /// Will be decoded as UTF-8.
+ public BaseLocalResponse(string input)
+ {
+ FileBytes = Encoding.UTF8.GetBytes(input.Replace("\r", "").Replace("\n", ""));
+ }
+
+ ///
+ /// Load from a file.
+ ///
+ /// Will be decoded as UTF-8.
+ public BaseLocalResponse(FileInfo input)
+ {
+ FileBytes = Encoding.UTF8.GetBytes(
+ File.ReadAllText(input.FullName).Replace("\r", "").Replace("\n", ""));
+ }
+
+ ///
+ /// ResultFile as UTF-8 bytes.
+ ///
+ public byte[] FileBytes { get; }
+
+ ///
+ /// Get the HMAC signature of the payload.
+ ///
+ /// Your secret key from the Mindee platform.
+ /// The generated HMAC signature.
+ public string GetHmacSignature(string secretKey)
+ {
+ var keyBytes = Encoding.UTF8.GetBytes(secretKey);
+ using var hmac = new HMACSHA256(keyBytes);
+ var hexString = BitConverter.ToString(hmac.ComputeHash(FileBytes));
+ return hexString.Replace("-", "").ToLower();
+ }
+
+ ///
+ /// Verify that the payload's signature matches the one received from the server.
+ ///
+ /// Your secret key from the Mindee platform.
+ /// The signature from the "X-Mindee-Hmac-Signature" HTTP header.
+ ///
+ public bool IsValidHmacSignature(string secretKey, string signature)
+ {
+ return GetHmacSignature(secretKey) == signature.ToLower();
+ }
+
+ ///
+ /// Print the file as a UTF-8 string.
+ ///
+ ///
+ public override string ToString()
+ {
+ return Encoding.UTF8.GetString(FileBytes);
+ }
+ }
+}
diff --git a/src/Mindee/V1/Client.cs b/src/Mindee/V1/Client.cs
index 9b8d0eedc..3156ec0b3 100644
--- a/src/Mindee/V1/Client.cs
+++ b/src/Mindee/V1/Client.cs
@@ -3,11 +3,9 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Extensions.DependencyInjection;
using Mindee.Input;
-using Mindee.Parsing;
using Mindee.Pdf;
using Mindee.V1.ClientOptions;
using Mindee.V1.Http;
diff --git a/src/Mindee/V1/Parsing/Common/Inference.cs b/src/Mindee/V1/Parsing/Common/ExtractionInference.cs
similarity index 97%
rename from src/Mindee/V1/Parsing/Common/Inference.cs
rename to src/Mindee/V1/Parsing/Common/ExtractionInference.cs
index 0216e8cd6..4f20632d2 100644
--- a/src/Mindee/V1/Parsing/Common/Inference.cs
+++ b/src/Mindee/V1/Parsing/Common/ExtractionInference.cs
@@ -10,7 +10,7 @@ namespace Mindee.V1.Parsing.Common
///
/// Page prediction (could be the same that TDocumentPrediction).
/// Document prediction (could be the same that TPagePrediction).
- public abstract class Inference
+ public abstract class ExtractionInference
where TPagePrediction : IPrediction, new()
where TDocumentPrediction : IPrediction, new()
{
diff --git a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
index cc306a0b0..23621e7ad 100644
--- a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
+++ b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.BarcodeReader
/// Barcode Reader API version 1 inference prediction.
///
[Endpoint("barcode_reader", "1")]
- public sealed class BarcodeReaderV1 : Inference
+ public sealed class BarcodeReaderV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Cropper/CropperV1.cs b/src/Mindee/V1/Product/Cropper/CropperV1.cs
index 6784b9929..a8e4bb222 100644
--- a/src/Mindee/V1/Product/Cropper/CropperV1.cs
+++ b/src/Mindee/V1/Product/Cropper/CropperV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Cropper
/// Cropper API version 1 inference prediction.
///
[Endpoint("cropper", "1")]
- public sealed class CropperV1 : Inference
+ public sealed class CropperV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs b/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
index 55c9739e2..be290470b 100644
--- a/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
+++ b/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.FinancialDocument
/// Financial Document API version 1 inference prediction.
///
[Endpoint("financial_document", "1")]
- public sealed class FinancialDocumentV1 : Inference
+ public sealed class FinancialDocumentV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
index fc8f4f836..4d923bebf 100644
--- a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
+++ b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.BankAccountDetails
/// Bank Account Details API version 1 inference prediction.
///
[Endpoint("bank_account_details", "1")]
- public sealed class BankAccountDetailsV1 : Inference
+ public sealed class BankAccountDetailsV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
index f3af6459d..66cefe3c8 100644
--- a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
+++ b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.BankAccountDetails
/// Bank Account Details API version 2 inference prediction.
///
[Endpoint("bank_account_details", "2")]
- public sealed class BankAccountDetailsV2 : Inference
+ public sealed class BankAccountDetailsV2 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs b/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
index 9f210fc60..9539ee0d1 100644
--- a/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
+++ b/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.CarteGrise
/// Carte Grise API version 1 inference prediction.
///
[Endpoint("carte_grise", "1")]
- public sealed class CarteGriseV1 : Inference
+ public sealed class CarteGriseV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs b/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
index 563d12418..dd01c8e5f 100644
--- a/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
+++ b/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.HealthCard
/// Health Card API version 1 inference prediction.
///
[Endpoint("french_healthcard", "1")]
- public sealed class HealthCardV1 : Inference
+ public sealed class HealthCardV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs b/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
index c51fb62c6..db3b878a7 100644
--- a/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
+++ b/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.IdCard
/// Carte Nationale d'Identité API version 1 inference prediction.
///
[Endpoint("idcard_fr", "1")]
- public sealed class IdCardV1 : Inference
+ public sealed class IdCardV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs b/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
index 005b812fb..8581605d6 100644
--- a/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
+++ b/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.IdCard
/// Carte Nationale d'Identité API version 2 inference prediction.
///
[Endpoint("idcard_fr", "2")]
- public sealed class IdCardV2 : Inference
+ public sealed class IdCardV2 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs b/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
index daf742794..8f71e6db0 100644
--- a/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
+++ b/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.Payslip
/// Payslip API version 3 inference prediction.
///
[Endpoint("payslip_fra", "3")]
- public sealed class PayslipV3 : Inference
+ public sealed class PayslipV3 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Generated/GeneratedV1.cs b/src/Mindee/V1/Product/Generated/GeneratedV1.cs
index 881228f96..28bfd3514 100644
--- a/src/Mindee/V1/Product/Generated/GeneratedV1.cs
+++ b/src/Mindee/V1/Product/Generated/GeneratedV1.cs
@@ -5,7 +5,7 @@ namespace Mindee.V1.Product.Generated
///
/// The definition for Generated Documents, API version 1.
///
- public class GeneratedV1 : Inference
+ public class GeneratedV1 : ExtractionInference
{
}
diff --git a/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs b/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
index e1dfb44b0..b8be8350b 100644
--- a/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
+++ b/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.InternationalId
/// International ID API version 2 inference prediction.
///
[Endpoint("international_id", "2")]
- public sealed class InternationalIdV2 : Inference
+ public sealed class InternationalIdV2 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Invoice/InvoiceV4.cs b/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
index 5a7d009be..9e5601325 100644
--- a/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
+++ b/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Invoice
/// Invoice API version 4 inference prediction.
///
[Endpoint("invoices", "4")]
- public sealed class InvoiceV4 : Inference
+ public sealed class InvoiceV4 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs b/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
index f1c200613..35e334a63 100644
--- a/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
+++ b/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.InvoiceSplitter
/// Invoice Splitter API version 1 inference prediction.
///
[Endpoint("invoice_splitter", "1")]
- public sealed class InvoiceSplitterV1 : Inference
+ public sealed class InvoiceSplitterV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs b/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
index f54d5168b..1ef706889 100644
--- a/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
+++ b/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.MultiReceiptsDetector
/// Multi Receipts Detector API version 1 inference prediction.
///
[Endpoint("multi_receipts_detector", "1")]
- public sealed class MultiReceiptsDetectorV1 : Inference
+ public sealed class MultiReceiptsDetectorV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Passport/PassportV1.cs b/src/Mindee/V1/Product/Passport/PassportV1.cs
index dfcb8031e..a952ae316 100644
--- a/src/Mindee/V1/Product/Passport/PassportV1.cs
+++ b/src/Mindee/V1/Product/Passport/PassportV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Passport
/// Passport API version 1 inference prediction.
///
[Endpoint("passport", "1")]
- public sealed class PassportV1 : Inference
+ public sealed class PassportV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Receipt/ReceiptV4.cs b/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
index 9fe7ad7ea..23b0df32e 100644
--- a/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
+++ b/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
@@ -7,7 +7,7 @@ namespace Mindee.V1.Product.Receipt
/// The definition for Receipt, API version 4.
///
[Endpoint("expense_receipts", "4")]
- public sealed class ReceiptV4 : Inference
+ public sealed class ReceiptV4 : ExtractionInference
{
}
}
diff --git a/src/Mindee/V1/Product/Receipt/ReceiptV5.cs b/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
index f5f23e056..07504bf93 100644
--- a/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
+++ b/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Receipt
/// Receipt API version 5 inference prediction.
///
[Endpoint("expense_receipts", "5")]
- public sealed class ReceiptV5 : Inference
+ public sealed class ReceiptV5 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
index e83b95fbb..d509bfe38 100644
--- a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
+++ b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Us.BankCheck
/// Bank Check API version 1 inference prediction.
///
[Endpoint("bank_check", "1")]
- public sealed class BankCheckV1 : Inference
+ public sealed class BankCheckV1 : ExtractionInference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
index a2ce54b31..0d58f5fe8 100644
--- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
+++ b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
@@ -7,7 +7,7 @@ namespace Mindee.V1.Product.Us.PayrollCheckRegister
/// The definition for Payroll Check Register, API version 1.
///
[Endpoint("payroll_check_register", "1")]
- public sealed class PayrollCheckRegisterV1 : Inference
+ public sealed class PayrollCheckRegisterV1 : ExtractionInference
{
}
}
diff --git a/src/Mindee/V2/Client.cs b/src/Mindee/V2/Client.cs
index a8253eebd..3c336e50c 100644
--- a/src/Mindee/V2/Client.cs
+++ b/src/Mindee/V2/Client.cs
@@ -3,14 +3,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
-using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Extensions.DependencyInjection;
using Mindee.Input;
using Mindee.V2.ClientOptions;
using Mindee.V2.Http;
using Mindee.V2.Parsing;
-using Mindee.V2.Parsing.Search;
+using Mindee.V2.Product;
using Mindee.V2.Product.Extraction;
using Mindee.V2.Product.Extraction.Params;
using SettingsV2 = Mindee.V2.Http.Settings;
@@ -96,7 +95,7 @@ public Client(HttpApiV2 httpApi, ILoggerFactory logger = null)
///
///
///
- ///
+ ///
///
///
///
@@ -105,7 +104,7 @@ public Client(HttpApiV2 httpApi, ILoggerFactory logger = null)
///
public async Task EnqueueAsync(
InputSource inputSource
- , BaseParameters parameters)
+ , ExtractionParameters extractionParameters)
{
switch (inputSource)
{
@@ -121,7 +120,7 @@ InputSource inputSource
throw new MindeeInputException($"Unsupported input source {inputSource.GetType().Name}");
}
- return await _mindeeApi.ReqPostEnqueueAsync(inputSource, parameters);
+ return await _mindeeApi.ReqPostEnqueueAsync(inputSource, extractionParameters);
}
///
@@ -130,9 +129,9 @@ InputSource inputSource
///
/// The URL to poll to retrieve the job.
///
- ///
+ ///
///
- public async Task GetJobFromUrlAsync(string pollingUrl)
+ public async Task GetJobAsync(string pollingUrl)
{
_logger?.LogInformation("Getting Job at: {}", pollingUrl);
@@ -141,7 +140,7 @@ public async Task GetJobFromUrlAsync(string pollingUrl)
throw new ArgumentNullException(pollingUrl);
}
- return await _mindeeApi.ReqGetJobFromUrlAsync(pollingUrl);
+ return await _mindeeApi.ReqGetJobAsync(pollingUrl);
}
///
@@ -152,8 +151,8 @@ public async Task GetJobFromUrlAsync(string pollingUrl)
///
///
///
- private async Task GetResultFromUrlAsync(string pollingUrl)
- where TResponse : BaseResponse, new()
+ public async Task> GetResultAsync(string pollingUrl)
+ where TProduct : BaseProduct, new()
{
_logger?.LogInformation("Polling: {}", pollingUrl);
@@ -161,46 +160,34 @@ private async Task GetResultFromUrlAsync(string pollingUrl
{
throw new ArgumentNullException(pollingUrl);
}
- return await _mindeeApi.ReqGetResultFromUrlAsync(pollingUrl);
- }
-
- ///
- /// Get the status of an inference that was previously enqueued.
- /// Can be used for polling.
- ///
- /// The job id.
- ///
- ///
- ///
- public async Task GetResultAsync(string jobId)
- where TResponse : BaseResponse, new()
- {
- _logger?.LogInformation("Polling: {}", jobId);
-
- if (string.IsNullOrWhiteSpace(jobId))
- {
- throw new ArgumentNullException(jobId);
- }
- return await _mindeeApi.ReqGetResultAsync(jobId);
+ return await _mindeeApi.ReqGetInferenceAsync(pollingUrl);
}
///
- /// Get the status of an inference that was previously enqueued.
- /// Can be used for polling.
+ /// Add the document to an async queue, poll, and parse when complete.
///
- /// The job id.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
///
///
///
- public async Task GetJobAsync(string jobId)
+ ///
+ public async Task EnqueueAndGetInferenceAsync(
+ InputSource inputSource
+ , ExtractionParameters extractionParameters)
{
- _logger?.LogInformation("Getting job {}", jobId);
-
- if (string.IsNullOrWhiteSpace(jobId))
+ var response =
+ await EnqueueAndGetResultAsync(inputSource, extractionParameters);
+ if (response is ExtractionResponse extractionResponse)
{
- throw new ArgumentNullException(jobId);
+ return extractionResponse;
}
- return await _mindeeApi.ReqGetJobAsync(jobId);
+ throw new MindeeException($"Unexpected response type '{response.GetType().Name}'.");
}
///
@@ -210,17 +197,17 @@ public async Task GetJobAsync(string jobId)
///
///
///
- ///
- ///
+ ///
+ ///
///
///
///
///
///
- public async Task EnqueueAndGetResultAsync(
+ public async Task> EnqueueAndGetResultAsync(
InputSource inputSource
- , BaseParameters parameters)
- where TResponse : BaseResponse, new()
+ , ExtractionParameters extractionParameters)
+ where TProduct : BaseProduct, new()
{
switch (inputSource)
{
@@ -236,12 +223,12 @@ InputSource inputSource
throw new MindeeInputException($"Unsupported input source {inputSource.GetType().Name}");
}
- parameters.PollingOptions ??= new PollingOptions();
+ extractionParameters.PollingOptions ??= new PollingOptions();
var enqueueResponse = await EnqueueAsync(
inputSource,
- parameters);
- return await PollForResultsAsync(enqueueResponse, parameters.PollingOptions);
+ extractionParameters);
+ return await PollForResultsAsync(enqueueResponse, extractionParameters.PollingOptions);
}
///
@@ -266,9 +253,9 @@ public async Task SearchModels(string name = null, string modelT
///
///
/// Thrown when maxRetries is reached and the result isn't ready.
- private async Task PollForResultsAsync(
+ private async Task> PollForResultsAsync(
JobResponse enqueueResponse,
- PollingOptions pollingOptions) where TResponse : BaseResponse, new()
+ PollingOptions pollingOptions) where TProduct : BaseProduct, new()
{
var maxRetries = pollingOptions.MaxRetries + 1;
var pollingUrl = enqueueResponse.Job.PollingUrl;
@@ -287,7 +274,7 @@ private async Task PollForResultsAsync(
retryCount,
maxRetries);
- response = await GetJobFromUrlAsync(pollingUrl);
+ response = await GetJobAsync(pollingUrl);
if (response.Job.Error != null)
{
break;
@@ -296,7 +283,7 @@ private async Task PollForResultsAsync(
if (response.Job.Status.Equals("Processed"))
{
var resultUrl = response.Job.ResultUrl;
- return await GetResultFromUrlAsync(resultUrl);
+ return await GetResultAsync(resultUrl);
}
retryCount++;
diff --git a/src/Mindee/V2/Http/HttpApiV2.cs b/src/Mindee/V2/Http/HttpApiV2.cs
index 67bac16ea..663be5259 100644
--- a/src/Mindee/V2/Http/HttpApiV2.cs
+++ b/src/Mindee/V2/Http/HttpApiV2.cs
@@ -1,5 +1,6 @@
#nullable enable
+using System;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@@ -7,7 +8,7 @@
using Mindee.Input;
using Mindee.V2.ClientOptions;
using Mindee.V2.Parsing;
-using Mindee.V2.Parsing.Search;
+using Mindee.V2.Product;
namespace Mindee.V2.Http
{
@@ -41,33 +42,13 @@ public abstract class HttpApiV2
/// Get a job for an enqueued document.
///
/// The job ID as returned by the predict_async route.
- public abstract Task ReqGetJobFromUrlAsync(string pollingUrl);
-
- ///
- /// Get a job for an enqueued document.
- ///
- /// The job ID as returned by the predict_async route.
- public abstract Task ReqGetJobAsync(string jobId);
-
- ///
- /// Get a document inference.
- ///
- /// Url to poll.
- public abstract Task ReqGetResultAsync(string inferenceId) where TResponse : BaseResponse, new();
+ public abstract Task ReqGetJobAsync(string pollingUrl);
///
/// Get a document inference.
///
/// Url to poll.
- public abstract Task ReqGetResultFromUrlAsync(string resultUrl) where TResponse : BaseResponse, new();
-
- ///
- /// Retrieves a list of models available for a given API key.
- ///
- /// Name of the model to search for.
- /// Type of the model to search for.
- ///
- public abstract Task SearchModels(string? name, string? modelType);
+ public abstract Task> ReqGetInferenceAsync(string resultUrl) where TProduct : BaseProduct, new();
///
/// Get the error from the server return.
@@ -98,10 +79,11 @@ protected ErrorResponse GetErrorFromContent(int statusCode, string? responseCont
/// Attempt to deserialize a response from the server.
///
///
- ///
+ ///
+ ///
///
- protected TResponse DeserializeResponse(string? responseContent)
- where TResponse : BaseResponse, new()
+ protected CommonResponse DeserializeResponse(string? responseContent, Type responseType)
+ where TProduct : BaseProduct, new()
{
Logger?.LogInformation("Parsing HTTP 2xx response ...");
@@ -109,9 +91,9 @@ protected TResponse DeserializeResponse(string? responseContent)
{
throw new MindeeException("Empty response from server.");
}
- var deserializedResult = JsonSerializer.Deserialize(responseContent);
+ var deserializedResult = JsonSerializer.Deserialize(responseContent, responseType);
- if (deserializedResult is BaseResponse model)
+ if (deserializedResult is CommonResponse model)
{
model.RawResponse = responseContent;
return (TResponse)model;
diff --git a/src/Mindee/V2/Http/MindeeApiV2.cs b/src/Mindee/V2/Http/MindeeApiV2.cs
index 6db263d59..f7fd6cc44 100644
--- a/src/Mindee/V2/Http/MindeeApiV2.cs
+++ b/src/Mindee/V2/Http/MindeeApiV2.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@@ -10,7 +9,6 @@
using Mindee.Input;
using Mindee.V2.ClientOptions;
using Mindee.V2.Parsing;
-using Mindee.V2.Parsing.Search;
using Mindee.V2.Product;
using Mindee.V2.Product.Extraction.Params;
using RestSharp;
@@ -64,40 +62,10 @@ BaseParameters parameters
return HandleJobResponse(response);
}
- public override async Task SearchModels(string name, string modelType)
- {
- var request = new RestRequest("v2/search/models");
- Logger?.LogInformation("Fetching models...");
- if (!string.IsNullOrWhiteSpace(name))
- {
- Logger?.LogInformation("Models matching name like {Name}", name);
- request.AddParameter("name", name);
- }
-
- if (!string.IsNullOrWhiteSpace(modelType))
- {
- Logger?.LogInformation("Models matching model_type={ModelType}", modelType);
- request.AddParameter("model_type", modelType);
- }
-
- var response = await _httpClient.ExecuteGetAsync(request);
- return handleSearchResponse(response);
- }
-
- public override async Task ReqGetJobAsync(string jobId)
- {
- var request = new RestRequest($"v2/jobs/{jobId}");
- Logger?.LogInformation("HTTP GET to {RequestResource}...", _baseUrl + request.Resource);
- var response = await _httpClient.ExecuteGetAsync(request);
- Logger?.LogDebug("HTTP response: {ResponseContent}", response.Content);
- var handledResponse = HandleJobResponse(response);
- return handledResponse;
- }
-
- public override async Task ReqGetJobFromUrlAsync(string pollingUrl)
+ public override async Task ReqGetJobAsync(string pollingUrl)
{
var request = new RestRequest(new Uri(pollingUrl));
- Logger?.LogInformation("HTTP GET to {RequestResource}...", request.Resource);
+ Logger?.LogInformation("HTTP GET to {RequestResource}...", _baseUrl + request.Resource);
var response = await _httpClient.ExecuteGetAsync(request);
Logger?.LogDebug("HTTP response: {ResponseContent}", response.Content);
var handledResponse = HandleJobResponse(response);
@@ -105,24 +73,14 @@ public override async Task ReqGetJobFromUrlAsync(string pollingUrl)
}
- public override async Task ReqGetResultAsync(string inferenceId)
- {
- var slug = typeof(TResponse).GetCustomAttribute();
- var request = new RestRequest($"v2/products/{slug}/results/{inferenceId}");
- Logger?.LogInformation("HTTP GET to {RequestResource}...", request.Resource);
- var queueResponse = await _httpClient.ExecuteGetAsync(request);
- return HandleProductResponse(queueResponse);
- }
-
- public override async Task ReqGetResultFromUrlAsync(string resultUrl)
+ public override async Task> ReqGetInferenceAsync(string resultUrl)
{
var request = new RestRequest(new Uri(resultUrl));
Logger?.LogInformation("HTTP GET to {RequestResource}...", resultUrl);
var queueResponse = await _httpClient.ExecuteGetAsync(request);
- return HandleProductResponse(queueResponse);
+ return HandleProductResponse(queueResponse);
}
-
private static void AddPredictRequestParameters(InputSource inputSource, BaseParameters parameters, RestRequest request)
{
switch (inputSource)
@@ -230,8 +188,8 @@ private JobResponse HandleJobResponse(RestResponse restResponse)
return model ?? throw new MindeeException("Couldn't deserialize JobResponse.");
}
- private TResponse HandleProductResponse(RestResponse restResponse)
- where TResponse : BaseResponse, new()
+ private CommonResponse HandleProductResponse(RestResponse restResponse)
+ where TProduct : BaseProduct, new()
{
Logger?.LogDebug("HTTP response: {RestResponseContent}", restResponse.Content);
@@ -243,7 +201,9 @@ private TResponse HandleProductResponse(RestResponse restResponse)
GetErrorFromContent((int)restResponse.StatusCode, restResponse.Content));
}
- return DeserializeResponse(restResponse.Content);
+ var responseType = typeof(TProduct).GetProperty("ResponseType")?.GetValue(null) as Type
+ ?? typeof(CommonResponse);
+ return DeserializeResponse(restResponse.Content, responseType);
}
}
diff --git a/src/Mindee/V2/Parsing/BaseResponse.cs b/src/Mindee/V2/Parsing/BaseResponse.cs
index d232c8e23..a9057338e 100644
--- a/src/Mindee/V2/Parsing/BaseResponse.cs
+++ b/src/Mindee/V2/Parsing/BaseResponse.cs
@@ -1,14 +1,16 @@
+using System;
+using Mindee.V2.Product;
+
namespace Mindee.V2.Parsing
{
///
/// Base class for all responses from the V2 API.
///
- public abstract class BaseResponse
+ public abstract class CommonResponse : BaseResponse where TProduct : BaseProduct, new()
{
///
- /// The raw server response.
- /// This is not formatted in any way by the library and may contain newline and tab characters.
+ /// Type of product returned by this response
///
- public string RawResponse { get; set; }
+ public static Type ReturnType => typeof(TProduct);
}
}
diff --git a/src/Mindee/V2/Parsing/Inference/BaseInference.cs b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
index a27dc9701..ef522f59c 100644
--- a/src/Mindee/V2/Parsing/Inference/BaseInference.cs
+++ b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
@@ -1,14 +1,15 @@
using System;
using System.Text;
using System.Text.Json.Serialization;
-using Mindee.Parsing;
+using Mindee.V1.Parsing;
+using Mindee.V2.Parsing;
-namespace Mindee.V2.Parsing.Inference
+namespace Mindee.V2.Product.Extraction
{
///
- /// Base for all inference-based V2 products.
+ /// ExtractionInference object for the V2 API.
///
- public abstract class BaseInference
+ public class ExtractionInference
{
///
diff --git a/src/Mindee/V2/Parsing/LocalResponse.cs b/src/Mindee/V2/Parsing/LocalResponse.cs
index fde34ca66..77c303593 100644
--- a/src/Mindee/V2/Parsing/LocalResponse.cs
+++ b/src/Mindee/V2/Parsing/LocalResponse.cs
@@ -25,8 +25,9 @@ public LocalResponse(FileInfo input) : base(input)
/// Typically used when wanting to load a V2 webhook callback.
///
///
- public TResponse DeserializeResponse()
- where TResponse : BaseResponse, new()
+ public TResponse DeserializeResponse()
+ where TProduct : BaseProduct, new()
+ where TResponse : CommonResponse, new()
{
var model = JsonSerializer.Deserialize(FileBytes);
diff --git a/src/Mindee/V2/Product/BaseProduct.cs b/src/Mindee/V2/Product/BaseProduct.cs
new file mode 100644
index 000000000..c11777378
--- /dev/null
+++ b/src/Mindee/V2/Product/BaseProduct.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace Mindee.V2.Product
+{
+ ///
+ /// Base class for all V2 products.
+ ///
+ public abstract class BaseProduct
+ {
+ ///
+ /// Type of the product's response.
+ ///
+ public static Type ResponseType;
+
+ ///
+ /// Retrieves the parameters class for the product.
+ ///
+ public static Type ParametersType;
+
+ ///
+ /// Retrieves the slug of the product.
+ ///
+ public static string Slug;
+ }
+}
diff --git a/src/Mindee/V2/Product/Extraction/Extraction.cs b/src/Mindee/V2/Product/Extraction/Extraction.cs
new file mode 100644
index 000000000..1aeb1858c
--- /dev/null
+++ b/src/Mindee/V2/Product/Extraction/Extraction.cs
@@ -0,0 +1,26 @@
+using System;
+using Mindee.V2.Product.Extraction.Params;
+
+namespace Mindee.V2.Product.Extraction
+{
+ ///
+ /// Automatically extract structured data from any image or scanned document.
+ ///
+ public class Extraction : BaseProduct
+ {
+ ///
+ /// Type of the product's response.
+ ///
+ public static new Type ResponseType => typeof(ExtractionResponse);
+
+ ///
+ /// Retrieves the parameters class for the product.
+ ///
+ public static new Type ParametersType => typeof(ExtractionParameters);
+
+ ///
+ /// Retrieves the slug of the product.
+ ///
+ public static new string Slug => "extraction";
+ }
+}
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
index 4d1caa290..2982f3550 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
@@ -4,10 +4,9 @@
namespace Mindee.V2.Product.Extraction
{
///
- /// Response for an extraction inference.
+ /// Represent an extraction response from Mindee V2 API.
///
- [ProductSlug("extraction")]
- public class ExtractionResponse : BaseResponse
+ public class ExtractionResponse : CommonResponse
{
///
/// Contents of the inference.
diff --git a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
index d6d80deed..38916e9f8 100644
--- a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
+++ b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
@@ -8,7 +8,7 @@
namespace Mindee.V2.Product.Extraction.Params
{
///
- /// Parameters for an extraction inference.
+ /// ResultOptions to pass when calling methods using the predict API V2.
///
public class ExtractionParameters : BaseParameters
{
@@ -51,7 +51,7 @@ public class ExtractionParameters : BaseParameters
public sealed override string Slug { get; protected set; }
///
- /// Extraction parameters to set when sending a file.
+ /// ExtractionInference parameters to set when sending a file.
///
///
///
diff --git a/tests/Mindee.IntegrationTests/V1/ClientTest.cs b/tests/Mindee.IntegrationTests/V1/ClientTest.cs
index 59a9be2c6..3196d79f8 100644
--- a/tests/Mindee.IntegrationTests/V1/ClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V1/ClientTest.cs
@@ -1,4 +1,3 @@
-using Mindee.ClientOptions;
using Mindee.Exceptions;
using Mindee.Input;
using Mindee.V1;
diff --git a/tests/Mindee.IntegrationTests/V2/ClientTest.cs b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
index b56f1096b..f10dc5ae8 100644
--- a/tests/Mindee.IntegrationTests/V2/ClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
@@ -1,8 +1,7 @@
using Mindee.Exceptions;
using Mindee.Input;
using Mindee.V2;
-using Mindee.V2.Parsing.Inference;
-using Mindee.V2.Product.Extraction;
+using Mindee.V2.Parsing;
using Mindee.V2.Product.Extraction.Params;
namespace Mindee.IntegrationTests.V2
@@ -227,7 +226,7 @@ public async Task NotFound_Job_MustThrowError()
public async Task NotFound_Inference_MustThrowError()
{
var ex = await Assert.ThrowsAsync(() =>
- _client.GetJobAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
+ _client.GetResultAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
Assert.Equal(404, ex.Status);
Assert.StartsWith("404-", ex.Code);
}
@@ -241,7 +240,7 @@ public async Task Url_InputSource_MustNotRaiseErrors()
var inputSource = new UrlInputSource(new Uri(url));
var inferenceParams = new ExtractionParameters(_findocModelId);
- var response = await _client.EnqueueAndGetResultAsync(inputSource, inferenceParams);
+ var response = await _client.EnqueueAndGetInferenceAsync(inputSource, inferenceParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.UnitTests/V1/ClientTest.cs b/tests/Mindee.UnitTests/V1/ClientTest.cs
index f21bea1a4..385d4f53a 100644
--- a/tests/Mindee.UnitTests/V1/ClientTest.cs
+++ b/tests/Mindee.UnitTests/V1/ClientTest.cs
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging.Abstractions;
using Mindee.Input;
-using Mindee.Parsing;
using Mindee.Pdf;
using Mindee.V1;
using Mindee.V1.Http;
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
index 20c7d358f..d0064fc5b 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
@@ -9,7 +9,7 @@ public class FullTextOcrTest
{
private static readonly JsonSerializerOptions JsonOptions = new() { PropertyNameCaseInsensitive = true };
- private Inference LoadInference()
+ private ExtractionInference LoadInference()
{
var json = File.ReadAllText(Constants.V1RootDir + "extras/full_text_ocr/complete.json");
var prediction = JsonSerializer.Deserialize>(json, JsonOptions);
diff --git a/tests/Mindee.UnitTests/V2/ClientTest.cs b/tests/Mindee.UnitTests/V2/ClientTest.cs
index c5a3c40ec..39c6b88b2 100644
--- a/tests/Mindee.UnitTests/V2/ClientTest.cs
+++ b/tests/Mindee.UnitTests/V2/ClientTest.cs
@@ -1,5 +1,4 @@
using Mindee.Input;
-using Mindee.Parsing;
using Mindee.V2;
using Mindee.V2.Http;
using Mindee.V2.Parsing;
@@ -18,7 +17,7 @@ private Client MakeCustomMindeeClientV2(Mock predictable)
predictable.Setup(x => x.ReqPostEnqueueAsync(It.IsAny(), It.IsAny())
).ReturnsAsync(new JobResponse());
- predictable.Setup(x => x.ReqGetResultAsync(It.IsAny())
+ predictable.Setup(x => x.ReqGetInferenceAsync(It.IsAny())
).ReturnsAsync(new ExtractionResponse());
predictable.Setup(x => x.ReqGetJobAsync(It.IsAny())
@@ -52,11 +51,11 @@ public async Task Document_GetInference_Async()
{
var predictable = new Mock();
var mindeeClient = MakeCustomMindeeClientV2(predictable);
- var response = await mindeeClient.GetResultAsync("dummy-id");
+ var response = await mindeeClient.GetResultAsync("dummy-id");
Assert.NotNull(response);
predictable.Verify(
- p => p.ReqGetResultAsync(It.IsAny()),
+ p => p.ReqGetInferenceAsync(It.IsAny()),
Times.AtMostOnce());
}
@@ -78,7 +77,7 @@ public void Inference_LoadsLocally()
{
var localResponse = new LocalResponse(
new FileInfo(Constants.V2RootDir + "products/extraction/financial_document/complete.json"));
- ExtractionResponse locallyLoadedResponse = localResponse.DeserializeResponse();
+ ExtractionResponse locallyLoadedResponse = localResponse.DeserializeResponse();
Assert.NotNull(locallyLoadedResponse);
Assert.Equal("12345678-1234-1234-1234-123456789abc", locallyLoadedResponse.Inference.Model.Id);
Assert.Equal("John Smith",
diff --git a/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs b/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
index 1de635b28..1c1ce67ea 100644
--- a/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
+++ b/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
@@ -22,9 +22,9 @@ private static void AssertLocalResponse(LocalResponse localResponse)
Assert.Equal(signature, localResponse.GetHmacSignature(secretKey));
Assert.True(localResponse.IsValidHmacSignature(
secretKey, signature));
- ExtractionResponse extractionResponse = localResponse.DeserializeResponse();
- Assert.NotNull(extractionResponse);
- Assert.NotNull(extractionResponse.Inference);
+ ExtractionResponse inferenceResponse = localResponse.DeserializeResponse();
+ Assert.NotNull(inferenceResponse);
+ Assert.NotNull(inferenceResponse.Inference);
}
[Fact]
diff --git a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
index 0dd5b31b8..0b35c7c56 100644
--- a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
@@ -7,7 +7,7 @@ namespace Mindee.UnitTests.V2.Product
{
[Trait("Category", "V2")]
[Trait("Category", "ExtractionInference")]
- public class ExtractionTest
+ public class ExtractionInferenceTest
{
[Fact]
public void FinancialDocument_WhenEmpty_MustHaveValidProperties()
@@ -382,8 +382,8 @@ private static string NormalizeLineEndings(string input)
private static ExtractionResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2ProductDir + path));
- return localResponse.DeserializeResponse();
+ File.ReadAllText(Constants.V2RootDir + path));
+ return localResponse.DeserializeResponse();
}
private void AssertInferenceResponse(ExtractionResponse response)
From 9cc2f078bb576da140c90ad0059637f79a2fce83 Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Mon, 23 Feb 2026 17:41:38 +0100
Subject: [PATCH 03/33] :sparkles: add crop & job info for products
---
.../V2/Parsing/Inference/BaseInference.cs | 14 ++++---------
src/Mindee/V2/Product/Crop/Crop.cs | 16 +++++++++++++++
src/Mindee/V2/Product/Crop/CropResponse.cs | 3 +--
.../V2/Product/Crop/Params/CropParameters.cs | 4 ++--
.../V2/Product/Extraction/Extraction.cs | 11 ----------
.../V2/Product/Extraction/ExtractionResult.cs | 1 +
.../Extraction/Params/ExtractionParameters.cs | 2 +-
tests/Mindee.UnitTests/V2/Product/CropTest.cs | 20 +++++++++++++------
.../V2/Product/ExtractionTest.cs | 2 +-
9 files changed, 40 insertions(+), 33 deletions(-)
create mode 100644 src/Mindee/V2/Product/Crop/Crop.cs
diff --git a/src/Mindee/V2/Parsing/Inference/BaseInference.cs b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
index ef522f59c..6472a13fc 100644
--- a/src/Mindee/V2/Parsing/Inference/BaseInference.cs
+++ b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
@@ -1,15 +1,14 @@
-using System;
using System.Text;
using System.Text.Json.Serialization;
+using Mindee.Parsing;
using Mindee.V1.Parsing;
-using Mindee.V2.Parsing;
-namespace Mindee.V2.Product.Extraction
+namespace Mindee.V2.Parsing
{
///
- /// ExtractionInference object for the V2 API.
+ /// Base for all inference-based V2 products.
///
- public class ExtractionInference
+ public abstract class BaseInference
{
///
@@ -36,11 +35,6 @@ public class ExtractionInference
[JsonPropertyName("job")]
public InferenceJob Job { get; set; }
- ///
- /// Type of the product's response.
- ///
- public virtual Type ResponseType { get; set; }
-
///
///
///
diff --git a/src/Mindee/V2/Product/Crop/Crop.cs b/src/Mindee/V2/Product/Crop/Crop.cs
new file mode 100644
index 000000000..c80878235
--- /dev/null
+++ b/src/Mindee/V2/Product/Crop/Crop.cs
@@ -0,0 +1,16 @@
+using System;
+using Mindee.V2.Product.Crop;
+
+namespace Mindee.V2.Product.Crop
+{
+ ///
+ /// Send a file to the asynchronous processing queue for a crop utility inference.
+ ///
+ public class Crop : BaseProduct
+ {
+ ///
+ /// Type of the product's response.
+ ///
+ public static new Type ResponseType => typeof(CropResponse);
+ }
+}
diff --git a/src/Mindee/V2/Product/Crop/CropResponse.cs b/src/Mindee/V2/Product/Crop/CropResponse.cs
index 4f422efa7..f9221156a 100644
--- a/src/Mindee/V2/Product/Crop/CropResponse.cs
+++ b/src/Mindee/V2/Product/Crop/CropResponse.cs
@@ -6,8 +6,7 @@ namespace Mindee.V2.Product.Crop
///
/// Represent a crop response from Mindee V2 API.
///
- [ProductSlug("crop")]
- public class CropResponse : BaseResponse
+ public class CropResponse : CommonResponse
{
///
/// Contents of the inference.
diff --git a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
index a48d3c412..8f63a8e4e 100644
--- a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
+++ b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
@@ -9,7 +9,7 @@ namespace Mindee.V2.Product.Crop.Params
public class CropParameters : BaseParameters
{
///
- /// Slug for the crop product.
+ /// Slug for the extraction product.
///
public sealed override string Slug { get; protected set; }
@@ -22,7 +22,7 @@ public class CropParameters : BaseParameters
///
public CropParameters(
string modelId,
- string alias = null,
+ string alias,
List webhookIds = null,
PollingOptions pollingOptions = null) : base(modelId, alias, webhookIds, pollingOptions)
{
diff --git a/src/Mindee/V2/Product/Extraction/Extraction.cs b/src/Mindee/V2/Product/Extraction/Extraction.cs
index 1aeb1858c..27d08a03a 100644
--- a/src/Mindee/V2/Product/Extraction/Extraction.cs
+++ b/src/Mindee/V2/Product/Extraction/Extraction.cs
@@ -1,5 +1,4 @@
using System;
-using Mindee.V2.Product.Extraction.Params;
namespace Mindee.V2.Product.Extraction
{
@@ -12,15 +11,5 @@ public class Extraction : BaseProduct
/// Type of the product's response.
///
public static new Type ResponseType => typeof(ExtractionResponse);
-
- ///
- /// Retrieves the parameters class for the product.
- ///
- public static new Type ParametersType => typeof(ExtractionParameters);
-
- ///
- /// Retrieves the slug of the product.
- ///
- public static new string Slug => "extraction";
}
}
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionResult.cs b/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
index 032a36cc4..003278d5f 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
@@ -1,6 +1,7 @@
using System.Text;
using System.Text.Json.Serialization;
using Mindee.Parsing;
+using Mindee.V1.Parsing;
using Mindee.V2.Parsing;
using Mindee.V2.Parsing.Inference;
using Mindee.V2.Parsing.Inference.Field;
diff --git a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
index 38916e9f8..fa8ff70c0 100644
--- a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
+++ b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
@@ -51,7 +51,7 @@ public class ExtractionParameters : BaseParameters
public sealed override string Slug { get; protected set; }
///
- /// ExtractionInference parameters to set when sending a file.
+ /// Extraction parameters to set when sending a file.
///
///
///
diff --git a/tests/Mindee.UnitTests/V2/Product/CropTest.cs b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
index fada340a2..e0aedb751 100644
--- a/tests/Mindee.UnitTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
@@ -11,19 +11,22 @@ public class CropTest
[Fact]
public void Crop_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("crop/crop_single.json");
+ var response = GetInference("products/crop/crop_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
+ // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
Assert.Equal("12345678-1234-1234-1234-jobid1234567", inference.Job.Id);
+ // Validate file metadata
Assert.Equal("sample.jpeg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
+ // Validate crops
var crops = inference.Result.Crops;
Assert.NotNull(crops);
Assert.Single(crops);
@@ -43,7 +46,7 @@ public void Crop_WhenSingle_MustHaveValidProperties()
[Fact]
public void Crop_WhenMultiple_MustHaveValidProperties()
{
- var response = GetInference("crop/crop_multiple.json");
+ var response = GetInference("products/crop/crop_multiple.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -51,9 +54,11 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
var job = inference.Job;
Assert.Equal("12345678-1234-1234-1234-jobid1234567", job.Id);
+ // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
+ // Validate file metadata
Assert.Equal("default_sample.jpg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
@@ -62,6 +67,7 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
Assert.NotNull(crops);
Assert.Equal(2, crops.Count);
+ // Validate first crop item
var firstCrop = crops[0];
Assert.Equal("invoice", firstCrop.ObjectType);
Assert.Equal(0, firstCrop.Location.Page);
@@ -73,6 +79,7 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
Assert.Equal(new Point(0.476, 0.979), firstPolygon[2]);
Assert.Equal(new Point(0.214, 0.979), firstPolygon[3]);
+ // Validate second crop item
var secondCrop = crops[1];
Assert.Equal("invoice", secondCrop.ObjectType);
Assert.Equal(0, secondCrop.Location.Page);
@@ -88,9 +95,10 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
[Fact(DisplayName = "crop_single.rst – RST display must be parsed and exposed")]
public void RstDisplay_MustBeAccessible()
{
- var resp = GetInference("crop/crop_single.json");
+ // Arrange
+ var resp = GetInference("products/crop/crop_single.json");
var rstReference = File.ReadAllText(
- Constants.V2ProductDir + "crop/crop_single.rst");
+ Constants.V2RootDir + "products/crop/crop_single.rst");
var inf = resp.Inference;
@@ -114,8 +122,8 @@ private static string NormalizeLineEndings(string input)
private static CropResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2ProductDir + path));
- return localResponse.DeserializeResponse();
+ File.ReadAllText(Constants.V2RootDir + path));
+ return localResponse.DeserializeResponse();
}
private void AssertInferenceResponse(CropResponse response)
diff --git a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
index 0b35c7c56..139274064 100644
--- a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
@@ -7,7 +7,7 @@ namespace Mindee.UnitTests.V2.Product
{
[Trait("Category", "V2")]
[Trait("Category", "ExtractionInference")]
- public class ExtractionInferenceTest
+ public class ExtractionTest
{
[Fact]
public void FinancialDocument_WhenEmpty_MustHaveValidProperties()
From dcdbc9d07b272580477abc3d4f13d7fff017f725 Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Mon, 23 Feb 2026 19:00:45 +0100
Subject: [PATCH 04/33] :recycle: completely rehaul system to preserve types
---
src/Mindee.Cli/Commands/V1/PredictCommand.cs | 2 +-
.../{ExtractionInference.cs => Inference.cs} | 2 +-
.../Product/BarcodeReader/BarcodeReaderV1.cs | 2 +-
src/Mindee/V1/Product/Cropper/CropperV1.cs | 2 +-
.../FinancialDocument/FinancialDocumentV1.cs | 2 +-
.../BankAccountDetailsV1.cs | 2 +-
.../BankAccountDetailsV2.cs | 2 +-
.../V1/Product/Fr/CarteGrise/CarteGriseV1.cs | 2 +-
.../V1/Product/Fr/HealthCard/HealthCardV1.cs | 2 +-
src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs | 2 +-
src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs | 2 +-
src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs | 2 +-
.../V1/Product/Generated/GeneratedV1.cs | 2 +-
.../InternationalId/InternationalIdV2.cs | 2 +-
src/Mindee/V1/Product/Invoice/InvoiceV4.cs | 2 +-
.../InvoiceSplitter/InvoiceSplitterV1.cs | 2 +-
.../MultiReceiptsDetectorV1.cs | 2 +-
src/Mindee/V1/Product/Passport/PassportV1.cs | 2 +-
src/Mindee/V1/Product/Receipt/ReceiptV4.cs | 2 +-
src/Mindee/V1/Product/Receipt/ReceiptV5.cs | 2 +-
.../V1/Product/Us/BankCheck/BankCheckV1.cs | 2 +-
.../PayrollCheckRegisterV1.cs | 2 +-
src/Mindee/V2/Client.cs | 80 +++++++++++++------
src/Mindee/V2/Http/HttpApiV2.cs | 29 ++++---
src/Mindee/V2/Http/MindeeApiV2.cs | 38 ++++++---
.../V2/Parsing/Inference/BaseInference.cs | 7 +-
src/Mindee/V2/Parsing/LocalResponse.cs | 5 +-
src/Mindee/V2/Product/BaseProduct.cs | 25 ------
src/Mindee/V2/Product/Crop/Crop.cs | 16 ----
src/Mindee/V2/Product/Crop/CropInference.cs | 6 ++
src/Mindee/V2/Product/Crop/CropResponse.cs | 3 +-
.../V2/Product/Crop/Params/CropParameters.cs | 2 +-
.../V2/Product/Extraction/Extraction.cs | 15 ----
.../Product/Extraction/ExtractionInference.cs | 5 ++
.../Product/Extraction/ExtractionResponse.cs | 3 +-
.../Mindee.IntegrationTests/V2/ClientTest.cs | 3 +-
.../V2/Product/CropTest.cs | 14 ++--
.../V2/Product/ExtractionTest.cs | 39 ---------
.../V1/Parsing/Common/FullTextOcrTest.cs | 2 +-
tests/Mindee.UnitTests/V2/ClientTest.cs | 8 +-
.../V2/Input/LocalResponseTest.cs | 2 +-
tests/Mindee.UnitTests/V2/Product/CropTest.cs | 2 +-
.../V2/Product/ExtractionTest.cs | 2 +-
43 files changed, 165 insertions(+), 185 deletions(-)
rename src/Mindee/V1/Parsing/Common/{ExtractionInference.cs => Inference.cs} (97%)
delete mode 100644 src/Mindee/V2/Product/BaseProduct.cs
delete mode 100644 src/Mindee/V2/Product/Crop/Crop.cs
delete mode 100644 src/Mindee/V2/Product/Extraction/Extraction.cs
diff --git a/src/Mindee.Cli/Commands/V1/PredictCommand.cs b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
index 46b010b4b..790b5831a 100644
--- a/src/Mindee.Cli/Commands/V1/PredictCommand.cs
+++ b/src/Mindee.Cli/Commands/V1/PredictCommand.cs
@@ -30,7 +30,7 @@ internal struct ParseOptions(string path, bool allWords, bool fullText, OutputTy
class PredictCommand : Command
where TDoc : IPrediction, new()
where TPage : IPrediction, new()
- where TInferenceModel : ExtractionInference, new()
+ where TInferenceModel : Inference, new()
{
private readonly Option _outputOption;
private readonly Option? _allWordsOption;
diff --git a/src/Mindee/V1/Parsing/Common/ExtractionInference.cs b/src/Mindee/V1/Parsing/Common/Inference.cs
similarity index 97%
rename from src/Mindee/V1/Parsing/Common/ExtractionInference.cs
rename to src/Mindee/V1/Parsing/Common/Inference.cs
index 4f20632d2..0216e8cd6 100644
--- a/src/Mindee/V1/Parsing/Common/ExtractionInference.cs
+++ b/src/Mindee/V1/Parsing/Common/Inference.cs
@@ -10,7 +10,7 @@ namespace Mindee.V1.Parsing.Common
///
/// Page prediction (could be the same that TDocumentPrediction).
/// Document prediction (could be the same that TPagePrediction).
- public abstract class ExtractionInference
+ public abstract class Inference
where TPagePrediction : IPrediction, new()
where TDocumentPrediction : IPrediction, new()
{
diff --git a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
index 23621e7ad..cc306a0b0 100644
--- a/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
+++ b/src/Mindee/V1/Product/BarcodeReader/BarcodeReaderV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.BarcodeReader
/// Barcode Reader API version 1 inference prediction.
///
[Endpoint("barcode_reader", "1")]
- public sealed class BarcodeReaderV1 : ExtractionInference
+ public sealed class BarcodeReaderV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Cropper/CropperV1.cs b/src/Mindee/V1/Product/Cropper/CropperV1.cs
index a8e4bb222..6784b9929 100644
--- a/src/Mindee/V1/Product/Cropper/CropperV1.cs
+++ b/src/Mindee/V1/Product/Cropper/CropperV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Cropper
/// Cropper API version 1 inference prediction.
///
[Endpoint("cropper", "1")]
- public sealed class CropperV1 : ExtractionInference
+ public sealed class CropperV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs b/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
index be290470b..55c9739e2 100644
--- a/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
+++ b/src/Mindee/V1/Product/FinancialDocument/FinancialDocumentV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.FinancialDocument
/// Financial Document API version 1 inference prediction.
///
[Endpoint("financial_document", "1")]
- public sealed class FinancialDocumentV1 : ExtractionInference
+ public sealed class FinancialDocumentV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
index 4d923bebf..fc8f4f836 100644
--- a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
+++ b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.BankAccountDetails
/// Bank Account Details API version 1 inference prediction.
///
[Endpoint("bank_account_details", "1")]
- public sealed class BankAccountDetailsV1 : ExtractionInference
+ public sealed class BankAccountDetailsV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
index 66cefe3c8..f3af6459d 100644
--- a/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
+++ b/src/Mindee/V1/Product/Fr/BankAccountDetails/BankAccountDetailsV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.BankAccountDetails
/// Bank Account Details API version 2 inference prediction.
///
[Endpoint("bank_account_details", "2")]
- public sealed class BankAccountDetailsV2 : ExtractionInference
+ public sealed class BankAccountDetailsV2 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs b/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
index 9539ee0d1..9f210fc60 100644
--- a/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
+++ b/src/Mindee/V1/Product/Fr/CarteGrise/CarteGriseV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.CarteGrise
/// Carte Grise API version 1 inference prediction.
///
[Endpoint("carte_grise", "1")]
- public sealed class CarteGriseV1 : ExtractionInference
+ public sealed class CarteGriseV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs b/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
index dd01c8e5f..563d12418 100644
--- a/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
+++ b/src/Mindee/V1/Product/Fr/HealthCard/HealthCardV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.HealthCard
/// Health Card API version 1 inference prediction.
///
[Endpoint("french_healthcard", "1")]
- public sealed class HealthCardV1 : ExtractionInference
+ public sealed class HealthCardV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs b/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
index db3b878a7..c51fb62c6 100644
--- a/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
+++ b/src/Mindee/V1/Product/Fr/IdCard/IdCardV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.IdCard
/// Carte Nationale d'Identité API version 1 inference prediction.
///
[Endpoint("idcard_fr", "1")]
- public sealed class IdCardV1 : ExtractionInference
+ public sealed class IdCardV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs b/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
index 8581605d6..005b812fb 100644
--- a/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
+++ b/src/Mindee/V1/Product/Fr/IdCard/IdCardV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.IdCard
/// Carte Nationale d'Identité API version 2 inference prediction.
///
[Endpoint("idcard_fr", "2")]
- public sealed class IdCardV2 : ExtractionInference
+ public sealed class IdCardV2 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs b/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
index 8f71e6db0..daf742794 100644
--- a/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
+++ b/src/Mindee/V1/Product/Fr/Payslip/PayslipV3.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Fr.Payslip
/// Payslip API version 3 inference prediction.
///
[Endpoint("payslip_fra", "3")]
- public sealed class PayslipV3 : ExtractionInference
+ public sealed class PayslipV3 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Generated/GeneratedV1.cs b/src/Mindee/V1/Product/Generated/GeneratedV1.cs
index 28bfd3514..881228f96 100644
--- a/src/Mindee/V1/Product/Generated/GeneratedV1.cs
+++ b/src/Mindee/V1/Product/Generated/GeneratedV1.cs
@@ -5,7 +5,7 @@ namespace Mindee.V1.Product.Generated
///
/// The definition for Generated Documents, API version 1.
///
- public class GeneratedV1 : ExtractionInference
+ public class GeneratedV1 : Inference
{
}
diff --git a/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs b/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
index b8be8350b..e1dfb44b0 100644
--- a/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
+++ b/src/Mindee/V1/Product/InternationalId/InternationalIdV2.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.InternationalId
/// International ID API version 2 inference prediction.
///
[Endpoint("international_id", "2")]
- public sealed class InternationalIdV2 : ExtractionInference
+ public sealed class InternationalIdV2 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Invoice/InvoiceV4.cs b/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
index 9e5601325..5a7d009be 100644
--- a/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
+++ b/src/Mindee/V1/Product/Invoice/InvoiceV4.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Invoice
/// Invoice API version 4 inference prediction.
///
[Endpoint("invoices", "4")]
- public sealed class InvoiceV4 : ExtractionInference
+ public sealed class InvoiceV4 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs b/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
index 35e334a63..f1c200613 100644
--- a/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
+++ b/src/Mindee/V1/Product/InvoiceSplitter/InvoiceSplitterV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.InvoiceSplitter
/// Invoice Splitter API version 1 inference prediction.
///
[Endpoint("invoice_splitter", "1")]
- public sealed class InvoiceSplitterV1 : ExtractionInference
+ public sealed class InvoiceSplitterV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs b/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
index 1ef706889..f54d5168b 100644
--- a/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
+++ b/src/Mindee/V1/Product/MultiReceiptsDetector/MultiReceiptsDetectorV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.MultiReceiptsDetector
/// Multi Receipts Detector API version 1 inference prediction.
///
[Endpoint("multi_receipts_detector", "1")]
- public sealed class MultiReceiptsDetectorV1 : ExtractionInference
+ public sealed class MultiReceiptsDetectorV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Passport/PassportV1.cs b/src/Mindee/V1/Product/Passport/PassportV1.cs
index a952ae316..dfcb8031e 100644
--- a/src/Mindee/V1/Product/Passport/PassportV1.cs
+++ b/src/Mindee/V1/Product/Passport/PassportV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Passport
/// Passport API version 1 inference prediction.
///
[Endpoint("passport", "1")]
- public sealed class PassportV1 : ExtractionInference
+ public sealed class PassportV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Receipt/ReceiptV4.cs b/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
index 23b0df32e..9fe7ad7ea 100644
--- a/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
+++ b/src/Mindee/V1/Product/Receipt/ReceiptV4.cs
@@ -7,7 +7,7 @@ namespace Mindee.V1.Product.Receipt
/// The definition for Receipt, API version 4.
///
[Endpoint("expense_receipts", "4")]
- public sealed class ReceiptV4 : ExtractionInference
+ public sealed class ReceiptV4 : Inference
{
}
}
diff --git a/src/Mindee/V1/Product/Receipt/ReceiptV5.cs b/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
index 07504bf93..f5f23e056 100644
--- a/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
+++ b/src/Mindee/V1/Product/Receipt/ReceiptV5.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Receipt
/// Receipt API version 5 inference prediction.
///
[Endpoint("expense_receipts", "5")]
- public sealed class ReceiptV5 : ExtractionInference
+ public sealed class ReceiptV5 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
index d509bfe38..e83b95fbb 100644
--- a/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
+++ b/src/Mindee/V1/Product/Us/BankCheck/BankCheckV1.cs
@@ -8,7 +8,7 @@ namespace Mindee.V1.Product.Us.BankCheck
/// Bank Check API version 1 inference prediction.
///
[Endpoint("bank_check", "1")]
- public sealed class BankCheckV1 : ExtractionInference
+ public sealed class BankCheckV1 : Inference
{
///
/// The pages and the associated values which were detected on the document.
diff --git a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
index 0d58f5fe8..a2ce54b31 100644
--- a/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
+++ b/src/Mindee/V1/Product/Us/PayrollCheckRegister/PayrollCheckRegisterV1.cs
@@ -7,7 +7,7 @@ namespace Mindee.V1.Product.Us.PayrollCheckRegister
/// The definition for Payroll Check Register, API version 1.
///
[Endpoint("payroll_check_register", "1")]
- public sealed class PayrollCheckRegisterV1 : ExtractionInference
+ public sealed class PayrollCheckRegisterV1 : Inference
{
}
}
diff --git a/src/Mindee/V2/Client.cs b/src/Mindee/V2/Client.cs
index 3c336e50c..f5a3698bc 100644
--- a/src/Mindee/V2/Client.cs
+++ b/src/Mindee/V2/Client.cs
@@ -9,7 +9,6 @@
using Mindee.V2.ClientOptions;
using Mindee.V2.Http;
using Mindee.V2.Parsing;
-using Mindee.V2.Product;
using Mindee.V2.Product.Extraction;
using Mindee.V2.Product.Extraction.Params;
using SettingsV2 = Mindee.V2.Http.Settings;
@@ -95,7 +94,7 @@ public Client(HttpApiV2 httpApi, ILoggerFactory logger = null)
///
///
///
- ///
+ ///
///
///
///
@@ -104,7 +103,7 @@ public Client(HttpApiV2 httpApi, ILoggerFactory logger = null)
///
public async Task EnqueueAsync(
InputSource inputSource
- , ExtractionParameters extractionParameters)
+ , BaseParameters parameters)
{
switch (inputSource)
{
@@ -120,7 +119,7 @@ InputSource inputSource
throw new MindeeInputException($"Unsupported input source {inputSource.GetType().Name}");
}
- return await _mindeeApi.ReqPostEnqueueAsync(inputSource, extractionParameters);
+ return await _mindeeApi.ReqPostEnqueueAsync(inputSource, parameters);
}
///
@@ -131,7 +130,7 @@ InputSource inputSource
///
///
///
- public async Task GetJobAsync(string pollingUrl)
+ public async Task GetJobFromUrlAsync(string pollingUrl)
{
_logger?.LogInformation("Getting Job at: {}", pollingUrl);
@@ -140,7 +139,7 @@ public async Task GetJobAsync(string pollingUrl)
throw new ArgumentNullException(pollingUrl);
}
- return await _mindeeApi.ReqGetJobAsync(pollingUrl);
+ return await _mindeeApi.ReqGetJobFromUrlAsync(pollingUrl);
}
///
@@ -151,8 +150,8 @@ public async Task GetJobAsync(string pollingUrl)
///
///
///
- public async Task> GetResultAsync(string pollingUrl)
- where TProduct : BaseProduct, new()
+ private async Task GetResultFromUrlAsync(string pollingUrl)
+ where TResponse : CommonInferenceResponse, new()
{
_logger?.LogInformation("Polling: {}", pollingUrl);
@@ -160,7 +159,46 @@ public async Task> GetResultAsync(string poll
{
throw new ArgumentNullException(pollingUrl);
}
- return await _mindeeApi.ReqGetInferenceAsync(pollingUrl);
+ return await _mindeeApi.ReqGetResultFromUrlAsync(pollingUrl);
+ }
+
+ ///
+ /// Get the status of an inference that was previously enqueued.
+ /// Can be used for polling.
+ ///
+ /// The job id.
+ ///
+ ///
+ ///
+ public async Task GetResultAsync(string jobId)
+ where TResponse : CommonInferenceResponse, new()
+ {
+ _logger?.LogInformation("Polling: {}", jobId);
+
+ if (string.IsNullOrWhiteSpace(jobId))
+ {
+ throw new ArgumentNullException(jobId);
+ }
+ return await _mindeeApi.ReqGetResultAsync(jobId);
+ }
+
+ ///
+ /// Get the status of an inference that was previously enqueued.
+ /// Can be used for polling.
+ ///
+ /// The job id.
+ ///
+ ///
+ ///
+ public async Task GetJobAsync(string jobId)
+ {
+ _logger?.LogInformation("Getting job {}", jobId);
+
+ if (string.IsNullOrWhiteSpace(jobId))
+ {
+ throw new ArgumentNullException(jobId);
+ }
+ return await _mindeeApi.ReqGetJobAsync(jobId);
}
///
@@ -181,13 +219,7 @@ public async Task EnqueueAndGetInferenceAsync(
InputSource inputSource
, ExtractionParameters extractionParameters)
{
- var response =
- await EnqueueAndGetResultAsync(inputSource, extractionParameters);
- if (response is ExtractionResponse extractionResponse)
- {
- return extractionResponse;
- }
- throw new MindeeException($"Unexpected response type '{response.GetType().Name}'.");
+ return await EnqueueAndGetResultAsync(inputSource, extractionParameters);
}
///
@@ -204,10 +236,10 @@ InputSource inputSource
///
///
///
- public async Task> EnqueueAndGetResultAsync(
+ public async Task EnqueueAndGetResultAsync(
InputSource inputSource
- , ExtractionParameters extractionParameters)
- where TProduct : BaseProduct, new()
+ , BaseParameters extractionParameters)
+ where TResponse : CommonInferenceResponse, new()
{
switch (inputSource)
{
@@ -228,7 +260,7 @@ InputSource inputSource
var enqueueResponse = await EnqueueAsync(
inputSource,
extractionParameters);
- return await PollForResultsAsync(enqueueResponse, extractionParameters.PollingOptions);
+ return await PollForResultsAsync(enqueueResponse, extractionParameters.PollingOptions);
}
///
@@ -253,9 +285,9 @@ public async Task SearchModels(string name = null, string modelT
///
///
/// Thrown when maxRetries is reached and the result isn't ready.
- private async Task> PollForResultsAsync(
+ private async Task PollForResultsAsync(
JobResponse enqueueResponse,
- PollingOptions pollingOptions) where TProduct : BaseProduct, new()
+ PollingOptions pollingOptions) where TResponse : CommonInferenceResponse, new()
{
var maxRetries = pollingOptions.MaxRetries + 1;
var pollingUrl = enqueueResponse.Job.PollingUrl;
@@ -274,7 +306,7 @@ private async Task> PollForResultsAsync(
retryCount,
maxRetries);
- response = await GetJobAsync(pollingUrl);
+ response = await GetJobFromUrlAsync(pollingUrl);
if (response.Job.Error != null)
{
break;
@@ -283,7 +315,7 @@ private async Task> PollForResultsAsync(
if (response.Job.Status.Equals("Processed"))
{
var resultUrl = response.Job.ResultUrl;
- return await GetResultAsync(resultUrl);
+ return await GetResultFromUrlAsync(resultUrl);
}
retryCount++;
diff --git a/src/Mindee/V2/Http/HttpApiV2.cs b/src/Mindee/V2/Http/HttpApiV2.cs
index 663be5259..685a42a17 100644
--- a/src/Mindee/V2/Http/HttpApiV2.cs
+++ b/src/Mindee/V2/Http/HttpApiV2.cs
@@ -1,6 +1,5 @@
#nullable enable
-using System;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@@ -8,7 +7,6 @@
using Mindee.Input;
using Mindee.V2.ClientOptions;
using Mindee.V2.Parsing;
-using Mindee.V2.Product;
namespace Mindee.V2.Http
{
@@ -42,13 +40,25 @@ public abstract class HttpApiV2
/// Get a job for an enqueued document.
///
/// The job ID as returned by the predict_async route.
- public abstract Task ReqGetJobAsync(string pollingUrl);
+ public abstract Task ReqGetJobFromUrlAsync(string pollingUrl);
+
+ ///
+ /// Get a job for an enqueued document.
+ ///
+ /// The job ID as returned by the predict_async route.
+ public abstract Task ReqGetJobAsync(string jobId);
+
+ ///
+ /// Get a document inference.
+ ///
+ /// Url to poll.
+ public abstract Task ReqGetResultAsync(string inferenceId) where TResponse : CommonInferenceResponse, new();
///
/// Get a document inference.
///
/// Url to poll.
- public abstract Task> ReqGetInferenceAsync(string resultUrl) where TProduct : BaseProduct, new();
+ public abstract Task ReqGetResultFromUrlAsync(string resultUrl) where TResponse : CommonInferenceResponse, new();
///
/// Get the error from the server return.
@@ -79,11 +89,10 @@ protected ErrorResponse GetErrorFromContent(int statusCode, string? responseCont
/// Attempt to deserialize a response from the server.
///
///
- ///
- ///
+ ///
///
- protected CommonResponse DeserializeResponse(string? responseContent, Type responseType)
- where TProduct : BaseProduct, new()
+ protected TResponse DeserializeResponse(string? responseContent)
+ where TResponse : CommonInferenceResponse, new()
{
Logger?.LogInformation("Parsing HTTP 2xx response ...");
@@ -91,9 +100,9 @@ protected CommonResponse DeserializeResponse(string? respons
{
throw new MindeeException("Empty response from server.");
}
- var deserializedResult = JsonSerializer.Deserialize(responseContent, responseType);
+ var deserializedResult = JsonSerializer.Deserialize(responseContent);
- if (deserializedResult is CommonResponse model)
+ if (deserializedResult is CommonInferenceResponse model)
{
model.RawResponse = responseContent;
return (TResponse)model;
diff --git a/src/Mindee/V2/Http/MindeeApiV2.cs b/src/Mindee/V2/Http/MindeeApiV2.cs
index f7fd6cc44..d58a1d9e2 100644
--- a/src/Mindee/V2/Http/MindeeApiV2.cs
+++ b/src/Mindee/V2/Http/MindeeApiV2.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@@ -9,7 +10,6 @@
using Mindee.Input;
using Mindee.V2.ClientOptions;
using Mindee.V2.Parsing;
-using Mindee.V2.Product;
using Mindee.V2.Product.Extraction.Params;
using RestSharp;
#if NET6_0_OR_GREATER
@@ -62,9 +62,9 @@ BaseParameters parameters
return HandleJobResponse(response);
}
- public override async Task ReqGetJobAsync(string pollingUrl)
+ public override async Task ReqGetJobAsync(string jobId)
{
- var request = new RestRequest(new Uri(pollingUrl));
+ var request = new RestRequest($"v2/jobs/{jobId}");
Logger?.LogInformation("HTTP GET to {RequestResource}...", _baseUrl + request.Resource);
var response = await _httpClient.ExecuteGetAsync(request);
Logger?.LogDebug("HTTP response: {ResponseContent}", response.Content);
@@ -72,15 +72,35 @@ public override async Task ReqGetJobAsync(string pollingUrl)
return handledResponse;
}
+ public override async Task ReqGetJobFromUrlAsync(string pollingUrl)
+ {
+ var request = new RestRequest(new Uri(pollingUrl));
+ Logger?.LogInformation("HTTP GET to {RequestResource}...", request.Resource);
+ var response = await _httpClient.ExecuteGetAsync(request);
+ Logger?.LogDebug("HTTP response: {ResponseContent}", response.Content);
+ var handledResponse = HandleJobResponse(response);
+ return handledResponse;
+ }
+
- public override async Task> ReqGetInferenceAsync(string resultUrl)
+ public override async Task ReqGetResultAsync(string inferenceId)
+ {
+ var slug = typeof(TResponse).GetCustomAttribute();
+ var request = new RestRequest($"v2/products/{slug}/results/{inferenceId}");
+ Logger?.LogInformation("HTTP GET to {RequestResource}...", request.Resource);
+ var queueResponse = await _httpClient.ExecuteGetAsync(request);
+ return HandleProductResponse(queueResponse);
+ }
+
+ public override async Task ReqGetResultFromUrlAsync(string resultUrl)
{
var request = new RestRequest(new Uri(resultUrl));
Logger?.LogInformation("HTTP GET to {RequestResource}...", resultUrl);
var queueResponse = await _httpClient.ExecuteGetAsync(request);
- return HandleProductResponse(queueResponse);
+ return HandleProductResponse(queueResponse);
}
+
private static void AddPredictRequestParameters(InputSource inputSource, BaseParameters parameters, RestRequest request)
{
switch (inputSource)
@@ -188,8 +208,8 @@ private JobResponse HandleJobResponse(RestResponse restResponse)
return model ?? throw new MindeeException("Couldn't deserialize JobResponse.");
}
- private CommonResponse HandleProductResponse(RestResponse restResponse)
- where TProduct : BaseProduct, new()
+ private TResponse HandleProductResponse(RestResponse restResponse)
+ where TResponse : CommonInferenceResponse, new()
{
Logger?.LogDebug("HTTP response: {RestResponseContent}", restResponse.Content);
@@ -201,9 +221,7 @@ private CommonResponse HandleProductResponse(RestResponse re
GetErrorFromContent((int)restResponse.StatusCode, restResponse.Content));
}
- var responseType = typeof(TProduct).GetProperty("ResponseType")?.GetValue(null) as Type
- ?? typeof(CommonResponse);
- return DeserializeResponse(restResponse.Content, responseType);
+ return DeserializeResponse(restResponse.Content);
}
}
diff --git a/src/Mindee/V2/Parsing/Inference/BaseInference.cs b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
index 6472a13fc..52f1155f0 100644
--- a/src/Mindee/V2/Parsing/Inference/BaseInference.cs
+++ b/src/Mindee/V2/Parsing/Inference/BaseInference.cs
@@ -1,7 +1,7 @@
+using System;
using System.Text;
using System.Text.Json.Serialization;
using Mindee.Parsing;
-using Mindee.V1.Parsing;
namespace Mindee.V2.Parsing
{
@@ -35,6 +35,11 @@ public abstract class BaseInference
[JsonPropertyName("job")]
public InferenceJob Job { get; set; }
+ ///
+ /// Type of the product's response.
+ ///
+ public virtual Type ResponseType { get; set; }
+
///
///
///
diff --git a/src/Mindee/V2/Parsing/LocalResponse.cs b/src/Mindee/V2/Parsing/LocalResponse.cs
index 77c303593..b0071cf10 100644
--- a/src/Mindee/V2/Parsing/LocalResponse.cs
+++ b/src/Mindee/V2/Parsing/LocalResponse.cs
@@ -25,9 +25,8 @@ public LocalResponse(FileInfo input) : base(input)
/// Typically used when wanting to load a V2 webhook callback.
///
///
- public TResponse DeserializeResponse()
- where TProduct : BaseProduct, new()
- where TResponse : CommonResponse, new()
+ public TResponse DeserializeResponse()
+ where TResponse : CommonInferenceResponse, new()
{
var model = JsonSerializer.Deserialize(FileBytes);
diff --git a/src/Mindee/V2/Product/BaseProduct.cs b/src/Mindee/V2/Product/BaseProduct.cs
deleted file mode 100644
index c11777378..000000000
--- a/src/Mindee/V2/Product/BaseProduct.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-
-namespace Mindee.V2.Product
-{
- ///
- /// Base class for all V2 products.
- ///
- public abstract class BaseProduct
- {
- ///
- /// Type of the product's response.
- ///
- public static Type ResponseType;
-
- ///
- /// Retrieves the parameters class for the product.
- ///
- public static Type ParametersType;
-
- ///
- /// Retrieves the slug of the product.
- ///
- public static string Slug;
- }
-}
diff --git a/src/Mindee/V2/Product/Crop/Crop.cs b/src/Mindee/V2/Product/Crop/Crop.cs
deleted file mode 100644
index c80878235..000000000
--- a/src/Mindee/V2/Product/Crop/Crop.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using Mindee.V2.Product.Crop;
-
-namespace Mindee.V2.Product.Crop
-{
- ///
- /// Send a file to the asynchronous processing queue for a crop utility inference.
- ///
- public class Crop : BaseProduct
- {
- ///
- /// Type of the product's response.
- ///
- public static new Type ResponseType => typeof(CropResponse);
- }
-}
diff --git a/src/Mindee/V2/Product/Crop/CropInference.cs b/src/Mindee/V2/Product/Crop/CropInference.cs
index b9543c2bf..468242f27 100644
--- a/src/Mindee/V2/Product/Crop/CropInference.cs
+++ b/src/Mindee/V2/Product/Crop/CropInference.cs
@@ -1,3 +1,4 @@
+using System;
using System.Text.Json.Serialization;
using Mindee.V2.Parsing.Inference;
@@ -14,6 +15,11 @@ public class CropInference : BaseInference
[JsonPropertyName("result")]
public CropResult Result { get; set; }
+ ///
+ /// Type of the product's response.
+ ///
+ public static new Type ResponseType => typeof(CropResponse);
+
///
/// String representation of the crop inference.
///
diff --git a/src/Mindee/V2/Product/Crop/CropResponse.cs b/src/Mindee/V2/Product/Crop/CropResponse.cs
index f9221156a..ef4ccf76d 100644
--- a/src/Mindee/V2/Product/Crop/CropResponse.cs
+++ b/src/Mindee/V2/Product/Crop/CropResponse.cs
@@ -6,7 +6,8 @@ namespace Mindee.V2.Product.Crop
///
/// Represent a crop response from Mindee V2 API.
///
- public class CropResponse : CommonResponse
+ [EndpointSlug("crop")]
+ public class CropResponse : CommonInferenceResponse
{
///
/// Contents of the inference.
diff --git a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
index 8f63a8e4e..93df7fad8 100644
--- a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
+++ b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
@@ -22,7 +22,7 @@ public class CropParameters : BaseParameters
///
public CropParameters(
string modelId,
- string alias,
+ string alias = null,
List webhookIds = null,
PollingOptions pollingOptions = null) : base(modelId, alias, webhookIds, pollingOptions)
{
diff --git a/src/Mindee/V2/Product/Extraction/Extraction.cs b/src/Mindee/V2/Product/Extraction/Extraction.cs
deleted file mode 100644
index 27d08a03a..000000000
--- a/src/Mindee/V2/Product/Extraction/Extraction.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace Mindee.V2.Product.Extraction
-{
- ///
- /// Automatically extract structured data from any image or scanned document.
- ///
- public class Extraction : BaseProduct
- {
- ///
- /// Type of the product's response.
- ///
- public static new Type ResponseType => typeof(ExtractionResponse);
- }
-}
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionInference.cs b/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
index 1cb1b4a58..a0522d5ad 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
@@ -24,6 +24,11 @@ public sealed class ExtractionInference : BaseInference
[JsonPropertyName("result")]
public ExtractionResult Result { get; set; }
+ ///
+ /// Type of the product's response.
+ ///
+ public static new Type ResponseType => typeof(ExtractionResponse);
+
///
/// A prettier representation.
///
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
index 2982f3550..6c1e86444 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
@@ -6,7 +6,8 @@ namespace Mindee.V2.Product.Extraction
///
/// Represent an extraction response from Mindee V2 API.
///
- public class ExtractionResponse : CommonResponse
+ [EndpointSlug("extraction")]
+ public class ExtractionResponse : CommonInferenceResponse
{
///
/// Contents of the inference.
diff --git a/tests/Mindee.IntegrationTests/V2/ClientTest.cs b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
index f10dc5ae8..e18221735 100644
--- a/tests/Mindee.IntegrationTests/V2/ClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
@@ -2,6 +2,7 @@
using Mindee.Input;
using Mindee.V2;
using Mindee.V2.Parsing;
+using Mindee.V2.Product.Extraction;
using Mindee.V2.Product.Extraction.Params;
namespace Mindee.IntegrationTests.V2
@@ -226,7 +227,7 @@ public async Task NotFound_Job_MustThrowError()
public async Task NotFound_Inference_MustThrowError()
{
var ex = await Assert.ThrowsAsync(() =>
- _client.GetResultAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
+ _client.GetResultAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
Assert.Equal(404, ex.Status);
Assert.StartsWith("404-", ex.Code);
}
diff --git a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
index 3de43974f..54497c9e2 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
@@ -22,12 +22,14 @@ public CropTest()
[Fact(Timeout = 180000)]
public async Task Crop_DefaultSample_MustSucceed()
{
+ // Arrange
var inputSource = new LocalInputSource(
- Constants.V2ProductDir + "crop/default_sample.jpg");
- var productParams = new CropParameters(_cropModelId);
+ Constants.V2RootDir + "products/crop/default_sample.jpg");
+ var cropParameters = new CropParameters(_cropModelId);
+
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, productParams);
+ inputSource, cropParameters);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
@@ -40,12 +42,8 @@ public async Task Crop_DefaultSample_MustSucceed()
Assert.NotNull(result);
var crops = result.Crops;
+ Assert.NotNull(crops);
Assert.Equal(2, crops.Count);
- foreach (var crop in crops)
- {
- Assert.NotNull(crop.ObjectType);
- Assert.NotNull(crop.Location);
- }
}
}
}
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
index 9c02e6989..93ee70839 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
@@ -1,46 +1,7 @@
-using Mindee.Input;
-using Mindee.V2;
-using Mindee.V2.Product.Extraction;
-using Mindee.V2.Product.Extraction.Params;
-
namespace Mindee.IntegrationTests.V2.Product
{
- [Trait("Category", "V2")]
- [Trait("Category", "Integration")]
public class ExtractionTest
{
- private readonly string? _extractionModelId;
- private readonly Client _client;
-
- public ExtractionTest()
- {
- var apiKey = Environment.GetEnvironmentVariable("MindeeV2__ApiKey");
- _client = TestingUtilities.GetOrGenerateMindeeClientV2(apiKey);
- _extractionModelId = Environment.GetEnvironmentVariable("MindeeV2__Findoc__Model__Id");
- }
-
- [Fact(Timeout = 180000)]
- public async Task Extraction_DefaultSample_MustSucceed()
- {
- var inputSource = new LocalInputSource(
- Constants.V2ProductDir + "extraction/financial_document/default_sample.jpg");
- var productParams = new ExtractionParameters(_extractionModelId);
-
- var response = await _client.EnqueueAndGetResultAsync(
- inputSource, productParams);
-
- Assert.NotNull(response);
- Assert.NotNull(response.Inference);
-
- var file = response.Inference.File;
- Assert.NotNull(file);
- Assert.Equal("default_sample.jpg", file.Name);
-
- var result = response.Inference.Result;
- Assert.NotNull(result);
- var fields = result.Fields;
- Assert.NotNull(fields);
- }
}
}
diff --git a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
index d0064fc5b..20c7d358f 100644
--- a/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
+++ b/tests/Mindee.UnitTests/V1/Parsing/Common/FullTextOcrTest.cs
@@ -9,7 +9,7 @@ public class FullTextOcrTest
{
private static readonly JsonSerializerOptions JsonOptions = new() { PropertyNameCaseInsensitive = true };
- private ExtractionInference LoadInference()
+ private Inference LoadInference()
{
var json = File.ReadAllText(Constants.V1RootDir + "extras/full_text_ocr/complete.json");
var prediction = JsonSerializer.Deserialize>(json, JsonOptions);
diff --git a/tests/Mindee.UnitTests/V2/ClientTest.cs b/tests/Mindee.UnitTests/V2/ClientTest.cs
index 39c6b88b2..2123f5bc6 100644
--- a/tests/Mindee.UnitTests/V2/ClientTest.cs
+++ b/tests/Mindee.UnitTests/V2/ClientTest.cs
@@ -17,7 +17,7 @@ private Client MakeCustomMindeeClientV2(Mock predictable)
predictable.Setup(x => x.ReqPostEnqueueAsync(It.IsAny(), It.IsAny())
).ReturnsAsync(new JobResponse());
- predictable.Setup(x => x.ReqGetInferenceAsync(It.IsAny())
+ predictable.Setup(x => x.ReqGetResultAsync(It.IsAny())
).ReturnsAsync(new ExtractionResponse());
predictable.Setup(x => x.ReqGetJobAsync(It.IsAny())
@@ -51,11 +51,11 @@ public async Task Document_GetInference_Async()
{
var predictable = new Mock();
var mindeeClient = MakeCustomMindeeClientV2(predictable);
- var response = await mindeeClient.GetResultAsync("dummy-id");
+ var response = await mindeeClient.GetResultAsync("dummy-id");
Assert.NotNull(response);
predictable.Verify(
- p => p.ReqGetInferenceAsync(It.IsAny()),
+ p => p.ReqGetResultAsync(It.IsAny()),
Times.AtMostOnce());
}
@@ -77,7 +77,7 @@ public void Inference_LoadsLocally()
{
var localResponse = new LocalResponse(
new FileInfo(Constants.V2RootDir + "products/extraction/financial_document/complete.json"));
- ExtractionResponse locallyLoadedResponse = localResponse.DeserializeResponse();
+ ExtractionResponse locallyLoadedResponse = localResponse.DeserializeResponse();
Assert.NotNull(locallyLoadedResponse);
Assert.Equal("12345678-1234-1234-1234-123456789abc", locallyLoadedResponse.Inference.Model.Id);
Assert.Equal("John Smith",
diff --git a/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs b/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
index 1c1ce67ea..4ff94d95c 100644
--- a/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
+++ b/tests/Mindee.UnitTests/V2/Input/LocalResponseTest.cs
@@ -22,7 +22,7 @@ private static void AssertLocalResponse(LocalResponse localResponse)
Assert.Equal(signature, localResponse.GetHmacSignature(secretKey));
Assert.True(localResponse.IsValidHmacSignature(
secretKey, signature));
- ExtractionResponse inferenceResponse = localResponse.DeserializeResponse();
+ ExtractionResponse inferenceResponse = localResponse.DeserializeResponse();
Assert.NotNull(inferenceResponse);
Assert.NotNull(inferenceResponse.Inference);
}
diff --git a/tests/Mindee.UnitTests/V2/Product/CropTest.cs b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
index e0aedb751..1d05b867c 100644
--- a/tests/Mindee.UnitTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
@@ -123,7 +123,7 @@ private static CropResponse GetInference(string path)
{
var localResponse = new LocalResponse(
File.ReadAllText(Constants.V2RootDir + path));
- return localResponse.DeserializeResponse();
+ return localResponse.DeserializeResponse();
}
private void AssertInferenceResponse(CropResponse response)
diff --git a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
index 139274064..69ee0627c 100644
--- a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
@@ -383,7 +383,7 @@ private static ExtractionResponse GetInference(string path)
{
var localResponse = new LocalResponse(
File.ReadAllText(Constants.V2RootDir + path));
- return localResponse.DeserializeResponse();
+ return localResponse.DeserializeResponse();
}
private void AssertInferenceResponse(ExtractionResponse response)
From 0f251b7d0726689be8d9d3caa272420373f007ba Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Tue, 24 Feb 2026 11:19:25 +0100
Subject: [PATCH 05/33] :sparkles: add support for classification
---
.../Params/ClassificationParameters.cs | 2 +-
.../Product/Extraction/ExtractionInference.cs | 5 ---
.../Product/Extraction/ExtractionResponse.cs | 2 +-
.../Extraction/Params/ExtractionParameters.cs | 2 +-
.../V2/Product/ClassificationTest.cs | 10 +++--
.../V2/Product/ExtractionTest.cs | 41 +++++++++++++++++++
.../V2/Product/ClassificationTest.cs | 5 +--
7 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs b/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
index fc6e6526f..fd767788b 100644
--- a/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
+++ b/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
@@ -9,7 +9,7 @@ namespace Mindee.V2.Product.Classification.Params
public class ClassificationParameters : BaseParameters
{
///
- /// Slug for the classification product.
+ /// Slug for the extraction product.
///
public sealed override string Slug { get; protected set; }
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionInference.cs b/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
index a0522d5ad..1cb1b4a58 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionInference.cs
@@ -24,11 +24,6 @@ public sealed class ExtractionInference : BaseInference
[JsonPropertyName("result")]
public ExtractionResult Result { get; set; }
- ///
- /// Type of the product's response.
- ///
- public static new Type ResponseType => typeof(ExtractionResponse);
-
///
/// A prettier representation.
///
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
index 6c1e86444..071fab776 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionResponse.cs
@@ -4,7 +4,7 @@
namespace Mindee.V2.Product.Extraction
{
///
- /// Represent an extraction response from Mindee V2 API.
+ /// Response for an extraction inference.
///
[EndpointSlug("extraction")]
public class ExtractionResponse : CommonInferenceResponse
diff --git a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
index fa8ff70c0..d6d80deed 100644
--- a/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
+++ b/src/Mindee/V2/Product/Extraction/Params/ExtractionParameters.cs
@@ -8,7 +8,7 @@
namespace Mindee.V2.Product.Extraction.Params
{
///
- /// ResultOptions to pass when calling methods using the predict API V2.
+ /// Parameters for an extraction inference.
///
public class ExtractionParameters : BaseParameters
{
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
index 8750da7d4..d366ad8b8 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
@@ -22,19 +22,21 @@ public ClassificationTest()
[Fact(Timeout = 180000)]
public async Task Classification_DefaultSample_MustSucceed()
{
+ // Arrange
var inputSource = new LocalInputSource(
- Constants.V2ProductDir + "classification/default_invoice.jpg");
- var productParams = new ClassificationParameters(_classificationModelId);
+ Constants.V2RootDir + "products/classification/default_sample.jpg");
+ var classificationParameters = new ClassificationParameters(_classificationModelId);
+
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, productParams);
+ inputSource, classificationParameters);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
var file = response.Inference.File;
Assert.NotNull(file);
- Assert.Equal("default_invoice.jpg", file.Name);
+ Assert.Equal("default_sample.jpg", file.Name);
var result = response.Inference.Result;
Assert.NotNull(result);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
index 93ee70839..df5b37535 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
@@ -1,7 +1,48 @@
+using Mindee.Input;
+using Mindee.V2;
+using Mindee.V2.Product.Extraction;
+using Mindee.V2.Product.Extraction.Params;
+
namespace Mindee.IntegrationTests.V2.Product
{
+ [Trait("Category", "V2")]
+ [Trait("Category", "Integration")]
public class ExtractionTest
{
+ private readonly string? _extractionModelId;
+ private readonly Client _client;
+
+ public ExtractionTest()
+ {
+ var apiKey = Environment.GetEnvironmentVariable("MindeeV2__ApiKey");
+ _client = TestingUtilities.GetOrGenerateMindeeClientV2(apiKey);
+ _extractionModelId = Environment.GetEnvironmentVariable("MindeeV2__Findoc__Model__Id");
+ }
+
+ [Fact(Timeout = 180000)]
+ public async Task Extraction_DefaultSample_MustSucceed()
+ {
+ // Arrange
+ var inputSource = new LocalInputSource(
+ Constants.V2RootDir + "products/extraction/default_sample.jpg");
+ var extractionParameters = new ExtractionParameters(_extractionModelId);
+
+
+ var response = await _client.EnqueueAndGetResultAsync(
+ inputSource, extractionParameters);
+
+ Assert.NotNull(response);
+ Assert.NotNull(response.Inference);
+
+ var file = response.Inference.File;
+ Assert.NotNull(file);
+ Assert.Equal("default_sample.jpg", file.Name);
+
+ var result = response.Inference.Result;
+ Assert.NotNull(result);
+ var fields = result.Fields;
+ Assert.NotNull(fields);
+ }
}
}
diff --git a/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs b/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
index 5eedcf29b..f645a426a 100644
--- a/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
@@ -10,7 +10,7 @@ public class ClassificationTest
[Fact]
public void Classification_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("classification/classification_single.json");
+ var response = GetInference("products/classification/classification_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -26,11 +26,10 @@ public void Classification_WhenSingle_MustHaveValidProperties()
var classification = inference.Result.Classification;
Assert.Equal("invoice", classification.DocumentType);
}
-
private static ClassificationResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2ProductDir + path));
+ File.ReadAllText(Constants.V2RootDir + path));
return localResponse.DeserializeResponse();
}
From a54b6af82fc5492f4c02b1901cd541e48f6b9a0b Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Tue, 24 Feb 2026 12:01:00 +0100
Subject: [PATCH 06/33] :sparkles: add support for Ocr
---
.../Params/ClassificationParameters.cs | 2 +-
src/Mindee/V2/Product/Crop/CropInference.cs | 6 ----
.../V2/Product/Crop/Params/CropParameters.cs | 2 +-
.../V2/Product/Extraction/ExtractionResult.cs | 1 -
.../Mindee.IntegrationTests/V2/ClientTest.cs | 2 +-
.../V2/Product/ClassificationTest.cs | 4 +--
.../V2/Product/ExtractionTest.cs | 3 +-
tests/Mindee.UnitTests/V2/Product/OcrTest.cs | 31 +++----------------
8 files changed, 10 insertions(+), 41 deletions(-)
diff --git a/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs b/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
index fd767788b..fc6e6526f 100644
--- a/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
+++ b/src/Mindee/V2/Product/Classification/Params/ClassificationParameters.cs
@@ -9,7 +9,7 @@ namespace Mindee.V2.Product.Classification.Params
public class ClassificationParameters : BaseParameters
{
///
- /// Slug for the extraction product.
+ /// Slug for the classification product.
///
public sealed override string Slug { get; protected set; }
diff --git a/src/Mindee/V2/Product/Crop/CropInference.cs b/src/Mindee/V2/Product/Crop/CropInference.cs
index 468242f27..b9543c2bf 100644
--- a/src/Mindee/V2/Product/Crop/CropInference.cs
+++ b/src/Mindee/V2/Product/Crop/CropInference.cs
@@ -1,4 +1,3 @@
-using System;
using System.Text.Json.Serialization;
using Mindee.V2.Parsing.Inference;
@@ -15,11 +14,6 @@ public class CropInference : BaseInference
[JsonPropertyName("result")]
public CropResult Result { get; set; }
- ///
- /// Type of the product's response.
- ///
- public static new Type ResponseType => typeof(CropResponse);
-
///
/// String representation of the crop inference.
///
diff --git a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
index 93df7fad8..a48d3c412 100644
--- a/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
+++ b/src/Mindee/V2/Product/Crop/Params/CropParameters.cs
@@ -9,7 +9,7 @@ namespace Mindee.V2.Product.Crop.Params
public class CropParameters : BaseParameters
{
///
- /// Slug for the extraction product.
+ /// Slug for the crop product.
///
public sealed override string Slug { get; protected set; }
diff --git a/src/Mindee/V2/Product/Extraction/ExtractionResult.cs b/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
index 003278d5f..032a36cc4 100644
--- a/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
+++ b/src/Mindee/V2/Product/Extraction/ExtractionResult.cs
@@ -1,7 +1,6 @@
using System.Text;
using System.Text.Json.Serialization;
using Mindee.Parsing;
-using Mindee.V1.Parsing;
using Mindee.V2.Parsing;
using Mindee.V2.Parsing.Inference;
using Mindee.V2.Parsing.Inference.Field;
diff --git a/tests/Mindee.IntegrationTests/V2/ClientTest.cs b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
index e18221735..7be617f5b 100644
--- a/tests/Mindee.IntegrationTests/V2/ClientTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/ClientTest.cs
@@ -227,7 +227,7 @@ public async Task NotFound_Job_MustThrowError()
public async Task NotFound_Inference_MustThrowError()
{
var ex = await Assert.ThrowsAsync(() =>
- _client.GetResultAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
+ _client.GetJobAsync("fc405e37-4ba4-4d03-aeba-533a8d1f0f21"));
Assert.Equal(404, ex.Status);
Assert.StartsWith("404-", ex.Code);
}
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
index d366ad8b8..ab6911adb 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
@@ -24,7 +24,7 @@ public async Task Classification_DefaultSample_MustSucceed()
{
// Arrange
var inputSource = new LocalInputSource(
- Constants.V2RootDir + "products/classification/default_sample.jpg");
+ Constants.V2ProductDir + "classification/default_invoice.jpg");
var classificationParameters = new ClassificationParameters(_classificationModelId);
@@ -36,7 +36,7 @@ public async Task Classification_DefaultSample_MustSucceed()
var file = response.Inference.File;
Assert.NotNull(file);
- Assert.Equal("default_sample.jpg", file.Name);
+ Assert.Equal("default_invoice.jpg", file.Name);
var result = response.Inference.Result;
Assert.NotNull(result);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
index df5b37535..f736b93c9 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
@@ -22,9 +22,8 @@ public ExtractionTest()
[Fact(Timeout = 180000)]
public async Task Extraction_DefaultSample_MustSucceed()
{
- // Arrange
var inputSource = new LocalInputSource(
- Constants.V2RootDir + "products/extraction/default_sample.jpg");
+ Constants.V2ProductDir + "extraction/financial_document/default_sample.jpg");
var extractionParameters = new ExtractionParameters(_extractionModelId);
diff --git a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
index feecc4e9e..4fc4a2852 100644
--- a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
@@ -10,14 +10,16 @@ public class OcrTest
[Fact]
public void Ocr_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("ocr/ocr_single.json");
+ var response = GetInference("products/ocr/ocr_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
+ // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
+ // Validate file metadata
Assert.Equal("default_sample.jpg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
@@ -38,36 +40,11 @@ public void Ocr_WhenSingle_MustHaveValidProperties()
Assert.Equal(4, fifthWord.Polygon.Count);
}
- [Fact]
- public void Ocr_WhenMultiple_MustHaveValidProperties()
- {
- var response = GetInference("ocr/ocr_multiple.json");
- AssertInferenceResponse(response);
-
- var inference = response.Inference;
-
- var job = inference.Job;
- Assert.Equal("12345678-1234-1234-1234-jobid1234567", job.Id);
-
- var model = inference.Model;
- Assert.NotNull(model);
-
- var pages = inference.Result.Pages;
- Assert.NotNull(pages);
- Assert.Equal(3, pages.Count);
-
- foreach (var page in pages)
- {
- Assert.NotNull(page.Words);
- Assert.NotNull(page.Content);
- Assert.IsType(page.Content);
- }
- }
private static OcrResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2ProductDir + path));
+ File.ReadAllText(Constants.V2RootDir + path));
return localResponse.DeserializeResponse();
}
From 761116a02b2010d9fb7ba1268488a727466a97ca Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Tue, 24 Feb 2026 12:19:47 +0100
Subject: [PATCH 07/33] :sparkles: add support for split product
---
.../V2/Product/ClassificationTest.cs | 1 -
.../V2/Product/CropTest.cs | 3 +--
.../V2/Product/OcrTest.cs | 4 +--
.../V2/Product/SplitTest.cs | 5 ++--
tests/Mindee.UnitTests/V2/Product/CropTest.cs | 8 ------
.../V2/Product/ExtractionTest.cs | 2 +-
tests/Mindee.UnitTests/V2/Product/OcrTest.cs | 27 +++++++++++++++++--
.../Mindee.UnitTests/V2/Product/SplitTest.cs | 6 ++---
8 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
index ab6911adb..461d92550 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
@@ -22,7 +22,6 @@ public ClassificationTest()
[Fact(Timeout = 180000)]
public async Task Classification_DefaultSample_MustSucceed()
{
- // Arrange
var inputSource = new LocalInputSource(
Constants.V2ProductDir + "classification/default_invoice.jpg");
var classificationParameters = new ClassificationParameters(_classificationModelId);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
index 54497c9e2..643921a87 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
@@ -22,7 +22,6 @@ public CropTest()
[Fact(Timeout = 180000)]
public async Task Crop_DefaultSample_MustSucceed()
{
- // Arrange
var inputSource = new LocalInputSource(
Constants.V2RootDir + "products/crop/default_sample.jpg");
var cropParameters = new CropParameters(_cropModelId);
@@ -43,7 +42,7 @@ public async Task Crop_DefaultSample_MustSucceed()
var crops = result.Crops;
Assert.NotNull(crops);
- Assert.Equal(2, crops.Count);
+ Assert.Single(crops);
}
}
}
diff --git a/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs b/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
index 5c003b5da..7e8419849 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
@@ -24,10 +24,10 @@ public async Task Ocr_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2ProductDir + "ocr/default_sample.jpg");
- var productParams = new OcrParameters(_ocrModelId);
+ var ocrParameters = new OcrParameters(_ocrModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, productParams);
+ inputSource, ocrParameters);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs b/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
index 72140337a..41a3abc50 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
@@ -24,10 +24,11 @@ public async Task Split_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2RootDir + "products/split/default_sample.pdf");
- var productParams = new SplitParameters(_splitModelId);
+ var splitParameters = new SplitParameters(_splitModelId);
+
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, productParams);
+ inputSource, splitParameters);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.UnitTests/V2/Product/CropTest.cs b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
index 1d05b867c..5642a11b9 100644
--- a/tests/Mindee.UnitTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
@@ -16,17 +16,14 @@ public void Crop_WhenSingle_MustHaveValidProperties()
var inference = response.Inference;
- // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
Assert.Equal("12345678-1234-1234-1234-jobid1234567", inference.Job.Id);
- // Validate file metadata
Assert.Equal("sample.jpeg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
- // Validate crops
var crops = inference.Result.Crops;
Assert.NotNull(crops);
Assert.Single(crops);
@@ -54,11 +51,9 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
var job = inference.Job;
Assert.Equal("12345678-1234-1234-1234-jobid1234567", job.Id);
- // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
- // Validate file metadata
Assert.Equal("default_sample.jpg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
@@ -67,7 +62,6 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
Assert.NotNull(crops);
Assert.Equal(2, crops.Count);
- // Validate first crop item
var firstCrop = crops[0];
Assert.Equal("invoice", firstCrop.ObjectType);
Assert.Equal(0, firstCrop.Location.Page);
@@ -79,7 +73,6 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
Assert.Equal(new Point(0.476, 0.979), firstPolygon[2]);
Assert.Equal(new Point(0.214, 0.979), firstPolygon[3]);
- // Validate second crop item
var secondCrop = crops[1];
Assert.Equal("invoice", secondCrop.ObjectType);
Assert.Equal(0, secondCrop.Location.Page);
@@ -95,7 +88,6 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
[Fact(DisplayName = "crop_single.rst – RST display must be parsed and exposed")]
public void RstDisplay_MustBeAccessible()
{
- // Arrange
var resp = GetInference("products/crop/crop_single.json");
var rstReference = File.ReadAllText(
Constants.V2RootDir + "products/crop/crop_single.rst");
diff --git a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
index 69ee0627c..aa585f564 100644
--- a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
@@ -290,7 +290,7 @@ public void StandardFieldTypes_mustHaveLocations()
[Fact(DisplayName = "standard_field_types.rst – RST display must be parsed and exposed")]
public void RstDisplay_mustBeAccessible()
{
- var resp = GetInference("extraction/standard_field_types.json");
+ var resp = GetInference("products/extraction/standard_field_types.json");
var rstReference = File.ReadAllText(
Constants.V2ProductDir + "extraction/standard_field_types.rst");
diff --git a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
index 4fc4a2852..8f24c6468 100644
--- a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
@@ -15,11 +15,9 @@ public void Ocr_WhenSingle_MustHaveValidProperties()
var inference = response.Inference;
- // Validate inference metadata
Assert.Equal("12345678-1234-1234-1234-123456789abc", inference.Id);
Assert.Equal("test-model-id", inference.Model.Id);
- // Validate file metadata
Assert.Equal("default_sample.jpg", inference.File.Name);
Assert.Equal(1, inference.File.PageCount);
Assert.Equal("image/jpeg", inference.File.MimeType);
@@ -40,6 +38,31 @@ public void Ocr_WhenSingle_MustHaveValidProperties()
Assert.Equal(4, fifthWord.Polygon.Count);
}
+ [Fact]
+ public void Ocr_WhenMultiple_MustHaveValidProperties()
+ {
+ var response = GetInference("products/ocr/ocr_multiple.json");
+ AssertInferenceResponse(response);
+
+ var inference = response.Inference;
+
+ var job = inference.Job;
+ Assert.Equal("12345678-1234-1234-1234-jobid1234567", job.Id);
+
+ var model = inference.Model;
+ Assert.NotNull(model);
+
+ var pages = inference.Result.Pages;
+ Assert.NotNull(pages);
+ Assert.Equal(3, pages.Count);
+
+ foreach (var page in pages)
+ {
+ Assert.NotNull(page.Words);
+ Assert.NotNull(page.Content);
+ Assert.IsType(page.Content);
+ }
+ }
private static OcrResponse GetInference(string path)
{
diff --git a/tests/Mindee.UnitTests/V2/Product/SplitTest.cs b/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
index 28d21be4e..ac9906ab9 100644
--- a/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
@@ -10,7 +10,7 @@ public class SplitTest
[Fact]
public void Split_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("split/split_single.json");
+ var response = GetInference("products/split/split_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -34,7 +34,7 @@ public void Split_WhenSingle_MustHaveValidProperties()
[Fact]
public void Split_WhenMultiple_MustHaveValidProperties()
{
- var response = GetInference("split/split_multiple.json");
+ var response = GetInference("products/split/split_multiple.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -66,7 +66,7 @@ public void Split_WhenMultiple_MustHaveValidProperties()
private static SplitResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2ProductDir + path));
+ File.ReadAllText(Constants.V2RootDir + path));
return localResponse.DeserializeResponse();
}
From bf41971c1bedbfd903786dad5e6ecf4699ce069d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?=
Date: Wed, 25 Feb 2026 16:50:17 +0100
Subject: [PATCH 08/33] easier v2 product tests
---
docs/code_samples/v2_extraction_polling.txt | 4 ++--
src/Mindee/V2/Client.cs | 12 ++++++------
.../V2/Product/ClassificationTest.cs | 5 ++---
.../V2/Product/CropTest.cs | 15 +++++++++------
.../V2/Product/ExtractionTest.cs | 5 ++---
.../Mindee.IntegrationTests/V2/Product/OcrTest.cs | 4 ++--
.../V2/Product/SplitTest.cs | 5 ++---
.../V2/Product/ClassificationTest.cs | 5 +++--
tests/Mindee.UnitTests/V2/Product/CropTest.cs | 10 +++++-----
.../Mindee.UnitTests/V2/Product/ExtractionTest.cs | 4 ++--
tests/Mindee.UnitTests/V2/Product/OcrTest.cs | 6 +++---
tests/Mindee.UnitTests/V2/Product/SplitTest.cs | 6 +++---
12 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/docs/code_samples/v2_extraction_polling.txt b/docs/code_samples/v2_extraction_polling.txt
index 3678b1a1f..71615b7f4 100644
--- a/docs/code_samples/v2_extraction_polling.txt
+++ b/docs/code_samples/v2_extraction_polling.txt
@@ -11,7 +11,7 @@ string modelId = "MY_MODEL_ID";
// Construct a new client
Client mindeeClient = new Client(apiKey);
-// Set parameters
+// Set inference parameters
var productParams = new ExtractionParameters(
modelId: modelId
@@ -32,7 +32,7 @@ var productParams = new ExtractionParameters(
var inputSource = new LocalInputSource(filePath);
// Upload the file
-var response = await mindeeClient.EnqueueAndGetResultAsync(
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
inputSource, productParams);
// Print a summary of the response
diff --git a/src/Mindee/V2/Client.cs b/src/Mindee/V2/Client.cs
index f5a3698bc..a203e74b1 100644
--- a/src/Mindee/V2/Client.cs
+++ b/src/Mindee/V2/Client.cs
@@ -229,8 +229,8 @@ InputSource inputSource
///
///
///
- ///
- ///
+ ///
+ ///
///
///
///
@@ -238,7 +238,7 @@ InputSource inputSource
///
public async Task EnqueueAndGetResultAsync(
InputSource inputSource
- , BaseParameters extractionParameters)
+ , BaseParameters parameters)
where TResponse : CommonInferenceResponse, new()
{
switch (inputSource)
@@ -255,12 +255,12 @@ InputSource inputSource
throw new MindeeInputException($"Unsupported input source {inputSource.GetType().Name}");
}
- extractionParameters.PollingOptions ??= new PollingOptions();
+ parameters.PollingOptions ??= new PollingOptions();
var enqueueResponse = await EnqueueAsync(
inputSource,
- extractionParameters);
- return await PollForResultsAsync(enqueueResponse, extractionParameters.PollingOptions);
+ parameters);
+ return await PollForResultsAsync(enqueueResponse, parameters.PollingOptions);
}
///
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
index 461d92550..8750da7d4 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ClassificationTest.cs
@@ -24,11 +24,10 @@ public async Task Classification_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2ProductDir + "classification/default_invoice.jpg");
- var classificationParameters = new ClassificationParameters(_classificationModelId);
-
+ var productParams = new ClassificationParameters(_classificationModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, classificationParameters);
+ inputSource, productParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
index 643921a87..3de43974f 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/CropTest.cs
@@ -23,12 +23,11 @@ public CropTest()
public async Task Crop_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
- Constants.V2RootDir + "products/crop/default_sample.jpg");
- var cropParameters = new CropParameters(_cropModelId);
-
+ Constants.V2ProductDir + "crop/default_sample.jpg");
+ var productParams = new CropParameters(_cropModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, cropParameters);
+ inputSource, productParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
@@ -41,8 +40,12 @@ public async Task Crop_DefaultSample_MustSucceed()
Assert.NotNull(result);
var crops = result.Crops;
- Assert.NotNull(crops);
- Assert.Single(crops);
+ Assert.Equal(2, crops.Count);
+ foreach (var crop in crops)
+ {
+ Assert.NotNull(crop.ObjectType);
+ Assert.NotNull(crop.Location);
+ }
}
}
}
diff --git a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
index f736b93c9..9c02e6989 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/ExtractionTest.cs
@@ -24,11 +24,10 @@ public async Task Extraction_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2ProductDir + "extraction/financial_document/default_sample.jpg");
- var extractionParameters = new ExtractionParameters(_extractionModelId);
-
+ var productParams = new ExtractionParameters(_extractionModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, extractionParameters);
+ inputSource, productParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs b/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
index 7e8419849..5c003b5da 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/OcrTest.cs
@@ -24,10 +24,10 @@ public async Task Ocr_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2ProductDir + "ocr/default_sample.jpg");
- var ocrParameters = new OcrParameters(_ocrModelId);
+ var productParams = new OcrParameters(_ocrModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, ocrParameters);
+ inputSource, productParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs b/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
index 41a3abc50..72140337a 100644
--- a/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
+++ b/tests/Mindee.IntegrationTests/V2/Product/SplitTest.cs
@@ -24,11 +24,10 @@ public async Task Split_DefaultSample_MustSucceed()
{
var inputSource = new LocalInputSource(
Constants.V2RootDir + "products/split/default_sample.pdf");
- var splitParameters = new SplitParameters(_splitModelId);
-
+ var productParams = new SplitParameters(_splitModelId);
var response = await _client.EnqueueAndGetResultAsync(
- inputSource, splitParameters);
+ inputSource, productParams);
Assert.NotNull(response);
Assert.NotNull(response.Inference);
diff --git a/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs b/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
index f645a426a..5eedcf29b 100644
--- a/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ClassificationTest.cs
@@ -10,7 +10,7 @@ public class ClassificationTest
[Fact]
public void Classification_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("products/classification/classification_single.json");
+ var response = GetInference("classification/classification_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -26,10 +26,11 @@ public void Classification_WhenSingle_MustHaveValidProperties()
var classification = inference.Result.Classification;
Assert.Equal("invoice", classification.DocumentType);
}
+
private static ClassificationResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2RootDir + path));
+ File.ReadAllText(Constants.V2ProductDir + path));
return localResponse.DeserializeResponse();
}
diff --git a/tests/Mindee.UnitTests/V2/Product/CropTest.cs b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
index 5642a11b9..fada340a2 100644
--- a/tests/Mindee.UnitTests/V2/Product/CropTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/CropTest.cs
@@ -11,7 +11,7 @@ public class CropTest
[Fact]
public void Crop_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("products/crop/crop_single.json");
+ var response = GetInference("crop/crop_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -43,7 +43,7 @@ public void Crop_WhenSingle_MustHaveValidProperties()
[Fact]
public void Crop_WhenMultiple_MustHaveValidProperties()
{
- var response = GetInference("products/crop/crop_multiple.json");
+ var response = GetInference("crop/crop_multiple.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -88,9 +88,9 @@ public void Crop_WhenMultiple_MustHaveValidProperties()
[Fact(DisplayName = "crop_single.rst – RST display must be parsed and exposed")]
public void RstDisplay_MustBeAccessible()
{
- var resp = GetInference("products/crop/crop_single.json");
+ var resp = GetInference("crop/crop_single.json");
var rstReference = File.ReadAllText(
- Constants.V2RootDir + "products/crop/crop_single.rst");
+ Constants.V2ProductDir + "crop/crop_single.rst");
var inf = resp.Inference;
@@ -114,7 +114,7 @@ private static string NormalizeLineEndings(string input)
private static CropResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2RootDir + path));
+ File.ReadAllText(Constants.V2ProductDir + path));
return localResponse.DeserializeResponse();
}
diff --git a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
index aa585f564..0dd5b31b8 100644
--- a/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/ExtractionTest.cs
@@ -290,7 +290,7 @@ public void StandardFieldTypes_mustHaveLocations()
[Fact(DisplayName = "standard_field_types.rst – RST display must be parsed and exposed")]
public void RstDisplay_mustBeAccessible()
{
- var resp = GetInference("products/extraction/standard_field_types.json");
+ var resp = GetInference("extraction/standard_field_types.json");
var rstReference = File.ReadAllText(
Constants.V2ProductDir + "extraction/standard_field_types.rst");
@@ -382,7 +382,7 @@ private static string NormalizeLineEndings(string input)
private static ExtractionResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2RootDir + path));
+ File.ReadAllText(Constants.V2ProductDir + path));
return localResponse.DeserializeResponse();
}
diff --git a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
index 8f24c6468..feecc4e9e 100644
--- a/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/OcrTest.cs
@@ -10,7 +10,7 @@ public class OcrTest
[Fact]
public void Ocr_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("products/ocr/ocr_single.json");
+ var response = GetInference("ocr/ocr_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -41,7 +41,7 @@ public void Ocr_WhenSingle_MustHaveValidProperties()
[Fact]
public void Ocr_WhenMultiple_MustHaveValidProperties()
{
- var response = GetInference("products/ocr/ocr_multiple.json");
+ var response = GetInference("ocr/ocr_multiple.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -67,7 +67,7 @@ public void Ocr_WhenMultiple_MustHaveValidProperties()
private static OcrResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2RootDir + path));
+ File.ReadAllText(Constants.V2ProductDir + path));
return localResponse.DeserializeResponse();
}
diff --git a/tests/Mindee.UnitTests/V2/Product/SplitTest.cs b/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
index ac9906ab9..28d21be4e 100644
--- a/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
+++ b/tests/Mindee.UnitTests/V2/Product/SplitTest.cs
@@ -10,7 +10,7 @@ public class SplitTest
[Fact]
public void Split_WhenSingle_MustHaveValidProperties()
{
- var response = GetInference("products/split/split_single.json");
+ var response = GetInference("split/split_single.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -34,7 +34,7 @@ public void Split_WhenSingle_MustHaveValidProperties()
[Fact]
public void Split_WhenMultiple_MustHaveValidProperties()
{
- var response = GetInference("products/split/split_multiple.json");
+ var response = GetInference("split/split_multiple.json");
AssertInferenceResponse(response);
var inference = response.Inference;
@@ -66,7 +66,7 @@ public void Split_WhenMultiple_MustHaveValidProperties()
private static SplitResponse GetInference(string path)
{
var localResponse = new LocalResponse(
- File.ReadAllText(Constants.V2RootDir + path));
+ File.ReadAllText(Constants.V2ProductDir + path));
return localResponse.DeserializeResponse();
}
From 6f83cd549a3548510ed62dbeaa95120272a8a9fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?=
Date: Mon, 2 Mar 2026 16:54:49 +0100
Subject: [PATCH 09/33] test samples
---
docs/code_samples/v2_croptxt | 26 ++++++++++++++++++++++++++
docs/code_samples/v2_splitxt | 26 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
create mode 100644 docs/code_samples/v2_croptxt
create mode 100644 docs/code_samples/v2_splitxt
diff --git a/docs/code_samples/v2_croptxt b/docs/code_samples/v2_croptxt
new file mode 100644
index 000000000..14f733afe
--- /dev/null
+++ b/docs/code_samples/v2_croptxt
@@ -0,0 +1,26 @@
+using Mindee;
+using Mindee.Input;
+using Mindee.V2;
+using Mindee.V2.Product.Crop.Params;
+
+string filePath = "/path/to/the/file.ext";
+string apiKey = "MY_API_KEY";
+string modelId = "MY_MODEL_ID";
+
+// Construct a new client
+Client mindeeClient = new Client(apiKey);
+
+// Set inference parameters
+var productParams = new CropParameters(
+ modelId: modelId
+);
+
+// Load a file from disk
+var inputSource = new LocalInputSource(filePath);
+
+// Upload the file
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
+ inputSource, productParams);
+
+// Print a summary of the response
+System.Console.WriteLine(response.Inference.ToString());
diff --git a/docs/code_samples/v2_splitxt b/docs/code_samples/v2_splitxt
new file mode 100644
index 000000000..095d08f71
--- /dev/null
+++ b/docs/code_samples/v2_splitxt
@@ -0,0 +1,26 @@
+using Mindee;
+using Mindee.Input;
+using Mindee.V2;
+using Mindee.V2.Product.Split.Params;
+
+string filePath = "/path/to/the/file.ext";
+string apiKey = "MY_API_KEY";
+string modelId = "MY_MODEL_ID";
+
+// Construct a new client
+Client mindeeClient = new Client(apiKey);
+
+// Set inference parameters
+var productParams = new SplitParameters(
+ modelId: modelId
+);
+
+// Load a file from disk
+var inputSource = new LocalInputSource(filePath);
+
+// Upload the file
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
+ inputSource, productParams);
+
+// Print a summary of the response
+System.Console.WriteLine(response.Inference.ToString());
From 7e3aeacc9a57b891251696114a3e0aa463305276 Mon Sep 17 00:00:00 2001
From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com>
Date: Fri, 6 Mar 2026 12:11:05 +0100
Subject: [PATCH 10/33] fix syntaxes + add tests
---
docs/code_samples/v2_classification.txt | 3 +--
docs/code_samples/v2_crop.txt | 3 +--
docs/code_samples/v2_croptxt | 26 -------------------
docs/code_samples/v2_ocr.txt | 3 +--
docs/code_samples/v2_split.txt | 3 +--
docs/code_samples/v2_splitxt | 26 -------------------
src/Mindee/V2/Client.cs | 21 ---------------
.../Mindee.IntegrationTests/V2/ClientTest.cs | 2 +-
.../V2/Input/LocalResponseTest.cs | 6 ++---
9 files changed, 8 insertions(+), 85 deletions(-)
delete mode 100644 docs/code_samples/v2_croptxt
delete mode 100644 docs/code_samples/v2_splitxt
diff --git a/docs/code_samples/v2_classification.txt b/docs/code_samples/v2_classification.txt
index 001845c3f..af2d2fa1a 100644
--- a/docs/code_samples/v2_classification.txt
+++ b/docs/code_samples/v2_classification.txt
@@ -1,7 +1,6 @@
using Mindee;
using Mindee.Input;
using Mindee.V2;
-using Mindee.V2.Product.Classification;
using Mindee.V2.Product.Classification.Params;
string filePath = "/path/to/the/file.ext";
@@ -20,7 +19,7 @@ var productParams = new ClassificationParameters(
var inputSource = new LocalInputSource(filePath);
// Upload the file
-var response = await mindeeClient.EnqueueAndGetResultAsync(
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
inputSource, productParams);
// Print a summary of the response
diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt
index 8a9cbbd8a..cec59a8bc 100644
--- a/docs/code_samples/v2_crop.txt
+++ b/docs/code_samples/v2_crop.txt
@@ -1,7 +1,6 @@
using Mindee;
using Mindee.Input;
using Mindee.V2;
-using Mindee.V2.Product.Crop;
using Mindee.V2.Product.Crop.Params;
string filePath = "/path/to/the/file.ext";
@@ -20,7 +19,7 @@ var productParams = new CropParameters(
var inputSource = new LocalInputSource(filePath);
// Upload the file
-var response = await mindeeClient.EnqueueAndGetResultAsync(
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
inputSource, productParams);
// Print a summary of the response
diff --git a/docs/code_samples/v2_croptxt b/docs/code_samples/v2_croptxt
deleted file mode 100644
index 14f733afe..000000000
--- a/docs/code_samples/v2_croptxt
+++ /dev/null
@@ -1,26 +0,0 @@
-using Mindee;
-using Mindee.Input;
-using Mindee.V2;
-using Mindee.V2.Product.Crop.Params;
-
-string filePath = "/path/to/the/file.ext";
-string apiKey = "MY_API_KEY";
-string modelId = "MY_MODEL_ID";
-
-// Construct a new client
-Client mindeeClient = new Client(apiKey);
-
-// Set inference parameters
-var productParams = new CropParameters(
- modelId: modelId
-);
-
-// Load a file from disk
-var inputSource = new LocalInputSource(filePath);
-
-// Upload the file
-var response = await mindeeClient.EnqueueAndGetInferenceAsync(
- inputSource, productParams);
-
-// Print a summary of the response
-System.Console.WriteLine(response.Inference.ToString());
diff --git a/docs/code_samples/v2_ocr.txt b/docs/code_samples/v2_ocr.txt
index 0654e7246..8b85e8738 100644
--- a/docs/code_samples/v2_ocr.txt
+++ b/docs/code_samples/v2_ocr.txt
@@ -1,7 +1,6 @@
using Mindee;
using Mindee.Input;
using Mindee.V2;
-using Mindee.V2.Product.Ocr;
using Mindee.V2.Product.Ocr.Params;
string filePath = "/path/to/the/file.ext";
@@ -20,7 +19,7 @@ var productParams = new OcrParameters(
var inputSource = new LocalInputSource(filePath);
// Upload the file
-var response = await mindeeClient.EnqueueAndGetResultAsync(
+var response = await mindeeClient.EnqueueAndGetInferenceAsync(
inputSource, productParams);
// Print a summary of the response
diff --git a/docs/code_samples/v2_split.txt b/docs/code_samples/v2_split.txt
index 1f3d0a071..c626727dd 100644
--- a/docs/code_samples/v2_split.txt
+++ b/docs/code_samples/v2_split.txt
@@ -1,7 +1,6 @@
using Mindee;
using Mindee.Input;
using Mindee.V2;
-using Mindee.V2.Product.Split;
using Mindee.V2.Product.Split.Params;
string filePath = "/path/to/the/file.ext";
@@ -20,7 +19,7 @@ var productParams = new SplitParameters(
var inputSource = new LocalInputSource(filePath);
// Upload the file
-var response = await mindeeClient.EnqueueAndGetResultAsync