feat(ClientOptions): add QueryStrings-property.
- add logic to handle global query strings on EConnectClient
This commit is contained in:
parent
a7cbced3e6
commit
dd60555ed3
@ -7,4 +7,6 @@ public class ClientOptions
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
public TimeSpan? Timeout { get; set; }
|
||||
|
||||
public Dictionary<string, string?>? QueryStrings { get; set; }
|
||||
}
|
||||
@ -23,6 +23,11 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
||||
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||
where TData : class
|
||||
{
|
||||
// add global query strings
|
||||
if (_options.QueryStrings is not null)
|
||||
route = route.AddQueryString(_options.QueryStrings);
|
||||
|
||||
// add query strings
|
||||
if (queryParams is not null)
|
||||
route = route.AddQueryString(queryParams.ToPropertyDictionary());
|
||||
|
||||
@ -43,6 +48,11 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
||||
public async Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||
where TData : class
|
||||
{
|
||||
// add global query strings
|
||||
if (_options.QueryStrings is not null)
|
||||
route = route.AddQueryString(_options.QueryStrings);
|
||||
|
||||
// add query strings
|
||||
if (queryParams is not null)
|
||||
route = route.AddQueryString(queryParams.ToPropertyDictionary());
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ public static class ObjectExtensions
|
||||
prop => prop.GetValue(obj).ToSafeString()
|
||||
);
|
||||
}
|
||||
|
||||
public static Dictionary<string, string?> ToPropertyDictionary(this Dictionary<string, object?> obj)
|
||||
{
|
||||
return obj
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user