runs. generic API response. getApiLevel works.

This commit is contained in:
Adam R Grey 2023-04-03 00:10:07 -04:00
parent 7cc8155b5b
commit 290092df5a
7 changed files with 102 additions and 12 deletions

26
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net7.0/ttrss-co-client.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/ttrss-co-client.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/ttrss-co-client.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/ttrss-co-client.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -9,7 +9,8 @@ namespace ttrss_co_client
var conf = Configure();
var ttrssClient = new ttrss.ApiClient(conf.BaseURI);
await ttrssClient.Login(conf.Username, conf.Password);
Console.WriteLine("Hello, World!");
var apiLevel = await ttrssClient.GetApiLevel();
Console.WriteLine(apiLevel);
}
static Configuration Configure(string configurationPath = "appsettings.json")
{

View File

@ -1,2 +1,5 @@
# ttrss-co-pilot
wait i wanted to call it ttrss-co-client, dammit
but that name isn't good anyway

View File

@ -45,13 +45,19 @@ namespace ttrss_co_client.ttrss
public async Task<int> GetApiLevel()
{
assertInitialized();
throw new NotImplementedException();
}
public async Task<string> GetVersion()
{
assertInitialized();
throw new NotImplementedException();
var json =JsonContent.Create(new
{
op = "getApiLevel",
sid = this.SessionId
});
var response = await (await httpClient.PostAsync(BaseURI, json)).Content.ReadAsStringAsync();
var apiResult = JsonConvert.DeserializeObject<ttrss.messages.GenericApiResponse>(response);
int level = 0;
if(int.TryParse(apiResult.Content["level"], out level))
return level;
else
return 0;
}
public async Task<bool> Logout()
@ -81,11 +87,11 @@ namespace ttrss_co_client.ttrss
}
public enum VIEWMODE { All, Unread, Adaptive, Marked, Updated }
public enum SORTORDER { Default, OldestFirst, NewestFirst }
public async Task GetHeadlines(int feed_id, int limit, int skip, /*string filter, */ bool is_cat, bool show_excerpt, bool show_content, VIEWMODE view_mode, bool include_attachments, int since_id, bool include_nested, SORTORDER order_by, bool sanitize, bool force_update = false, bool has_sandbox = false, bool include_header)
public async Task GetHeadlines(int feed_id, int limit, int skip, /*string filter, */ bool is_cat, bool show_excerpt, bool show_content, VIEWMODE view_mode, bool include_attachments, int since_id, bool include_nested, SORTORDER order_by, bool sanitize, bool force_update = false, bool has_sandbox = false, bool include_header = false)
{
await getHeadlines(feed_id, null, limit, skip, /*filter, */ is_cat, show_excerpt, show_content, view_mode, include_attachments, since_id, include_nested, order_by, sanitize, force_update, has_sandbox, include_header);
}
public async Task GetHeadlines(string feed_id, int limit, int skip, /*string filter, */ bool is_cat, bool show_excerpt, bool show_content, VIEWMODE view_mode, bool include_attachments, int since_id, bool include_nested, SORTORDER order_by, bool sanitize, bool force_update = false, bool has_sandbox = false, bool include_header)
public async Task GetHeadlines(string feed_id, int limit, int skip, /*string filter, */ bool is_cat, bool show_excerpt, bool show_content, VIEWMODE view_mode, bool include_attachments, int since_id, bool include_nested, SORTORDER order_by, bool sanitize, bool force_update = false, bool has_sandbox = false, bool include_header = false)
{
await getHeadlines(null, feed_id, limit, skip, /*filter, */ is_cat, show_excerpt, show_content, view_mode, include_attachments, since_id, include_nested, order_by, sanitize, force_update, has_sandbox, include_header);
}

View File

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace ttrss_co_client.ttrss.messages
{
public abstract class ApiResponse
{
public int seq { get; set; }
public int status { get; set; }
}
public class GenericApiResponse : ApiResponse
{
public Dictionary<string, string> Content{get; set;}
}
}

View File

@ -1,9 +1,7 @@
namespace ttrss_co_client.ttrss.messages
{
public class LoginResponse
public class LoginResponse : ApiResponse
{
public int seq { get; set; }
public int status { get; set; }
public Content content { get; set; }
public class Content