diff --git a/ttrss/ApiClient.cs b/ttrss/ApiClient.cs index 0f32e91..8f43087 100644 --- a/ttrss/ApiClient.cs +++ b/ttrss/ApiClient.cs @@ -645,23 +645,52 @@ namespace ttrss_co_client.ttrss throw new Exception("update ostensibly ok, but couldn't parse"); } } - public async Task ShareToPublished(string title, Uri url, string content, bool sanitize = true) + public async Task ShareToPublished(string title, Uri url, string content, bool sanitize = true) { + if(url == null) + { + throw new ArgumentNullException("url"); + } assertInitialized(); assertApiLevel(4); if (!sanitize) assertApiLevel(20); - throw new NotImplementedException(); + + + var json = JsonContent.Create(new + { + op = "shareToPublished", + sid = this.SessionId, + title =title, + url = url.ToString(), + content = content, + sanitize = sanitize + }); + + var apiResponse = await get>(json); + + return apiResponse.ContainsKey("status") && apiResponse["status"]?.ToLower() == "ok"; } - /// - ///if the feed requires basic HTTP auth; the login. (decidedly not self-explanatory, gdi) - ///if the feed requires basic HTTP auth; the password. (decidedly not self-explanatory, gdi) - /// - public async Task SubscribeToFeed(Uri feed_url, int category_id, string login, string password) + ///0 = uncategorized + ///probably if the feed requires basic HTTP auth; the login? (decidedly not self-explanatory, gdi) + ///probably if the feed requires basic HTTP auth; the password? (decidedly not self-explanatory, gdi) + ///¯\_(ツ)_/¯ - code 1 = success, I think? - the documentation says "See subscribe_to_feed() in functions.php for details" - that function doesn't exist (as of 2023-04-04). + public async Task SubscribeToFeed(Uri feed_url, int category_id =0, string login=null, string password=null) { assertInitialized(); assertApiLevel(5); - throw new NotImplementedException(); + + var json = JsonContent.Create(new + { + op = "subscribeToFeed", + sid = this.SessionId, + feed_url = feed_url.ToString(), + category_id = category_id, + login = login, + password = password + }); + var apiResponse = await get>>(json); + return apiResponse["status"]["code"]; } public async Task UnsubscribeFeed() {