native amount/offset handling
This commit is contained in:
@@ -14,6 +14,15 @@ public abstract class BaseChildItemClient<T>(IApiClient client) : BaseClient<T>(
|
||||
return (await client.SendRequest<GeneralItemMessages<T>.Items>($"{ApiEndpointParent}/{parentId}{ApiEndpointChild}", HttpMethod.Get)).EnsureOk().Items;
|
||||
}
|
||||
|
||||
public virtual async Task<IEnumerable<T>> GetAll(int parentId, int offset, int count)
|
||||
{
|
||||
return (await client.SendRequest<GeneralItemMessages<T>.Items>(ApiEndpoint, HttpMethod.Get, new ApiParameterCollection
|
||||
{
|
||||
["offset"] = offset,
|
||||
["count"] = count,
|
||||
})).EnsureOk().Items;
|
||||
}
|
||||
|
||||
public override async Task<T> Save(T item)
|
||||
{
|
||||
if (item.Id == 0)
|
||||
|
||||
@@ -12,6 +12,15 @@ public abstract class BaseClient<T>(IApiClient client) : IBaseClient<T> where T
|
||||
return (await client.SendRequest<GeneralItemMessages<T>.Items>(ApiEndpoint, HttpMethod.Get)).EnsureOk().Items;
|
||||
}
|
||||
|
||||
public virtual async Task<IEnumerable<T>> GetAll(int offset, int amount)
|
||||
{
|
||||
return (await client.SendRequest<GeneralItemMessages<T>.Items>(ApiEndpoint, HttpMethod.Get, new ApiParameterCollection
|
||||
{
|
||||
["offset"] = offset,
|
||||
["amount"] = amount,
|
||||
})).EnsureOk().Items;
|
||||
}
|
||||
|
||||
public virtual async Task<T> Get(int id)
|
||||
{
|
||||
return (await client.SendRequest<GeneralItemMessages<T>.Item>($"{ApiEndpoint}/{id}", HttpMethod.Get)).EnsureOk().Item;
|
||||
|
||||
@@ -5,5 +5,6 @@ namespace Pilz.Net.Api.Client;
|
||||
public interface IBaseChildItemClient<T> : IBaseClient<T> where T : IDataObject
|
||||
{
|
||||
Task<IEnumerable<T>> GetAll(int parentId);
|
||||
Task<IEnumerable<T>> GetAll(int parentId, int offset, int count);
|
||||
Task<T> Save(T item, int parentId);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ public interface IBaseClient<T> where T : IDataObject
|
||||
Task Delete(int id);
|
||||
Task<T> Get(int id);
|
||||
Task<IEnumerable<T>> GetAll();
|
||||
Task<IEnumerable<T>> GetAll(int offset, int amount);
|
||||
Task<T> Save(T item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user