From b9a40bb12e775f8b67602bcd1a23cea1a58f5b6f Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 11:42:03 +0100 Subject: [PATCH] Refactor API method names for consistency and clarity Renamed public API methods across ReC.Client.Api classes to use concise and uniform names (e.g., CreateAsync, UpdateAsync, DeleteAsync, GetAsync, InvokeAsync). Removed obsolete NETFRAMEWORK preprocessor blocks. Updated summary comment for Results property in ReCClient.cs. These changes improve naming consistency and code clarity throughout the client library. --- src/ReC.Client/Api/CommonApi.cs | 8 +++----- src/ReC.Client/Api/EndpointAuthApi.cs | 8 +++----- src/ReC.Client/Api/EndpointParamsApi.cs | 8 +++----- src/ReC.Client/Api/EndpointsApi.cs | 8 +++----- src/ReC.Client/Api/ProfileApi.cs | 10 ++++------ src/ReC.Client/Api/RecActionApi.cs | 12 +++++------- src/ReC.Client/Api/ResultApi.cs | 10 ++++------ src/ReC.Client/ReCClient.cs | 4 ++-- 8 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/ReC.Client/Api/CommonApi.cs b/src/ReC.Client/Api/CommonApi.cs index 4b9b87e..5dd4f1a 100644 --- a/src/ReC.Client/Api/CommonApi.cs +++ b/src/ReC.Client/Api/CommonApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -29,7 +27,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateObjectAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/Common", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -39,7 +37,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateObjectAsync(T procedure, CancellationToken cancel = default) + public Task UpdateAsync(T procedure, CancellationToken cancel = default) => _http.PutAsync("api/Common", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -49,7 +47,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteObjectAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/Common") { diff --git a/src/ReC.Client/Api/EndpointAuthApi.cs b/src/ReC.Client/Api/EndpointAuthApi.cs index 0d2c6cc..e583bbd 100644 --- a/src/ReC.Client/Api/EndpointAuthApi.cs +++ b/src/ReC.Client/Api/EndpointAuthApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -29,7 +27,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateEndpointAuthAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/EndpointAuth", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -40,7 +38,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateEndpointAuthAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/EndpointAuth/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -50,7 +48,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteEndpointAuthAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointAuth") { diff --git a/src/ReC.Client/Api/EndpointParamsApi.cs b/src/ReC.Client/Api/EndpointParamsApi.cs index d07d2d3..0cd96e5 100644 --- a/src/ReC.Client/Api/EndpointParamsApi.cs +++ b/src/ReC.Client/Api/EndpointParamsApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -29,7 +27,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateEndpointParamsAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/EndpointParams", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -40,7 +38,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateEndpointParamsAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/EndpointParams/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -50,7 +48,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteEndpointParamsAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointParams") { diff --git a/src/ReC.Client/Api/EndpointsApi.cs b/src/ReC.Client/Api/EndpointsApi.cs index c4085a5..015434c 100644 --- a/src/ReC.Client/Api/EndpointsApi.cs +++ b/src/ReC.Client/Api/EndpointsApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -29,7 +27,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateEndpointAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/Endpoints", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -40,7 +38,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateEndpointAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/Endpoints/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -50,7 +48,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteEndpointAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/Endpoints") { diff --git a/src/ReC.Client/Api/ProfileApi.cs b/src/ReC.Client/Api/ProfileApi.cs index 9251b9b..e27ab68 100644 --- a/src/ReC.Client/Api/ProfileApi.cs +++ b/src/ReC.Client/Api/ProfileApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -29,7 +27,7 @@ namespace ReC.Client.Api /// Whether to include related actions. /// A token to cancel the operation. /// The HTTP response message. - public Task GetProfileAsync(long id, bool includeActions = false, CancellationToken cancel = default) + public Task GetAsync(long id, bool includeActions = false, CancellationToken cancel = default) { var query = ReCClientHelpers.BuildQuery(("Id", id), ("IncludeActions", includeActions)); return _http.GetAsync($"api/Profile{query}", cancel); @@ -42,7 +40,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateProfileAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/Profile", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -53,7 +51,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateProfileAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/Profile/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -63,7 +61,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteProfilesAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/Profile") { diff --git a/src/ReC.Client/Api/RecActionApi.cs b/src/ReC.Client/Api/RecActionApi.cs index 86234fe..b1025f6 100644 --- a/src/ReC.Client/Api/RecActionApi.cs +++ b/src/ReC.Client/Api/RecActionApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -28,7 +26,7 @@ namespace ReC.Client.Api /// The profile identifier. /// A token to cancel the operation. /// if the request succeeds; otherwise, . - public async Task InvokeRecActionAsync(int profileId, CancellationToken cancellationToken = default) + public async Task InvokeAsync(int profileId, CancellationToken cancellationToken = default) { var resp = await _http.PostAsync($"api/RecAction/invoke/{profileId}", content: null, cancellationToken); return resp.IsSuccessStatusCode; @@ -41,7 +39,7 @@ namespace ReC.Client.Api /// Optional invoked filter. /// A token to cancel the operation. /// The HTTP response message. - public Task GetRecActionsAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default) + public Task GetAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default) { var query = ReCClientHelpers.BuildQuery(("ProfileId", profileId), ("Invoked", invoked)); return _http.GetAsync($"api/RecAction{query}", cancel); @@ -54,7 +52,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateRecActionAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/RecAction", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -65,7 +63,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateRecActionAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/RecAction/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -75,7 +73,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteRecActionsAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/RecAction") { diff --git a/src/ReC.Client/Api/ResultApi.cs b/src/ReC.Client/Api/ResultApi.cs index 8ed2a1c..bf4f308 100644 --- a/src/ReC.Client/Api/ResultApi.cs +++ b/src/ReC.Client/Api/ResultApi.cs @@ -1,8 +1,6 @@ -#if NETFRAMEWORK using System.Net.Http; using System.Threading; using System.Threading.Tasks; -#endif namespace ReC.Client.Api { @@ -30,7 +28,7 @@ namespace ReC.Client.Api /// Optional profile identifier. /// A token to cancel the operation. /// The HTTP response message. - public Task GetResultsAsync(long? id = null, long? actionId = null, long? profileId = null, CancellationToken cancel = default) + public Task GetAsync(long? id = null, long? actionId = null, long? profileId = null, CancellationToken cancel = default) { var query = ReCClientHelpers.BuildQuery(("Id", id), ("ActionId", actionId), ("ProfileId", profileId)); return _http.GetAsync($"api/Result{query}", cancel); @@ -43,7 +41,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task CreateResultAsync(T procedure, CancellationToken cancel = default) + public Task CreateAsync(T procedure, CancellationToken cancel = default) => _http.PostAsync("api/Result", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -54,7 +52,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task UpdateResultAsync(long id, T procedure, CancellationToken cancel = default) + public Task UpdateAsync(long id, T procedure, CancellationToken cancel = default) => _http.PutAsync($"api/Result/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); /// @@ -64,7 +62,7 @@ namespace ReC.Client.Api /// The payload to send. /// A token to cancel the operation. /// The HTTP response message. - public Task DeleteResultsAsync(T procedure, CancellationToken cancel = default) + public Task DeleteAsync(T procedure, CancellationToken cancel = default) { var request = new HttpRequestMessage(HttpMethod.Delete, "api/Result") { diff --git a/src/ReC.Client/ReCClient.cs b/src/ReC.Client/ReCClient.cs index dc73ccf..7aa23a2 100644 --- a/src/ReC.Client/ReCClient.cs +++ b/src/ReC.Client/ReCClient.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.Net.Http; -using System.Threading.Tasks; +using ReC.Client.Api; namespace ReC.Client { @@ -23,7 +23,7 @@ namespace ReC.Client public RecActionApi RecActions { get; } /// - /// Provides access to OutRes endpoints. + /// Provides access to Result endpoints. /// public ResultApi Results { get; }