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 /Feed.cs | |
| parent | 477c6c7a4f2ccb2123a89dce1cc51db2dc643833 (diff) | |
v0.16av0.16a
Diffstat (limited to 'Feed.cs')
| -rw-r--r-- | Feed.cs | 63 |
1 files changed, 63 insertions, 0 deletions
@@ -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[]>())!; + } +} |
