2022-10-06 23:54:44 +02:00
|
|
|
using Flurl.Http.Content;
|
|
|
|
|
|
|
|
namespace Piwigo.Client;
|
|
|
|
|
|
|
|
internal static class PiwigoMethods
|
|
|
|
{
|
2022-10-08 00:08:48 +02:00
|
|
|
public static void PiwigoLogin(this CapturedMultipartContent part, string username,
|
2022-10-06 23:54:44 +02:00
|
|
|
string password)
|
|
|
|
{
|
2022-10-08 00:08:48 +02:00
|
|
|
part.AddMethod("pwg.session.login").AddString("username", username).AddString("password", password);
|
2022-10-06 23:54:44 +02:00
|
|
|
}
|
|
|
|
|
2022-10-08 00:08:48 +02:00
|
|
|
public static void PiwigoLogout(this CapturedMultipartContent part)
|
2022-10-06 23:54:44 +02:00
|
|
|
{
|
2022-10-08 00:08:48 +02:00
|
|
|
part.AddMethod("pwg.session.logout");
|
2022-10-06 23:54:44 +02:00
|
|
|
}
|
2022-10-07 13:43:19 +02:00
|
|
|
|
2022-10-08 00:08:48 +02:00
|
|
|
public static void PiwigoGetStatus(this CapturedMultipartContent part)
|
2022-10-07 13:43:19 +02:00
|
|
|
{
|
2022-10-08 00:08:48 +02:00
|
|
|
part.AddMethod("pwg.session.getStatus");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void PiwigoGetAllCategories(this CapturedMultipartContent part, bool recursive = true)
|
|
|
|
{
|
|
|
|
part.AddMethod("pwg.categories.getList").AddString("recursive", recursive.ToString());
|
2022-10-07 13:43:19 +02:00
|
|
|
}
|
2022-10-07 23:11:28 +02:00
|
|
|
|
|
|
|
private static CapturedMultipartContent AddMethod(this CapturedMultipartContent part, string piwigoMethod)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(piwigoMethod))
|
|
|
|
{
|
|
|
|
throw new ArgumentException("Value cannot be null or whitespace.", nameof(piwigoMethod));
|
|
|
|
}
|
|
|
|
|
|
|
|
return part.AddString("method", piwigoMethod);
|
|
|
|
}
|
2022-10-06 23:54:44 +02:00
|
|
|
}
|