diff options
| author | Jake Mannens <jake@asger.xyz> | 2026-05-13 00:47:55 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2026-05-13 00:47:55 +1000 |
| commit | 532b46dfe288e31607f0362626d6b7b81b3c2948 (patch) | |
| tree | c27b4ee076642cb5dd97eb5fb788977a22d7d419 | |
| parent | 477c6c7a4f2ccb2123a89dce1cc51db2dc643833 (diff) | |
v0.16av0.16a
| -rw-r--r-- | ApiClient.csproj | 4 | ||||
| -rw-r--r-- | Feed.cs | 63 | ||||
| -rw-r--r-- | HyperBooru.cs | 2 |
3 files changed, 67 insertions, 2 deletions
diff --git a/ApiClient.csproj b/ApiClient.csproj index b6f9619..6fec3e0 100644 --- a/ApiClient.csproj +++ b/ApiClient.csproj @@ -7,9 +7,9 @@ <AssemblyName>HyperBooru.ApiClient</AssemblyName> <AssemblyTitle>HyperBooru.ApiClient</AssemblyTitle> <RootNamespace>HyperBooru.ApiClient</RootNamespace> - <AssemblyVersion>0.15.0.0</AssemblyVersion> + <AssemblyVersion>0.16.0.0</AssemblyVersion> <FileVersion>$(AssemblyVersion)</FileVersion> - <Version>0.15-alpha</Version> + <Version>0.16-alpha</Version> </PropertyGroup> <ItemGroup> @@ -0,0 +1,63 @@ +using HyperBooru.ApiModels; +using System.Net.Http.Json; + +namespace HyperBooru.ApiClient; + +public class Feed { + private HBSession session; + + internal Feed(HBSession session) => + this.session = session; + + public async Task<Guid[]> LoadChunkAsync( + bool selectIngest = false, + bool includeNsfw = false, + int count = 50, + SortOrder sortOrder = SortOrder.ObjectId, + Guid? continuationToken = null + ) => await LoadChunkAsync(new FeedRequest { + SelectIngest = selectIngest, + IncludeNsfw = includeNsfw, + Count = count, + SortOrder = sortOrder, + ContinuationToken = continuationToken + }); + + public async Task<Guid[]> LoadChunkAsync( + Guid tagId, + bool selectIngest = false, + bool includeNsfw = false, + int count = 50, + SortOrder sortOrder = SortOrder.ObjectId, + Guid? continuationToken = null + ) => await LoadChunkAsync(new FeedTagRequest { + SelectIngest = selectIngest, + IncludeNsfw = includeNsfw, + Count = count, + SortOrder = sortOrder, + ContinuationToken = continuationToken, + TagId = tagId + }); + + public async Task<Guid[]> LoadChunkAsync( + string query, + bool selectIngest = false, + bool includeNsfw = false, + int count = 50, + SortOrder sortOrder = SortOrder.ObjectId, + Guid? continuationToken = null + ) => await LoadChunkAsync(new FeedSearchRequest { + SelectIngest = selectIngest, + IncludeNsfw = includeNsfw, + Count = count, + SortOrder = sortOrder, + ContinuationToken = continuationToken, + Query = query + }); + + public async Task<Guid[]> LoadChunkAsync(FeedRequest feedRequest) { + var response = await session.HttpClient.PostAsJsonAsync("/api/feed", feedRequest); + + return (await response.Content.ReadFromJsonAsync<Guid[]>())!; + } +} diff --git a/HyperBooru.cs b/HyperBooru.cs index 4c41d96..b07351d 100644 --- a/HyperBooru.cs +++ b/HyperBooru.cs @@ -7,6 +7,7 @@ namespace HyperBooru.ApiClient; public sealed class HBSession : IDisposable { public Media Media { get; private init; } public Tag Tag { get; private init; } + public Feed Feed { get; private init; } public User User { get; private init; } public Uri BaseUri { get; private init; } @@ -36,6 +37,7 @@ public sealed class HBSession : IDisposable { Media = new(this); Tag = new(this); + Feed = new(this); User = new(this); } |
