From 19ecf104fa04901eebbd4d1372c9839f05e36662 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 11:30:46 +0100 Subject: [PATCH] Add EndpointParamsApi for endpoint parameter operations Introduced the EndpointParamsApi class in ReC.Client.Api to handle create, update, and delete operations for endpoint parameters via HTTP. Methods support generic payloads, cancellation tokens, and use JSON serialization helpers. Added necessary using directives for HTTP and threading. --- src/ReC.Client/Api/EndpointParamsApi.cs | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/ReC.Client/Api/EndpointParamsApi.cs diff --git a/src/ReC.Client/Api/EndpointParamsApi.cs b/src/ReC.Client/Api/EndpointParamsApi.cs new file mode 100644 index 0000000..231fcc0 --- /dev/null +++ b/src/ReC.Client/Api/EndpointParamsApi.cs @@ -0,0 +1,60 @@ +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace ReC.Client.Api +{ + /// + /// Provides access to endpoint parameter endpoints. + /// + public class EndpointParamsApi + { + private readonly HttpClient _http; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client used for requests. + public EndpointParamsApi(HttpClient http) + { + _http = http; + } + + /// + /// Creates endpoint parameters. + /// + /// The payload type. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task CreateEndpointParamsAsync(T procedure, CancellationToken cancel = default) + => _http.PostAsync("api/EndpointParams", ReCClientHelpers.ToJsonContent(procedure), cancel); + + /// + /// Updates endpoint parameters. + /// + /// The payload type. + /// The parameter identifier. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task UpdateEndpointParamsAsync(long id, T procedure, CancellationToken cancel = default) + => _http.PutAsync($"api/EndpointParams/{id}", ReCClientHelpers.ToJsonContent(procedure), cancel); + + /// + /// Deletes endpoint parameters. + /// + /// The payload type containing identifiers. + /// The payload to send. + /// A token to cancel the operation. + /// The HTTP response message. + public Task DeleteEndpointParamsAsync(T procedure, CancellationToken cancel = default) + { + var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointParams") + { + Content = ReCClientHelpers.ToJsonContent(procedure) + }; + return _http.SendAsync(request, cancel); + } + } +}