diff --git a/src/ReC.Client/Api/BaseCrudApi.cs b/src/ReC.Client/Api/BaseCrudApi.cs index 50e2b3d..bcb33f2 100644 --- a/src/ReC.Client/Api/BaseCrudApi.cs +++ b/src/ReC.Client/Api/BaseCrudApi.cs @@ -88,7 +88,8 @@ namespace ReC.Client.Api } /// - /// Deletes resources with identifiers supplied in the payload. + /// Deletes resources with identifiers supplied in the payload. The payload is serialized into + /// the query string because the API binds delete payloads from the URL query. /// /// The payload type containing identifiers. /// The payload to send. @@ -96,11 +97,8 @@ namespace ReC.Client.Api /// Thrown when the API responds with a non-success status code. public async Task DeleteAsync(T payload, CancellationToken cancel = default) { - using (var request = new HttpRequestMessage(HttpMethod.Delete, ResourcePath) - { - Content = ReCClientHelpers.ToJsonContent(payload) - }) - using (var resp = await Http.SendAsync(request, cancel)) + var query = ReCClientHelpers.BuildQueryFromObject(payload); + using (var resp = await Http.DeleteAsync($"{ResourcePath}{query}", cancel)) { await ReCClientHelpers.HandleResponseAsync(resp, Logger, Options.LogSuccessfulRequests, cancel).ConfigureAwait(false); } diff --git a/src/ReC.Client/Api/CommonApi.cs b/src/ReC.Client/Api/CommonApi.cs index 86ddc67..e37d6e1 100644 --- a/src/ReC.Client/Api/CommonApi.cs +++ b/src/ReC.Client/Api/CommonApi.cs @@ -6,7 +6,9 @@ using Microsoft.Extensions.Logging; namespace ReC.Client.Api { /// - /// Provides access to common object endpoints. + /// Provides access to common object endpoints. The Common API binds update and delete + /// payloads from the body / query string (no id route segment), so the inherited CRUD + /// helpers from are hidden with overloads that match the API. /// public class CommonApi : BaseCrudApi { @@ -23,5 +25,23 @@ namespace ReC.Client.Api #endif { } + + /// + /// Updates an object via the Common update procedure. The identifier is expected to be + /// part of rather than the URL. + /// + /// The payload type. + /// The payload to send. + /// A token to cancel the operation. + /// Thrown when the API responds with a non-success status code. + public async Task UpdateAsync(T payload, CancellationToken cancel = default) + { + using (var content = ReCClientHelpers.ToJsonContent(payload)) + using (var resp = await Http.PutAsync(ResourcePath, content, cancel)) + { + await ReCClientHelpers.HandleResponseAsync(resp, Logger, Options.LogSuccessfulRequests, cancel).ConfigureAwait(false); + } + } } } + diff --git a/src/ReC.Client/Api/ProfileApi.cs b/src/ReC.Client/Api/ProfileApi.cs index f5f9100..b0a62be 100644 --- a/src/ReC.Client/Api/ProfileApi.cs +++ b/src/ReC.Client/Api/ProfileApi.cs @@ -25,13 +25,13 @@ namespace ReC.Client.Api } /// - /// Retrieves a profile by identifier. + /// Retrieves profiles, optionally filtered by identifier. /// - /// The profile identifier. - /// Whether to include related actions. + /// Optional profile identifier filter. When , all profiles are returned. + /// Whether to include related actions. Defaults to to match the API default. /// A token to cancel the operation. /// The HTTP response message. - public Task GetAsync(long id, bool includeActions = false, CancellationToken cancel = default) + public Task GetAsync(long? id = null, bool includeActions = true, CancellationToken cancel = default) { var query = ReCClientHelpers.BuildQuery(("Id", id), ("IncludeActions", includeActions)); return Http.GetAsync($"{ResourcePath}{query}", cancel); diff --git a/src/ReC.Client/Api/RecActionApi.cs b/src/ReC.Client/Api/RecActionApi.cs index 8d2b387..f038a90 100644 --- a/src/ReC.Client/Api/RecActionApi.cs +++ b/src/ReC.Client/Api/RecActionApi.cs @@ -25,13 +25,17 @@ namespace ReC.Client.Api } /// - /// Invokes a ReC action for the specified profile. + /// Invokes a batch of RecActions for the specified profile. /// /// The profile identifier. /// Optional reference values to pass through to all result records. /// A token to cancel the operation. /// Thrown when the API responds with a non-success status code. - public async Task InvokeAsync(int profileId, InvokeReferences references, CancellationToken cancellationToken = default) +#if NETFRAMEWORK + public async Task InvokeAsync(long profileId, InvokeReferences references = null, CancellationToken cancellationToken = default) +#else + public async Task InvokeAsync(long profileId, InvokeReferences? references = null, CancellationToken cancellationToken = default) +#endif { var content = references != null ? ReCClientHelpers.ToJsonContent(references) : null; using (content) @@ -42,13 +46,13 @@ namespace ReC.Client.Api } /// - /// Invokes a ReC action for the specified profile. + /// Invokes a batch of RecActions for the specified profile. /// /// The profile identifier. /// Batch identifier. /// A token to cancel the operation. /// Thrown when the API responds with a non-success status code. - public Task InvokeAsync(int profileId, string batchId, CancellationToken cancellationToken = default) + public Task InvokeAsync(long profileId, string batchId, CancellationToken cancellationToken = default) { return InvokeAsync(profileId, new InvokeReferences() { BatchId = batchId }, cancellationToken); } diff --git a/src/ReC.Client/Api/ResultApi.cs b/src/ReC.Client/Api/ResultApi.cs index ceb2681..1a818c3 100644 --- a/src/ReC.Client/Api/ResultApi.cs +++ b/src/ReC.Client/Api/ResultApi.cs @@ -30,11 +30,26 @@ namespace ReC.Client.Api /// Optional result identifier. /// Optional action identifier. /// Optional profile identifier. + /// Optional batch identifier. + /// Whether to include the related action. Defaults to to match the API default. + /// Whether to include the related profile. Defaults to to match the API default. + /// When , restricts results to those belonging to the most recent batch matching the other filters. /// A token to cancel the operation. /// The HTTP response message. - public Task GetAsync(long? id = null, long? actionId = null, long? profileId = null, CancellationToken cancel = default) +#if NETFRAMEWORK + public Task GetAsync(long? id = null, long? actionId = null, long? profileId = null, string batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default) +#else + public Task GetAsync(long? id = null, long? actionId = null, long? profileId = null, string? batchId = null, bool includeAction = true, bool includeProfile = false, bool lastBatch = false, CancellationToken cancel = default) +#endif { - var query = ReCClientHelpers.BuildQuery(("Id", id), ("ActionId", actionId), ("ProfileId", profileId)); + var query = ReCClientHelpers.BuildQuery( + ("Id", id), + ("ActionId", actionId), + ("ProfileId", profileId), + ("BatchId", batchId), + ("IncludeAction", includeAction), + ("IncludeProfile", includeProfile), + ("LastBatch", lastBatch)); return Http.GetAsync($"{ResourcePath}{query}", cancel); } }