introduce a very simple Nextcloud API

This commit is contained in:
2023-09-27 14:12:55 +02:00
parent 7ea59cddb1
commit 2c28feacb5
23 changed files with 927 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.LoginFlowV2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs
{
public class OcsApiLoginFlowV2 : OcsApiBase
{
private const string OCS_LOGIN_INIT = "/index.php/login/v2";
public OcsApiLoginFlowV2(OcsApi manager) : base(manager)
{
}
public Task<OcsResponseLoginFlowV2?> Init(string url)
{
return Manager.MakeRequestJson<OcsResponseLoginFlowV2>(HttpMethod.Get, url + OCS_LOGIN_INIT);
}
public Task<OcsResponseLoginFlowV2Credentials?> Poll(OcsResponseLoginFlowV2.PollData poll)
{
ArgumentNullException.ThrowIfNull(poll?.Endpoint);
ArgumentNullException.ThrowIfNull(poll?.Token);
return Manager.MakeRequestJson<OcsResponseLoginFlowV2Credentials?>(HttpMethod.Get, poll.Endpoint,
parameters: new Dictionary<string, string>
{
{ "token", poll.Token }
});
}
}
}