finish tables api
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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.Apps.Tables.Model
|
||||
{
|
||||
public class RowUpdate
|
||||
{
|
||||
[JsonProperty("data")]
|
||||
public Dictionary<long, object> Data { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Pilz.Networking.CloudProviders.Nextcloud.Ocs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -54,5 +55,15 @@ namespace Pilz.Networking.CloudProviders.Nextcloud.Client.Apps.Tables
|
||||
{
|
||||
return Manager.MakeRequest<Column>(HttpMethod.Delete, OCS_TABLES_COLUMN.FillParameters(columnId));
|
||||
}
|
||||
|
||||
public Row? UpdateRow(long rowId, RowUpdate values)
|
||||
{
|
||||
return Manager.MakeRequest<Row>(HttpMethod.Put, OCS_TABLES_ROW.FillParameters(rowId), content: values);
|
||||
}
|
||||
|
||||
public Row? CreateRow(long tableId, RowUpdate values)
|
||||
{
|
||||
return Manager.MakeRequest<Row>(HttpMethod.Post, OCS_TABLES_TABLE_ROWS.FillParameters(tableId), content: values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,5 +57,15 @@ namespace Pilz.Networking.CloudProviders.Nextcloud.Client.Apps.Tables
|
||||
{
|
||||
return Client.Ocs.GetApi<OcsApiTables>().DeleteColumn(columnId);
|
||||
}
|
||||
|
||||
public Row? UpdateRow(long rowId, RowUpdate values)
|
||||
{
|
||||
return Client.Ocs.GetApi<OcsApiTables>().UpdateRow(rowId, values);
|
||||
}
|
||||
|
||||
public Row? CreateRow(long tableId, RowUpdate values)
|
||||
{
|
||||
return Client.Ocs.GetApi<OcsApiTables>().CreateRow(tableId, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Pilz.Networking.CloudProviders.Nextcloud.Client
|
||||
{
|
||||
protected NextcloudClient Client { get; init; }
|
||||
|
||||
public ClientBase(NextcloudClient client)
|
||||
protected ClientBase(NextcloudClient client)
|
||||
{
|
||||
Client = client;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Client;
|
||||
@@ -62,6 +63,11 @@ namespace Pilz.Networking.CloudProviders.Nextcloud
|
||||
}
|
||||
|
||||
public UserInfo? Login(NextcloudLogin login)
|
||||
{
|
||||
return Login(login, true);
|
||||
}
|
||||
|
||||
public UserInfo? Login(NextcloudLogin login, bool checkUser)
|
||||
{
|
||||
// Ensure we are logged out
|
||||
Logout(false);
|
||||
@@ -69,15 +75,20 @@ namespace Pilz.Networking.CloudProviders.Nextcloud
|
||||
// Temporary set user login
|
||||
CurrentLogin = login;
|
||||
|
||||
// Try get user info & check if user is enabled
|
||||
var userInfo = Cloud.GetUserInfo();
|
||||
var isValid = userInfo != null && userInfo.Enabled;
|
||||
if (checkUser)
|
||||
{
|
||||
// Try get user info & check if user is enabled
|
||||
var userInfo = Cloud.GetUserInfo();
|
||||
var isValid = userInfo != null && userInfo.Enabled;
|
||||
|
||||
// If invalid, reset login credentials
|
||||
if (!isValid)
|
||||
CurrentLogin = null;
|
||||
// If invalid, reset login credentials
|
||||
if (!isValid)
|
||||
CurrentLogin = null;
|
||||
|
||||
return userInfo;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public NextcloudLogin? Login(string baseUrl, CancellationToken cancellationToken)
|
||||
|
||||
@@ -175,8 +175,11 @@ namespace Pilz.Networking.CloudProviders.Nextcloud.Ocs
|
||||
// Create content
|
||||
if (content is HttpContent contentHttp)
|
||||
httpContent = contentHttp;
|
||||
else if (content is OcsData)
|
||||
httpContent = new StringContent(JsonConvert.SerializeObject(content), null, CONTENT_TYPE_JSON);
|
||||
else if (content is OcsData || content is not null)
|
||||
{
|
||||
var stringContent = JsonConvert.SerializeObject(content);
|
||||
httpContent = new StringContent(stringContent, null, CONTENT_TYPE_JSON);
|
||||
}
|
||||
else
|
||||
httpContent = null;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<PropertyGroup>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<IncrementVersionOnBuild>1.yyyy.Mdd.Hmm</IncrementVersionOnBuild>
|
||||
<Version>1.2023.1002.1726</Version>
|
||||
<Version>1.2023.1003.1124</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
1
Pilz.Networking.CloudProviders.Nextcloud/README.md
Normal file
1
Pilz.Networking.CloudProviders.Nextcloud/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Nextcloud Client Api
|
||||
Reference in New Issue
Block a user