From 99bdf77ead44ca73fd2a0dbc8ee1579f9b95728f Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 4 Aug 2026 14:05:50 +0200 Subject: [PATCH] Add BatchRecActionViewResponse and update InvokeAsync Introduce the `BatchRecActionViewResponse` class to represent the result of batch RecAction invocations, including total actions processed and exceptions encountered. Update `InvokeAsync` methods in `RecActionApi` to return a `BatchRecActionViewResponse` instead of `void`. Modify the implementation to deserialize API responses into this new class. Add XML documentation for the updated return type and use conditional compilation to handle nullable reference types for .NET Framework and other target frameworks. --- src/ReC.Client/Api/BatchRecActionViewResponse.cs | 14 ++++++++++++++ src/ReC.Client/Api/RecActionApi.cs | 15 +++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/ReC.Client/Api/BatchRecActionViewResponse.cs diff --git a/src/ReC.Client/Api/BatchRecActionViewResponse.cs b/src/ReC.Client/Api/BatchRecActionViewResponse.cs new file mode 100644 index 0000000..d70f315 --- /dev/null +++ b/src/ReC.Client/Api/BatchRecActionViewResponse.cs @@ -0,0 +1,14 @@ +namespace ReC.Client.Api +{ + /// + /// Represents the result of a batch RecAction invocation. + /// + public class BatchRecActionViewResponse + { + /// Total number of actions that were processed. + public int TotalActionCount { get; set; } + + /// Number of actions that resulted in an exception. + public int ActionExceptionCount { get; set; } + } +} diff --git a/src/ReC.Client/Api/RecActionApi.cs b/src/ReC.Client/Api/RecActionApi.cs index 17fce3c..e0f7982 100644 --- a/src/ReC.Client/Api/RecActionApi.cs +++ b/src/ReC.Client/Api/RecActionApi.cs @@ -30,18 +30,20 @@ namespace ReC.Client.Api /// The profile identifier. /// Optional reference values to pass through to all result records. /// A token to cancel the operation. + /// A describing the outcome of the batch invocation. /// Thrown when the API responds with a non-success status code. #if NETFRAMEWORK - public async Task InvokeAsync(long profileId, InvokeReferences references = null, CancellationToken cancellationToken = default) + public async Task InvokeAsync(long profileId, InvokeReferences references = null, CancellationToken cancellationToken = default) #else - public async Task InvokeAsync(long profileId, InvokeReferences? references = null, CancellationToken cancellationToken = default) + public async Task InvokeAsync(long profileId, InvokeReferences? references = null, CancellationToken cancellationToken = default) #endif { var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null; using (content) using (var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken)) { - await ReCClientHelpers.HandleResponseAsync(resp, Logger, Options.LogSuccessfulRequests, cancellationToken).ConfigureAwait(false); + var body = await ReCClientHelpers.HandleResponseAsync(resp, Logger, Options.LogSuccessfulRequests, cancellationToken).ConfigureAwait(false); + return ReCClientHelpers.Deserialize(body); } } @@ -51,8 +53,13 @@ namespace ReC.Client.Api /// The profile identifier. /// Batch identifier. /// A token to cancel the operation. + /// A describing the outcome of the batch invocation. /// Thrown when the API responds with a non-success status code. - public Task InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default) +#if NETFRAMEWORK + public Task InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default) +#else + public Task InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default) +#endif { return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken); }