From 190d41489e7b46bfafe8895a7d38a0840f8bb17f Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 19 May 2026 18:57:33 +0200 Subject: [PATCH] Refactor InvokeAsync to return Task and improve docs The return type of the `InvokeAsync` method has been changed from `Task` to `Task` for both overloads, removing the boolean return value for success indication. The `` XML documentation tag has been removed, and a new `` 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. --- src/ReC.Client/Api/RecActionApi.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ReC.Client/Api/RecActionApi.cs b/src/ReC.Client/Api/RecActionApi.cs index 6c6be6d..53d9a20 100644 --- a/src/ReC.Client/Api/RecActionApi.cs +++ b/src/ReC.Client/Api/RecActionApi.cs @@ -23,14 +23,14 @@ namespace ReC.Client.Api /// The profile identifier. /// Optional reference values to pass through to all result records. /// A token to cancel the operation. - /// if the request succeeds; otherwise, . - public async Task InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default) + /// Thrown when the API responds with a non-success status code. + 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 /// The profile identifier. /// Batch identifier. /// A token to cancel the operation. - /// if the request succeeds; otherwise, . - public Task InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default) + /// Thrown when the API responds with a non-success status code. + public Task InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default) { return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken); }