From 7b449ea2100b3829a66db5a8251c18004e55b328 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 29 Jul 2024 10:59:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(work):=20=E6=96=B0=E5=A2=9E=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E8=AE=BE=E7=BD=AE=E5=BA=94=E7=94=A8=E5=9C=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=B1=95=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tWorkClientExecuteCgibinAgentExtensions.cs | 27 ++++++ ...CgibinAgentBatchSetWorkbenchDataRequest.cs | 91 +++++++++++++++++++ ...gibinAgentBatchSetWorkbenchDataResponse.cs | 9 ++ ...ibinAgentBatchSetWorkbenchDataRequest.json | 17 ++++ 4 files changed, 144 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinAgentExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinAgentExtensions.cs index 5f9580ad..029466d6 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinAgentExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinAgentExtensions.cs @@ -243,6 +243,33 @@ namespace SKIT.FlurlHttpClient.Wechat.Work return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// 异步调用 [POST] /cgi-bin/agent/batch_set_workbench_data 接口。 + /// + /// REF:
+ ///
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteCgibinAgentBatchSetWorkbenchDataAsync(this WechatWorkClient client, Models.CgibinAgentBatchSetWorkbenchDataRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + if (request.AgentId is null) + request.AgentId = client.Credentials.AgentId; + + IFlurlRequest flurlReq = client + .CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "agent", "batch_set_workbench_data") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } #endregion } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.cs new file mode 100644 index 00000000..69da9d62 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/agent/batch_set_workbench_data 接口的请求。 + /// + public class CgibinAgentBatchSetWorkbenchDataRequest : WechatWorkRequest + { + public static class Types + { + public class Data + { + public static class Types + { + public class KeyDataTemplate : CgibinAgentSetWorkbenchDataRequest.Types.KeyDataTemplate + { + } + + public class ImageTemplate : CgibinAgentSetWorkbenchDataRequest.Types.ImageTemplate + { + } + + public class WebviewTemplate : CgibinAgentSetWorkbenchDataRequest.Types.WebviewTemplate + { + } + + public class ListTemplate : CgibinAgentSetWorkbenchDataRequest.Types.ListTemplate + { + } + } + + /// + /// 获取或设置模版类型。 + /// + [Newtonsoft.Json.JsonProperty("type")] + [System.Text.Json.Serialization.JsonPropertyName("type")] + public string Type { get; set; } = string.Empty; + + /// + /// 获取或设置关键数据型模版数据。 + /// + [Newtonsoft.Json.JsonProperty("keydata")] + [System.Text.Json.Serialization.JsonPropertyName("keydata")] + public Types.KeyDataTemplate? KeyDataTemplate { get; set; } + + /// + /// 获取或设置图片型模版数据。 + /// + [Newtonsoft.Json.JsonProperty("image")] + [System.Text.Json.Serialization.JsonPropertyName("image")] + public Types.ImageTemplate? ImageTemplate { get; set; } + + /// + /// 获取或设置列表型模版数据。 + /// + [Newtonsoft.Json.JsonProperty("list")] + [System.Text.Json.Serialization.JsonPropertyName("list")] + public Types.ListTemplate? ListTemplate { get; set; } + + /// + /// 获取或设置网页型模版数据。 + /// + [Newtonsoft.Json.JsonProperty("webview")] + [System.Text.Json.Serialization.JsonPropertyName("webview")] + public Types.WebviewTemplate? WebviewTemplate { get; set; } + } + } + + /// + /// 获取或设置应用 ID。如果不指定将使用构造 时的 参数。 + /// + [Newtonsoft.Json.JsonProperty("agentid")] + [System.Text.Json.Serialization.JsonPropertyName("agentid")] + public int? AgentId { get; set; } + + /// + /// 获取或设置成员账号列表。 + /// + [Newtonsoft.Json.JsonProperty("userid_list")] + [System.Text.Json.Serialization.JsonPropertyName("userid_list")] + public IList UserIdList { get; set; } = new List(); + + /// + /// 获取或设置用户设置的数据。 + /// + [Newtonsoft.Json.JsonProperty("data")] + [System.Text.Json.Serialization.JsonPropertyName("data")] + public Types.Data Data { get; set; } = new Types.Data(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataResponse.cs new file mode 100644 index 00000000..922f69d2 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/agent/batch_set_workbench_data 接口的响应。 + /// + public class CgibinAgentBatchSetWorkbenchDataResponse : WechatWorkResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.json new file mode 100644 index 00000000..86bf5f03 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinAgent/Workbench/CgibinAgentBatchSetWorkbenchDataRequest.json @@ -0,0 +1,17 @@ +{ + "agentid": 1000005, + "userid_list": [ "userid1", "userid2" ], + "data": { + "type": "keydata", + "keydata": { + "items": [ + { + "key": "待审批", + "data": "0", + "jump_url": "http://www.qq.com", + "pagepath": "pages/index" + } + ] + } + } +}