From 5b5b034e7865813a52d08bae10636b6d4d1ad899 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 11:30:30 +0100 Subject: [PATCH] Add EndpointAuthApi for endpoint authentication operations Introduced the EndpointAuthApi class in ReC.Client.Api to handle endpoint authentication API interactions. This class provides async methods for creating, updating, and deleting endpoint authentication configurations using HttpClient, with support for cancellation tokens and JSON payload serialization. XML documentation is included for clarity. --- src/ReC.Client/Api/EndpointAuthApi.cs | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/ReC.Client/Api/EndpointAuthApi.cs diff --git a/src/ReC.Client/Api/EndpointAuthApi.cs b/src/ReC.Client/Api/EndpointAuthApi.cs new file mode 100644 index 0000000..d93cf39 --- /dev/null +++ b/src/ReC.Client/Api/EndpointAuthApi.cs @@ -0,0 +1,60 @@ +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace ReC.Client.Api +{ + /// + /// Provides access to endpoint authentication endpoints. + /// + public class EndpointAuthApi + { + private readonly HttpClient _http; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client used for requests. + public EndpointAuthApi(HttpClient http) + { + _http = http; + } + + /// + /// Creates endpoint authentication configuration. + /// + /// The payload type. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task CreateEndpointAuthAsync(T procedure, CancellationToken cancel = default) + => _http.PostAsync("api/EndpointAuth", ReCClientHelpers.ToJsonContent(procedure), cancel); + + /// + /// Updates endpoint authentication configuration. + /// + /// The payload type. + /// The authentication identifier. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task UpdateEndpointAuthAsync(long id, T procedure, CancellationToken cancel = default) + => _http.PutAsync($"api/EndpointAuth/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); + + /// + /// Deletes endpoint authentications. + /// + /// The payload type containing identifiers. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task DeleteEndpointAuthAsync(T procedure, CancellationToken cancel = default) + { + var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointAuth") + { + Content = ReCClientHelpers.ToJsonContent(procedure) + }; + return _http.SendAsync(request, cancel); + } + } +}