a few untested methods
This commit is contained in:
parent
46d1aada59
commit
364bde427f
12
Program.cs
12
Program.cs
@ -17,17 +17,7 @@ namespace ttrss_co_client
|
|||||||
var apiLevel = await ttrssClient.GetApiLevel();
|
var apiLevel = await ttrssClient.GetApiLevel();
|
||||||
Console.WriteLine($"api level: {apiLevel}");
|
Console.WriteLine($"api level: {apiLevel}");
|
||||||
|
|
||||||
var cats = await ttrssClient.GetCategories(include_empty: true);
|
|
||||||
Console.WriteLine($"{cats.Count()} categor{(cats.Count() == 1 ? "y" : "ies")} found");
|
|
||||||
var firstUnread = cats.FirstOrDefault(f => f.unread > 0);
|
|
||||||
if(firstUnread != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"first unread: {firstUnread.title} (id {firstUnread.id})");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("no categories with feeds with unread articles.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var loggedout = await ttrssClient.Logout();
|
var loggedout = await ttrssClient.Logout();
|
||||||
Console.WriteLine($"logged out: {loggedout}");
|
Console.WriteLine($"logged out: {loggedout}");
|
||||||
|
@ -155,7 +155,6 @@ namespace ttrss_co_client.ttrss
|
|||||||
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
|
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
|
||||||
var apiResult = JsonConvert.DeserializeObject<ApiResponse<IEnumerable<Category>>>(response);
|
var apiResult = JsonConvert.DeserializeObject<ApiResponse<IEnumerable<Category>>>(response);
|
||||||
return apiResult.Content;
|
return apiResult.Content;
|
||||||
|
|
||||||
}
|
}
|
||||||
public enum VIEWMODE { All, Unread, Adaptive, Marked, Updated }
|
public enum VIEWMODE { All, Unread, Adaptive, Marked, Updated }
|
||||||
public enum SORTORDER { Default, OldestFirst, NewestFirst }
|
public enum SORTORDER { Default, OldestFirst, NewestFirst }
|
||||||
@ -300,7 +299,8 @@ namespace ttrss_co_client.ttrss
|
|||||||
var apiResult = JsonConvert.DeserializeObject<ApiResponse<IEnumerable<Headline>>>(response);
|
var apiResult = JsonConvert.DeserializeObject<ApiResponse<IEnumerable<Headline>>>(response);
|
||||||
return apiResult.Content;
|
return apiResult.Content;
|
||||||
}
|
}
|
||||||
// public async Task<HeadlinesHeaderResponse> GetHeadlinesAndHeader(
|
#region Get headlines include_header=true
|
||||||
|
// public async Task<Tuple<ttrss.messages.HeadlinesHeaderResponse, IEnumerable<Headline>>> GetHeadlinesAndHeader(
|
||||||
// int feed_id,
|
// int feed_id,
|
||||||
// bool is_cat,
|
// bool is_cat,
|
||||||
// int limit=60,
|
// int limit=60,
|
||||||
@ -418,25 +418,63 @@ namespace ttrss_co_client.ttrss
|
|||||||
// });
|
// });
|
||||||
// return await getHeadlinesAndHeader(json);
|
// return await getHeadlinesAndHeader(json);
|
||||||
// }
|
// }
|
||||||
// private async Task<HeadlinesHeaderResponse> getHeadlinesAndHeader(JsonContent parameters)
|
|
||||||
|
//todo: deserialize array of disparate types. can that be done?
|
||||||
|
// private async Task<Tuple<ttrss.messages.HeadlinesHeaderResponse, IEnumerable<Headline>>> getHeadlinesAndHeader(JsonContent parameters)
|
||||||
// {
|
// {
|
||||||
// var response = await (await httpClient.PostAsync(BaseURI, parameters)).Content.ReadAsStringAsync();
|
// var response = await (await httpClient.PostAsync(BaseURI, parameters)).Content.ReadAsStringAsync();
|
||||||
// var apiResult = JsonConvert.DeserializeObject<ttrss.messages.HeadlinesHeaderResponse>(response);
|
// var immediateApiResult = JsonConvert.DeserializeObject<ApiResponse<IEnumerable<string>>>(response).Content.ToList();
|
||||||
|
// var apiResult = JsonConvert.DeserializeObject<Tuple<ttrss.messages.HeadlinesHeaderResponse, IEnumerable<Headline>>>(immediateApiResult[1]);
|
||||||
// return apiResult;
|
// return apiResult;
|
||||||
// }
|
// }
|
||||||
public enum UPDATEMODE { SetFalse, SetTrue, Toggle }
|
#endregion
|
||||||
public enum UPDATEFIELD { starred, published, unread }
|
public enum UPDATEMODE { SetFalse=0, SetTrue=1, Toggle=2 }
|
||||||
|
///<summary>to update note, see <see cref="UpdateArticleNote"/></summary>
|
||||||
|
public enum UPDATEFIELD { starred=0, published=1, unread=2 }
|
||||||
public async Task<int> UpdateArticleField(UPDATEMODE mode, UPDATEFIELD field, params int[] ids)
|
public async Task<int> UpdateArticleField(UPDATEMODE mode, UPDATEFIELD field, params int[] ids)
|
||||||
{
|
{
|
||||||
|
if(ids == null || ids.Length == 0)
|
||||||
|
{
|
||||||
|
throw new System.ArgumentNullException("ids", "need to specify at least one id");
|
||||||
|
}
|
||||||
//documentation: UpdateArticle - for note, we have a separate method UpdateArticleNote
|
//documentation: UpdateArticle - for note, we have a separate method UpdateArticleNote
|
||||||
assertInitialized();
|
assertInitialized();
|
||||||
|
|
||||||
|
var json = JsonContent.Create(new
|
||||||
|
{
|
||||||
|
op = "updateArticle",
|
||||||
|
sid = this.SessionId,
|
||||||
|
article_ids = string.Join(',', ids),
|
||||||
|
mode = (int)mode,
|
||||||
|
field = (int)field
|
||||||
|
});
|
||||||
|
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
|
||||||
|
var apiResult = JsonConvert.DeserializeObject<ApiResponse<ArticleUpdateFieldResponse>>(response);
|
||||||
|
return apiResult.Content.updated;
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
///<summary>for fields other than note, we have a separate method UpdateArticleField</summary>
|
||||||
public async Task<int> UpdateArticleNote(string data, params int[] ids)
|
public async Task<int> UpdateArticleNote(string data, params int[] ids)
|
||||||
{
|
{
|
||||||
//documentation: UpdateArticle - for fields other than note, we have a separate method UpdateArticleField
|
if(ids == null || ids.Length == 0)
|
||||||
|
{
|
||||||
|
throw new System.ArgumentNullException("ids", "need to specify at least one id");
|
||||||
|
}
|
||||||
|
//documentation: UpdateArticle - for note, we have a separate method UpdateArticleNote
|
||||||
assertInitialized();
|
assertInitialized();
|
||||||
throw new NotImplementedException();
|
|
||||||
|
var json = JsonContent.Create(new
|
||||||
|
{
|
||||||
|
op = "updateArticle",
|
||||||
|
sid = this.SessionId,
|
||||||
|
article_ids = string.Join(',', ids),
|
||||||
|
field = 3,
|
||||||
|
data = data,
|
||||||
|
});
|
||||||
|
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
|
||||||
|
var apiResult = JsonConvert.DeserializeObject<ApiResponse<ArticleUpdateFieldResponse>>(response);
|
||||||
|
return apiResult.Content.updated;
|
||||||
}
|
}
|
||||||
public async Task<IEnumerable<object>> GetArticle(params int[] article_id)
|
public async Task<IEnumerable<object>> GetArticle(params int[] article_id)
|
||||||
{
|
{
|
||||||
|
10
ttrss/messages/ArticleUpdateFieldResponse.cs
Normal file
10
ttrss/messages/ArticleUpdateFieldResponse.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using ttrss_co_client.ttrss.datastructures;
|
||||||
|
|
||||||
|
namespace ttrss_co_client.ttrss.messages
|
||||||
|
{
|
||||||
|
public class ArticleUpdateFieldResponse
|
||||||
|
{
|
||||||
|
public string status {get;set;}
|
||||||
|
public int updated { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ using ttrss_co_client.ttrss.datastructures;
|
|||||||
|
|
||||||
namespace ttrss_co_client.ttrss.messages
|
namespace ttrss_co_client.ttrss.messages
|
||||||
{
|
{
|
||||||
public class HeadlinesHeaderContent
|
public class HeadlinesHeaderResponse
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public int first_id { get; set; }
|
public int first_id { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user