diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWebDriveExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWebDriveExtensions.cs index d1f32dea..d6c3fda7 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWebDriveExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWebDriveExtensions.cs @@ -393,6 +393,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Work return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + + /// + /// 异步调用 [POST] /cgi-bin/wedrive/get_file_permission 接口。 + /// REF: https://developer.work.weixin.qq.com/document/path/97962 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinWebDriveGetFilePermissionAsync(this WechatWorkClient client, Models.CgibinWebDriveGetFilePermissionRequest 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", "get_file_permission") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } #endregion #region FileACL diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.cs new file mode 100644 index 00000000..fe6a5387 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/get_file_permission 接口的请求。 + /// + public class CgibinWebDriveGetFilePermissionRequest : WechatWorkRequest + { + /// + /// 获取或设置文件 ID。 + /// + [Newtonsoft.Json.JsonProperty("fileid")] + [System.Text.Json.Serialization.JsonPropertyName("fileid")] + public string FileId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.cs new file mode 100644 index 00000000..88fdfdbc --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.cs @@ -0,0 +1,195 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/get_file_permission 接口的响应。 + /// + public class CgibinWebDriveGetFilePermissionResponse : WechatWorkResponse + { + public static class Types + { + public class ShareRange + { + /// + /// 获取或设置是否为企业内可访问。 + /// + [Newtonsoft.Json.JsonProperty("enable_corp_internal")] + [System.Text.Json.Serialization.JsonPropertyName("enable_corp_internal")] + public bool EnableCorpInternal { get; set; } + + /// + /// 获取或设置企业内权限类型。 + /// + [Newtonsoft.Json.JsonProperty("corp_internal_auth")] + [System.Text.Json.Serialization.JsonPropertyName("corp_internal_auth")] + public int CorpInternalAuthType { get; set; } + + /// + /// 获取或设置是否开启企业内管理员审批。 + /// + [Newtonsoft.Json.JsonProperty("corp_internal_approve_only_by_admin")] + [System.Text.Json.Serialization.JsonPropertyName("corp_internal_approve_only_by_admin")] + public bool? IsCorpInternalApproveOnlyByAdmin { get; set; } + + /// + /// 获取或设置是否为企业外可访问。 + /// + [Newtonsoft.Json.JsonProperty("enable_corp_external")] + [System.Text.Json.Serialization.JsonPropertyName("enable_corp_external")] + public bool EnableCorpExternal { get; set; } + + /// + /// 获取或设置企业外权限类型。 + /// + [Newtonsoft.Json.JsonProperty("corp_external_auth")] + [System.Text.Json.Serialization.JsonPropertyName("corp_external_auth")] + public int CorpExternalAuthType { get; set; } + + /// + /// 获取或设置是否开启企业外管理员审批。 + /// + [Newtonsoft.Json.JsonProperty("corp_external_approve_only_by_admin")] + [System.Text.Json.Serialization.JsonPropertyName("corp_external_approve_only_by_admin")] + public bool? IsCorpExternalApproveOnlyByAdmin { get; set; } + } + + public class SecureSettings + { + /// + /// 获取或设置是否开启只读备份。 + /// + [Newtonsoft.Json.JsonProperty("enable_readonly_copy")] + [System.Text.Json.Serialization.JsonPropertyName("enable_readonly_copy")] + public bool EnableReadonlyCopy { get; set; } + + /// + /// 获取或设置是否只允许管理员进行修改。 + /// + [Newtonsoft.Json.JsonProperty("modify_only_by_admin")] + [System.Text.Json.Serialization.JsonPropertyName("modify_only_by_admin")] + public bool IsModifyOnlyByAdmin { get; set; } + + /// + /// 获取或设置是否开启只读评论。 + /// + [Newtonsoft.Json.JsonProperty("enable_readonly_comment")] + [System.Text.Json.Serialization.JsonPropertyName("enable_readonly_comment")] + public bool EnableReadonlyComment { get; set; } + + /// + /// 获取或设置是否禁止分享到企业外部。 + /// + [Newtonsoft.Json.JsonProperty("ban_share_external")] + [System.Text.Json.Serialization.JsonPropertyName("ban_share_external")] + public bool IsBanShareExternal { get; set; } + } + + public class ACL + { + /// + /// 获取或设置文件授权信息列表。 + /// + [Newtonsoft.Json.JsonProperty("auth_list")] + [System.Text.Json.Serialization.JsonPropertyName("auth_list")] + public Types.Authority[] AuthorityList { get; set; } = default!; + + /// + /// 获取或设置是否开启父路径权限继承。 + /// + [Newtonsoft.Json.JsonProperty("inherit")] + [System.Text.Json.Serialization.JsonPropertyName("inherit")] + public bool IsInherit { get; set; } + } + + public class Authority : CgibinWebDriveSpaceInfoResponse.Types.Space.Types.Authority + { + } + + public class Watermark + { + /// + /// 获取或设置水印文字。 + /// + [Newtonsoft.Json.JsonProperty("text")] + [System.Text.Json.Serialization.JsonPropertyName("text")] + public string Text { get; set; } = default!; + + /// + /// 获取或设置水印类型。 + /// + [Newtonsoft.Json.JsonProperty("margin_type")] + [System.Text.Json.Serialization.JsonPropertyName("margin_type")] + public int MarginType { get; set; } + + /// + /// 获取或设置是否开启水印文本。 + /// + [Newtonsoft.Json.JsonProperty("show_text")] + [System.Text.Json.Serialization.JsonPropertyName("show_text")] + public bool EnableShowText { get; set; } + + /// + /// 获取或设置是否开启水印访问人名称。 + /// + [Newtonsoft.Json.JsonProperty("show_visitor_name")] + [System.Text.Json.Serialization.JsonPropertyName("show_visitor_name")] + public bool EnableShowVisitorName { get; set; } + + /// + /// 获取或设置管理员是否强制要求使用水印。 + /// + [Newtonsoft.Json.JsonProperty("force_by_admin")] + [System.Text.Json.Serialization.JsonPropertyName("force_by_admin")] + public bool IsForceByAdmin { get; set; } + + /// + /// 获取或设置空间管理员是否强制要求使用水印。 + /// + [Newtonsoft.Json.JsonProperty("force_by_space_admin")] + [System.Text.Json.Serialization.JsonPropertyName("force_by_space_admin")] + public bool IsForceBySpaceAdmin { get; set; } + } + } + + /// + /// 获取或设置文件分享设置。 + /// + [Newtonsoft.Json.JsonProperty("share_range")] + [System.Text.Json.Serialization.JsonPropertyName("share_range")] + public Types.ShareRange ShareRange { get; set; } = default!; + + /// + /// 获取或设置安全配置信息。 + /// + [Newtonsoft.Json.JsonProperty("secure_setting")] + [System.Text.Json.Serialization.JsonPropertyName("secure_setting")] + public Types.SecureSettings SecureSettings { get; set; } = default!; + + /// + /// 获取或设置从文件父路径继承的权限信息。 + /// + [Newtonsoft.Json.JsonProperty("inherit_father_auth")] + [System.Text.Json.Serialization.JsonPropertyName("inherit_father_auth")] + public Types.ACL FatherACL { get; set; } = default!; + + /// + /// 获取或设置文件成员授权信息列表。 + /// + [Newtonsoft.Json.JsonProperty("file_member_list")] + [System.Text.Json.Serialization.JsonPropertyName("file_member_list")] + public Types.Authority[]? FileMemberAuthorityList { get; set; } + + /// + /// 获取或设置文件协作者授权信息列表。 + /// + [Newtonsoft.Json.JsonProperty("co_auth_list")] + [System.Text.Json.Serialization.JsonPropertyName("co_auth_list")] + public Types.Authority[]? FileCollaboratorAuthorityList { get; set; } + + /// + /// 获取或设置水印信息。 + /// + [Newtonsoft.Json.JsonProperty("watermark")] + [System.Text.Json.Serialization.JsonPropertyName("watermark")] + public Types.Watermark? Watermark { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.json new file mode 100644 index 00000000..7885920d --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionRequest.json @@ -0,0 +1,3 @@ +{ + "fileid": "FILEID" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.json new file mode 100644 index 00000000..6cea26e9 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWebDrive/File/CgibinWebDriveGetFilePermissionResponse.json @@ -0,0 +1,41 @@ +{ + "errcode": 0, + "errmsg": "ok", + "share_range": { + "enable_corp_internal": true, + "corp_internal_auth": 1, + "enable_corp_external": false, + "corp_external_auth": 2 + }, + "secure_setting": { + "enable_readonly_copy": true, + "modify_only_by_admin": true, + "enable_readonly_comment": false, + "ban_share_external": true + }, + "inherit_father_auth": { + "auth_list": [ + { + "type": 1, + "userid": "USERID", + "auth": 1 + } + ], + "inherit": true + }, + "file_member_list": [ + { + "type": 1, + "userid": "USERID", + "auth": 1 + } + ], + "watermark": { + "text": "WATERMARK_TEXT", + "margin_type": 1, + "show_visitor_name": false, + "force_by_admin": false, + "show_text": false, + "force_by_space_admin": false + } +}