Refactor InvokeAsync to return Task and improve docs

The return type of the `InvokeAsync` method has been changed from `Task<bool>` to `Task` for both overloads, removing the boolean return value for success indication.

The `<returns>` XML documentation tag has been removed, and a new `<exception>` tag has been added to document the potential `ReCApiException` thrown when the API responds with a non-success status code.

The implementation now uses `ReCClientHelpers.EnsureSuccessAsync` to handle API responses, replacing the previous `resp.IsSuccessStatusCode` check.

These changes improve clarity and align the method's behavior with standard practices for handling asynchronous operations and exceptions.
This commit is contained in:
2026-05-19 18:57:33 +02:00
parent dfcf1fb536
commit 190d41489e

View File

@@ -23,14 +23,14 @@ 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><see langword="true"/> if the request succeeds; otherwise, <see langword="false"/>.</returns>
public async Task<bool> InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default)
/// <exception cref="ReCApiException">Thrown when the API responds with a non-success status code.</exception>
public async Task InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default)
{
var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null;
using (content)
using (var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken))
{
return resp.IsSuccessStatusCode;
await ReCClientHelpers.EnsureSuccessAsync(resp, cancellationToken).ConfigureAwait(false);
}
}
@@ -40,8 +40,8 @@ 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><see langword="true"/> if the request succeeds; otherwise, <see langword="false"/>.</returns>
public Task<bool> InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default)
/// <exception cref="ReCApiException">Thrown when the API responds with a non-success status code.</exception>
public Task InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default)
{
return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken);
}