From 57fba8f55a42d51af8b5e066e9a3ffa6a4ed3334 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Wed, 3 Jan 2024 14:46:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(work):=20=E6=96=B0=E5=A2=9E=E5=BE=AE?= =?UTF-8?q?=E7=9B=98=E9=AB=98=E7=BA=A7=E5=8A=9F=E8=83=BD=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...orkClientExecuteCgibinWedriveExtensions.cs | 62 +++++++++++++++++++ .../Vip/CgibinWedriveVipBatchAddRequest.cs | 17 +++++ .../Vip/CgibinWedriveVipBatchAddResponse.cs | 22 +++++++ .../Vip/CgibinWedriveVipBatchDeleteRequest.cs | 17 +++++ .../CgibinWedriveVipBatchDeleteResponse.cs | 22 +++++++ .../Vip/CgibinWedriveVipListRequest.cs | 22 +++++++ .../Vip/CgibinWedriveVipListResponse.cs | 29 +++++++++ .../Vip/CgibinWedriveVipBatchAddRequest.json | 3 + .../Vip/CgibinWedriveVipBatchAddResponse.json | 6 ++ .../CgibinWedriveVipBatchDeleteRequest.json | 3 + .../CgibinWedriveVipBatchDeleteResponse.json | 6 ++ .../Vip/CgibinWedriveVipListRequest.json | 4 ++ .../Vip/CgibinWedriveVipListResponse.json | 7 +++ 13 files changed, 220 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWedriveExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWedriveExtensions.cs index bc7ebd54..15b693cc 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWedriveExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinWedriveExtensions.cs @@ -578,5 +578,67 @@ namespace SKIT.FlurlHttpClient.Wechat.Work return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } #endregion + + #region Vip + /// + /// 异步调用 [POST] /cgi-bin/wedrive/vip/batch_add 接口。 + /// REF: https://developer.work.weixin.qq.com/document/path/99512 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinWedriveVipBatchAddAsync(this WechatWorkClient client, Models.CgibinWedriveVipBatchAddRequest 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", "vip", "batch_add") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/wedrive/vip/batch_del 接口。 + /// REF: https://developer.work.weixin.qq.com/document/path/99513 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinWedriveVipBatchDeleteAsync(this WechatWorkClient client, Models.CgibinWedriveVipBatchDeleteRequest 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", "vip", "batch_del") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/wedrive/vip/list 接口。 + /// REF: https://developer.work.weixin.qq.com/document/path/99514 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinWedriveVipListAsync(this WechatWorkClient client, Models.CgibinWedriveVipListRequest 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", "vip", "list") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + #endregion } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.cs new file mode 100644 index 00000000..603e4278 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/batch_add 接口的请求。 + /// + public class CgibinWedriveVipBatchAddRequest : WechatWorkRequest + { + /// + /// 获取或设置成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("userid_list")] + public IList UserIdList { get; set; } = new List(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.cs new file mode 100644 index 00000000..ac680533 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/batch_add 接口的响应。 + /// + public class CgibinWedriveVipBatchAddResponse : WechatWorkResponse + { + /// + /// 获取或设置分配成功的成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("succ_userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("succ_userid_list")] + public string[]? SuccessfulUserIdList { get; set; } + + /// + /// 获取或设置分配失败的成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("fail_userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("fail_userid_list")] + public string[]? FailedUserIdList { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.cs new file mode 100644 index 00000000..efe90a2e --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/batch_del 接口的请求。 + /// + public class CgibinWedriveVipBatchDeleteRequest : WechatWorkRequest + { + /// + /// 获取或设置成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("userid_list")] + public IList UserIdList { get; set; } = new List(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.cs new file mode 100644 index 00000000..595ab561 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/batch_del 接口的响应。 + /// + public class CgibinWedriveVipBatchDeleteResponse : WechatWorkResponse + { + /// + /// 获取或设置撤销分配成功的成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("succ_userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("succ_userid_list")] + public string[]? SuccessfulUserIdList { get; set; } + + /// + /// 获取或设置撤销分配失败的成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("fail_userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("fail_userid_list")] + public string[]? FailedUserIdList { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListRequest.cs new file mode 100644 index 00000000..dbc9a487 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListRequest.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/list 接口的请求。 + /// + public class CgibinWedriveVipListRequest : WechatWorkRequest + { + /// + /// 获取或设置分页每页数量。 + /// + [Newtonsoft.Json.JsonProperty("limit")] + [System.Text.Json.Serialization.JsonPropertyName("limit")] + public int? Limit { get; set; } + + /// + /// 获取或设置翻页标记。 + /// + [Newtonsoft.Json.JsonProperty("cursor")] + [System.Text.Json.Serialization.JsonPropertyName("cursor")] + public string? Cursor { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListResponse.cs new file mode 100644 index 00000000..0d1e6b6b --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinWedrive/Vip/CgibinWedriveVipListResponse.cs @@ -0,0 +1,29 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/wedrive/vip/list 接口的响应。 + /// + public class CgibinWedriveVipListResponse : WechatWorkResponse + { + /// + /// 获取或设置成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("userid_list")] + public string[] UserIdList { get; set; } = default!; + + /// + /// 获取或设置是否还有更多数据。 + /// + [Newtonsoft.Json.JsonProperty("has_more")] + [System.Text.Json.Serialization.JsonPropertyName("has_more")] + public bool HasMore { get; set; } + + /// + /// 获取或设置翻页标记。 + /// + [Newtonsoft.Json.JsonProperty("next_cursor")] + [System.Text.Json.Serialization.JsonPropertyName("next_cursor")] + public string? NextCursor { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.json new file mode 100644 index 00000000..52aeeaf6 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddRequest.json @@ -0,0 +1,3 @@ +{ + "userid_list": [ "zhangsan", "lisi", "wangwu" ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.json new file mode 100644 index 00000000..e57127d7 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchAddResponse.json @@ -0,0 +1,6 @@ +{ + "errcode": 0, + "errmsg": "ok", + "succ_userid_list": [ "zhangsan", "lisi" ], + "fail_userid_list": [ "wangwu" ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.json new file mode 100644 index 00000000..52aeeaf6 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteRequest.json @@ -0,0 +1,3 @@ +{ + "userid_list": [ "zhangsan", "lisi", "wangwu" ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.json new file mode 100644 index 00000000..e57127d7 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipBatchDeleteResponse.json @@ -0,0 +1,6 @@ +{ + "errcode": 0, + "errmsg": "ok", + "succ_userid_list": [ "zhangsan", "lisi" ], + "fail_userid_list": [ "wangwu" ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListRequest.json new file mode 100644 index 00000000..36e6e636 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListRequest.json @@ -0,0 +1,4 @@ +{ + "cursor": "CURSOR", + "limit": 2 +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListResponse.json new file mode 100644 index 00000000..61cade4d --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinWedrive/Vip/CgibinWedriveVipListResponse.json @@ -0,0 +1,7 @@ +{ + "errcode": 0, + "errmsg": "ok", + "has_more": true, + "next_cursor": "GNIJIGEO", + "userid_list": [ "zhangsan", "lisi" ] +}