refactor(EConnectClient): queryParams-Eingabe zu get-Methoden hinzufügen
This commit is contained in:
parent
a7a16ab281
commit
087df71b7b
@ -4,8 +4,8 @@ namespace Leanetec.EConnect.Client.Interface;
|
|||||||
|
|
||||||
public interface IEConnectClient<TError> where TError : class
|
public interface IEConnectClient<TError> where TError : class
|
||||||
{
|
{
|
||||||
public Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default) where TData : class;
|
public Task<Response<TData, TError>> GetAsync<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default) where TData : class;
|
||||||
|
|
||||||
public Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, CancellationToken cancel = default)
|
public Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||||
where TData : class;
|
where TData : class;
|
||||||
}
|
}
|
||||||
@ -20,9 +20,11 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
|||||||
LazyHttp = new Lazy<HttpClient>(httpFactory.CreateEConnectClient);
|
LazyHttp = new Lazy<HttpClient>(httpFactory.CreateEConnectClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, CancellationToken cancel = default)
|
public async Task<Response<TData, TError>> GetAsync<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||||
where TData : class
|
where TData : class
|
||||||
{
|
{
|
||||||
|
route = route?.AddQueryString(queryParams?.ToPropertyDictionary());
|
||||||
|
|
||||||
var res = await Http.GetAsync(route, cancel);
|
var res = await Http.GetAsync(route, cancel);
|
||||||
|
|
||||||
if (res.IsSuccessStatusCode)
|
if (res.IsSuccessStatusCode)
|
||||||
@ -37,9 +39,11 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, CancellationToken cancel = default)
|
public async Task<Response<IAsyncEnumerable<TData?>, TError>> GetListAsAsyncEnumerable<TData>(string? route = null, object? queryParams = null, CancellationToken cancel = default)
|
||||||
where TData : class
|
where TData : class
|
||||||
{
|
{
|
||||||
|
route = route?.AddQueryString(queryParams?.ToPropertyDictionary());
|
||||||
|
|
||||||
var res = await Http.GetAsync(route, cancel);
|
var res = await Http.GetAsync(route, cancel);
|
||||||
|
|
||||||
if (res.IsSuccessStatusCode)
|
if (res.IsSuccessStatusCode)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user