Add ReCClientOptions for configurable client behavior
Introduced a new `ReCClientOptions` property to `BaseCrudApi` and its derived classes to enhance flexibility and control over client behavior. Updated constructors to accept an optional `ReCClientOptions` parameter, with default options applied when omitted. Modified `CreateAsync`, `UpdateAsync`, and other methods in `BaseCrudApi` to utilize the `Options.LogSuccessfulRequests` property for more granular logging control. Updated derived API classes (`CommonApi`, `EndpointAuthApi`, `EndpointParamsApi`, `EndpointsApi`, `ProfileApi`, `RecActionApi`, and `ResultApi`) to pass the `options` parameter to the base constructor. Ensured compatibility with both `NETFRAMEWORK` and other frameworks by using nullable annotations where applicable. These changes improve the extensibility and maintainability of the API client.
This commit is contained in:
@@ -15,10 +15,11 @@ namespace ReC.Client.Api
|
||||
/// </summary>
|
||||
/// <param name="http">The HTTP client used for requests.</param>
|
||||
/// <param name="logger">An optional logger used to record API call outcomes.</param>
|
||||
/// <param name="options">An optional set of client options. Defaults are used when omitted.</param>
|
||||
#if NETFRAMEWORK
|
||||
public RecActionApi(HttpClient http, ILogger logger = null) : base(http, "api/RecAction", logger)
|
||||
public RecActionApi(HttpClient http, ILogger logger = null, ReCClientOptions options = null) : base(http, "api/RecAction", logger, options)
|
||||
#else
|
||||
public RecActionApi(HttpClient http, ILogger? logger = null) : base(http, "api/RecAction", logger)
|
||||
public RecActionApi(HttpClient http, ILogger? logger = null, ReCClientOptions? options = null) : base(http, "api/RecAction", logger, options)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
@@ -36,7 +37,7 @@ namespace ReC.Client.Api
|
||||
using (content)
|
||||
using (var resp = await Http.PostAsync($"{ResourcePath}/invoke/{profileId}", content, cancellationToken))
|
||||
{
|
||||
await ReCClientHelpers.HandleResponseAsync(resp, Logger, cancellationToken).ConfigureAwait(false);
|
||||
await ReCClientHelpers.HandleResponseAsync(resp, Logger, Options.LogSuccessfulRequests, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user