GetCounters - but doesn't seem to work (at least in my installation)
This commit is contained in:
parent
1480efdd82
commit
5797e4f415
@ -16,8 +16,8 @@ namespace ttrss_co_client
|
||||
var apiLevel = await ttrssClient.GetApiLevel();
|
||||
Console.WriteLine($"api level: {apiLevel}");
|
||||
|
||||
var unread = await ttrssClient.GetUnread();
|
||||
Console.WriteLine($"{unread} unread article{(unread == 1 ? "" : "s")}");
|
||||
var counters = await ttrssClient.GetCounters(true, false, false, false);
|
||||
Console.WriteLine($"{counters.Count()} counter{(counters.Count() == 1 ? "" : "s")} found");
|
||||
|
||||
var loggedout = await ttrssClient.Logout();
|
||||
Console.WriteLine($"logged out: {loggedout}");
|
||||
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using ttrss_co_client.ttrss.datastructures;
|
||||
|
||||
// https://tt-rss.org/wiki/ApiReference
|
||||
|
||||
@ -66,6 +67,28 @@ namespace ttrss_co_client.ttrss
|
||||
return await oneValueGet<int>("getUnread", "unread");
|
||||
}
|
||||
|
||||
///<summary>at least in my installation, it doesn't seem to respect the parameters I give it, be it curl or here.</summary>
|
||||
public async Task<IEnumerable<CounterInfo>> GetCounters(bool feeds = true, bool labels = true, bool categories = true, bool tags = false)
|
||||
{
|
||||
assertInitialized();
|
||||
assertApiLevel(4);
|
||||
|
||||
var output_mode = "";
|
||||
if (feeds) output_mode += "f";
|
||||
if (labels) output_mode += "l";
|
||||
if (categories) output_mode += "c";
|
||||
if (tags) output_mode += "t";
|
||||
|
||||
var json = JsonContent.Create(new
|
||||
{
|
||||
op = "getCounters",
|
||||
sid = this.SessionId,
|
||||
output_mode = output_mode
|
||||
});
|
||||
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
|
||||
var apiResult = JsonConvert.DeserializeObject<ttrss.messages.CounterInfoResponse>(response);
|
||||
return apiResult.content;
|
||||
}
|
||||
public async Task GetFeeds(int cat_id, bool unread_only, int limit, int offset, bool include_nested)
|
||||
{
|
||||
assertInitialized();
|
||||
@ -138,11 +161,6 @@ namespace ttrss_co_client.ttrss
|
||||
assertInitialized();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public async Task GetCounters(bool actual_feeds = true, bool labels = true, bool categories = true, bool tags = false)
|
||||
{
|
||||
assertInitialized();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public async Task GetLabels(int? article_id)
|
||||
{
|
||||
assertInitialized();
|
||||
@ -206,8 +224,8 @@ namespace ttrss_co_client.ttrss
|
||||
|
||||
private async Task<T> oneValueGet<T>(string op, string key)
|
||||
{
|
||||
//mostly you post {"op": "aThingToDo", "sid": "sessionId", "some other param": "some other value"}
|
||||
//and get back something like {"seq": 0, "status", "content": {"the value you asked for": 0}}
|
||||
//mostly you post {"op": "getAThing", "sid": "sessionId"}
|
||||
//and get back something like {"seq": 0, "status": 0, "content": {"the value you asked for": 0}}
|
||||
var json = JsonContent.Create(new
|
||||
{
|
||||
op = op,
|
||||
|
34
ttrss/datastructures/CounterInfo.cs
Normal file
34
ttrss/datastructures/CounterInfo.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ttrss_co_client.ttrss.datastructures
|
||||
{
|
||||
///<summary>"Counter Information" - not sure what that is</summary>
|
||||
public class CounterInfo
|
||||
{
|
||||
//there's "global-unread", "subscribed-feeds", and the rest are ints
|
||||
public string Id { get; set; }
|
||||
public string Updated { get; set; }
|
||||
public int? Counter { get; set; }
|
||||
public int? AuxCounter { get; set; }
|
||||
public int? Markedcounter { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int? ts { get; set; }
|
||||
public DateTime? TimeStamp
|
||||
{
|
||||
get
|
||||
{
|
||||
if(ts != null)
|
||||
{
|
||||
return new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc)
|
||||
.AddSeconds( ts.Value ).ToLocalTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Error { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
9
ttrss/messages/CounterInfoResponse.cs
Normal file
9
ttrss/messages/CounterInfoResponse.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using ttrss_co_client.ttrss.datastructures;
|
||||
|
||||
namespace ttrss_co_client.ttrss.messages
|
||||
{
|
||||
public class CounterInfoResponse : ApiResponse
|
||||
{
|
||||
public IEnumerable<CounterInfo> content { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user