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.
This commit is contained in:
2026-08-04 14:05:50 +02:00
parent c729cb33e3
commit 99bdf77ead
2 changed files with 25 additions and 4 deletions

View File

@@ -0,0 +1,14 @@
namespace ReC.Client.Api
{
/// <summary>
/// Represents the result of a batch RecAction invocation.
/// </summary>
public class BatchRecActionViewResponse
{
/// <summary>Total number of actions that were processed.</summary>
public int TotalActionCount { get; set; }
/// <summary>Number of actions that resulted in an exception.</summary>
public int ActionExceptionCount { get; set; }
}
}

View File

@@ -30,18 +30,20 @@ namespace ReC.Client.Api
/// <param name="profileId">The profile identifier.</param>
/// <param name="references">Optional reference values to pass through to all result records.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>A <see cref="BatchRecActionViewResponse"/> describing the outcome of the batch invocation.</returns>
/// <exception cref="ReCApiException">Thrown when the API responds with a non-success status code.</exception>
#if NETFRAMEWORK
public async Task InvokeAsync(long profileId, InvokeReferences references = null, CancellationToken cancellationToken = default)
public async Task<BatchRecActionViewResponse> 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<BatchRecActionViewResponse?> 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<BatchRecActionViewResponse>(body);
}
}
@@ -51,8 +53,13 @@ namespace ReC.Client.Api
/// <param name="profileId">The profile identifier.</param>
/// <param name="batchId">Batch identifier.</param>
/// <param name="cancellationToken">A token to cancel the operation.</param>
/// <returns>A <see cref="BatchRecActionViewResponse"/> describing the outcome of the batch invocation.</returns>
/// <exception cref="ReCApiException">Thrown when the API responds with a non-success status code.</exception>
public Task InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default)
#if NETFRAMEWORK
public Task<BatchRecActionViewResponse> InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default)
#else
public Task<BatchRecActionViewResponse?> InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default)
#endif
{
return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken);
}