30 lines
827 B
C#
30 lines
827 B
C#
using CommunityToolkit.Mvvm.DependencyInjection;
|
|
using PSCHelpdesk.Plugins.Nextcloud.Models;
|
|
using RestSharp;
|
|
using RestSharp.Authenticators;
|
|
|
|
namespace PSCHelpdesk.Plugins.Nextcloud.Api;
|
|
|
|
public class Notes
|
|
{
|
|
public Notes()
|
|
{
|
|
}
|
|
|
|
async public Task<List<Note>> GetNotes(Settings settings)
|
|
{
|
|
var notes = new List<Note>();
|
|
|
|
var client = new RestClient(settings.ServerUrl);
|
|
var request = new RestRequest("index.php/apps/notes/api/v1/notes");
|
|
request.Authenticator = new HttpBasicAuthenticator(settings.Username, settings.AppPassword);
|
|
|
|
var response = await client.ExecuteAsync<List<Note>>(request);
|
|
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
|
{
|
|
return response.Data;
|
|
}
|
|
|
|
return notes;
|
|
}
|
|
} |