feat(work): 新增获取微盘空间信息接口

This commit is contained in:
fudiwei 2022-12-03 17:45:13 +08:00
parent b3980cd733
commit aedd92ad39
5 changed files with 161 additions and 0 deletions

View File

@ -90,6 +90,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinWebDriveSpaceInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/wedrive/new_space_info 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97950 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinWebDriveNewSpaceInfoResponse> ExecuteCgibinWebDriveNewSpaceInfoAsync(this WechatWorkClient client, Models.CgibinWebDriveNewSpaceInfoRequest request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "wedrive", "new_space_info")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinWebDriveNewSpaceInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/wedrive/space_setting 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97876 </para>

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/wedrive/new_space_info 接口的请求。</para>
/// </summary>
public class CgibinWebDriveNewSpaceInfoRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置空间 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("spaceid")]
[System.Text.Json.Serialization.JsonPropertyName("spaceid")]
public string SpaceId { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,91 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/wedrive/new_space_info 接口的响应。</para>
/// </summary>
public class CgibinWebDriveNewSpaceInfoResponse : WechatWorkResponse
{
public static class Types
{
public class Space : CgibinWebDriveSpaceInfoResponse.Types.Space
{
public static new class Types
{
public class ACL : CgibinWebDriveSpaceInfoResponse.Types.Space.Types.ACL
{
}
public class Authority : CgibinWebDriveSpaceInfoResponse.Types.Space.Types.Authority
{
}
public class SecureSettings
{
/// <summary>
/// 获取或设置是否启用水印。
/// </summary>
[Newtonsoft.Json.JsonProperty("enable_watermark")]
[System.Text.Json.Serialization.JsonPropertyName("enable_watermark")]
public bool EnableWatermark { get; set; }
/// <summary>
/// 获取或设置是否启用保密模式。
/// </summary>
[Newtonsoft.Json.JsonProperty("enable_confidential_mode")]
[System.Text.Json.Serialization.JsonPropertyName("enable_confidential_mode")]
public bool EnableConfidentialMode { get; set; }
/// <summary>
/// 获取或设置是否通过链接加入空间无需审批。
/// </summary>
[Newtonsoft.Json.JsonProperty("share_url_no_approve")]
[System.Text.Json.Serialization.JsonPropertyName("share_url_no_approve")]
public bool IsShareUrlNoApprove { get; set; }
/// <summary>
/// 获取或设置邀请链接默认权限类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("share_url_no_approve_default_auth")]
[System.Text.Json.Serialization.JsonPropertyName("share_url_no_approve_default_auth")]
public int ShareUrlNoApproveDefaultAuthType { get; set; }
/// <summary>
/// 获取或设置文件默认可查看范围。
/// </summary>
[Newtonsoft.Json.JsonProperty("default_file_scope")]
[System.Text.Json.Serialization.JsonPropertyName("default_file_scope")]
public int DefaultFileScope { get; set; }
/// <summary>
/// 获取或设置是否禁止文件分享到企业外。
/// </summary>
[Newtonsoft.Json.JsonProperty("ban_share_external")]
[System.Text.Json.Serialization.JsonPropertyName("ban_share_external")]
public bool IsBanShareExternal { get; set; }
}
}
/// <summary>
/// 获取或设置访问控制信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("auth_list")]
[System.Text.Json.Serialization.JsonPropertyName("auth_list")]
public new Types.ACL ACL { get; set; } = default!;
/// <summary>
/// 获取或设置安全设置信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("secure_setting")]
[System.Text.Json.Serialization.JsonPropertyName("secure_setting")]
public Types.SecureSettings SecureSettings { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置空间信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("space_info")]
[System.Text.Json.Serialization.JsonPropertyName("space_info")]
public Types.Space Space { get; set; } = default!;
}
}

View File

@ -0,0 +1,32 @@
{
"errcode": 0,
"errmsg": "ok",
"space_info": {
"spaceid": "SPACEID",
"space_name": "SPACE_NAME",
"auth_list": {
"auth_info": [
{
"type": 1,
"userid": "USERID",
"auth": 1
},
{
"type": 2,
"departmentid": 1,
"auth": 7
}
],
"quit_userid": ["USERID1", "USERID2"]
},
"space_sub_type": 0,
"secure_setting": {
"enable_watermark": true,
"share_url_no_approve": true,
"share_url_no_approve_default_auth": 1,
"enable_confidential_mode": true,
"default_file_scope": 1,
"ban_share_external": false
}
}
}