re-organize Nextcloud project structure
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Client.LoginFlowV2.Ocs
|
||||
{
|
||||
public class OcsResponseLoginFlowV2
|
||||
{
|
||||
public class PollData
|
||||
{
|
||||
/// <summary>
|
||||
/// The login token that has been created for the login process.
|
||||
/// It can be used to poll the login state.
|
||||
/// </summary>
|
||||
[JsonProperty("token")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("endpoint")]
|
||||
public string? Endpoint { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("poll")]
|
||||
public PollData? Poll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The temporary login url that should be used for login.
|
||||
/// </summary>
|
||||
[JsonProperty("login")]
|
||||
public string? LoginUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Client.LoginFlowV2.Ocs
|
||||
{
|
||||
public class OcsResponseLoginFlowV2Credentials
|
||||
{
|
||||
/// <summary>
|
||||
/// The server url the login credentials are for.
|
||||
/// </summary>
|
||||
[JsonProperty("server")]
|
||||
public string? Server { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The login name (username or password) used for the login.
|
||||
/// </summary>
|
||||
[JsonProperty("loginName")]
|
||||
public string? LoginName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app password that has been generated.
|
||||
/// </summary>
|
||||
[JsonProperty("appPassword")]
|
||||
public string? AppPassword { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Client.LoginFlowV2.Ocs;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Client.LoginFlowV2
|
||||
{
|
||||
public class OcsApiLoginFlowV2 : OcsApiBase
|
||||
{
|
||||
private const string OCS_LOGIN_INIT = "/index.php/login/v2";
|
||||
|
||||
public OcsApiLoginFlowV2(OcsApi manager) : base(manager)
|
||||
{
|
||||
}
|
||||
|
||||
public OcsResponseLoginFlowV2? Init(string url)
|
||||
{
|
||||
return Manager.MakeRequest<OcsResponseLoginFlowV2>(HttpMethod.Get, url + OCS_LOGIN_INIT);
|
||||
}
|
||||
|
||||
public OcsResponseLoginFlowV2Credentials? Poll(OcsResponseLoginFlowV2.PollData poll)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(poll?.Endpoint);
|
||||
ArgumentNullException.ThrowIfNull(poll?.Token);
|
||||
|
||||
return Manager.MakeRequest<OcsResponseLoginFlowV2Credentials?>(HttpMethod.Get, poll.Endpoint,
|
||||
parameters: new Dictionary<string, string>
|
||||
{
|
||||
{ "token", poll.Token }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user