From 532b46dfe288e31607f0362626d6b7b81b3c2948 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Wed, 13 May 2026 00:47:55 +1000 Subject: v0.16a --- Feed.cs | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Feed.cs (limited to 'Feed.cs') diff --git a/Feed.cs b/Feed.cs new file mode 100644 index 0000000..e6492ff --- /dev/null +++ b/Feed.cs @@ -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 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 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 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 LoadChunkAsync(FeedRequest feedRequest) { + var response = await session.HttpClient.PostAsJsonAsync("/api/feed", feedRequest); + + return (await response.Content.ReadFromJsonAsync())!; + } +} -- cgit v1.3