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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user