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:
14
src/ReC.Client/Api/BatchRecActionViewResponse.cs
Normal file
14
src/ReC.Client/Api/BatchRecActionViewResponse.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,18 +30,20 @@ namespace ReC.Client.Api
|
|||||||
/// <param name="profileId">The profile identifier.</param>
|
/// <param name="profileId">The profile identifier.</param>
|
||||||
/// <param name="references">Optional reference values to pass through to all result records.</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>
|
/// <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>
|
/// <exception cref="ReCApiException">Thrown when the API responds with a non-success status code.</exception>
|
||||||
#if NETFRAMEWORK
|
#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
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null;
|
var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null;
|
||||||
using (content)
|
using (content)
|
||||||
using (var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken))
|
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="profileId">The profile identifier.</param>
|
||||||
/// <param name="batchId">Batch identifier.</param>
|
/// <param name="batchId">Batch identifier.</param>
|
||||||
/// <param name="cancellationToken">A token to cancel the operation.</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>
|
/// <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);
|
return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user