From 6d63d51a577124e3dec05aaff88dcf42ae5f9487 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Tue, 4 Apr 2023 12:46:30 -0400 Subject: [PATCH] udpate feed and get pref i think. i don't know any prefs to check. --- ttrss/ApiClient.cs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ttrss/ApiClient.cs b/ttrss/ApiClient.cs index 6d03a37..512d6b0 100644 --- a/ttrss/ApiClient.cs +++ b/ttrss/ApiClient.cs @@ -505,15 +505,44 @@ namespace ttrss_co_client.ttrss /// ///tell the feed to update. As opposed to updating our configuration of the feed. /// - public async Task UpdateFeed(int feed_id) + public async Task UpdateFeed(int feed_id) { assertInitialized(); - throw new NotImplementedException(); + + var json = JsonContent.Create(new + { + op = "updateFeed", + sid = this.SessionId, + feed_id = feed_id + }); + var apiResponse = await get>(json); + + return apiResponse.ContainsKey("status") && apiResponse["status"]?.ToLower() == "ok"; } - public async Task GetPref(string key) + public async Task GetPref(string pref) { assertInitialized(); - throw new NotImplementedException(); + + var json = JsonContent.Create(new + { + op = "getPref", + sid = this.SessionId, + pref_name = pref + }); + var apiResponse = await get>(json); + try + { + var converter = TypeDescriptor.GetConverter(typeof(T)); + if (converter != null) + { + return (T)converter.ConvertFromString(apiResponse["value"]); + } + return default(T); + } + catch (NotSupportedException) + { + return default(T); + } } public enum CATCHUPMODE { All, OneDay, OneWeek, TwoWeeks } public async Task CatchupFeed(int feed_id, bool is_cat, CATCHUPMODE mode = CATCHUPMODE.All)