From e096912d5108b752bdc8d8b4f2abedd9c125b885 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Wed, 26 Oct 2022 23:27:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E4=BB=A3?= =?UTF-8?q?=E5=95=86=E5=AE=B6=E7=AE=A1=E7=90=86=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tApiClientExecuteWxaComponentExtensions.cs | 20 +++++ .../Code/WxaGetVersionInfoRequest.cs | 9 +++ .../Code/WxaGetVersionInfoResponse.cs | 73 +++++++++++++++++++ .../Code/WxaGetVersionInfoResponse.json | 14 ++++ 4 files changed, 116 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaComponent/Code/WxaGetVersionInfoResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaComponentExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaComponentExtensions.cs index 8fae39ec..361d0a50 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaComponentExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaComponentExtensions.cs @@ -975,6 +975,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + + /// + /// 异步调用 [POST] /wxa/getversioninfo 接口。 + /// REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/code-management/getVersionInfo.html + /// + /// + /// + /// + /// + public static async Task ExecuteWxaGetVersionInfoAsync(this WechatApiClient client, Models.WxaGetVersionInfoRequest 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, "wxa", "getversioninfo") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } #endregion #region Record diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoRequest.cs new file mode 100644 index 00000000..674b8131 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoRequest.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/getversioninfo 接口的请求。 + /// + public class WxaGetVersionInfoRequest : WechatApiRequest, IInferable + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoResponse.cs new file mode 100644 index 00000000..55db07e5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaGetVersionInfoResponse.cs @@ -0,0 +1,73 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/getversioninfo 接口的响应。 + /// + public class WxaGetVersionInfoResponse : WechatApiResponse + { + public static class Types + { + public class ExperienceInfo + { + /// + /// 获取或设置提交时间戳。 + /// + [Newtonsoft.Json.JsonProperty("exp_time")] + [System.Text.Json.Serialization.JsonPropertyName("exp_time")] + public long Timestamp { get; set; } + + /// + /// 获取或设置版本信息。 + /// + [Newtonsoft.Json.JsonProperty("exp_version")] + [System.Text.Json.Serialization.JsonPropertyName("exp_version")] + public string Version { get; set; } = default!; + + /// + /// 获取或设置版本描述。 + /// + [Newtonsoft.Json.JsonProperty("exp_desc")] + [System.Text.Json.Serialization.JsonPropertyName("exp_desc")] + public string Description { get; set; } = default!; + } + + public class ReleaseInfo + { + /// + /// 获取或设置发布时间戳。 + /// + [Newtonsoft.Json.JsonProperty("release_time")] + [System.Text.Json.Serialization.JsonPropertyName("release_time")] + public long Timestamp { get; set; } + + /// + /// 获取或设置版本信息。 + /// + [Newtonsoft.Json.JsonProperty("release_version")] + [System.Text.Json.Serialization.JsonPropertyName("release_version")] + public string Version { get; set; } = default!; + + /// + /// 获取或设置版本描述。 + /// + [Newtonsoft.Json.JsonProperty("release_desc")] + [System.Text.Json.Serialization.JsonPropertyName("release_desc")] + public string Description { get; set; } = default!; + } + } + + /// + /// 获取或设置体验版信息。 + /// + [Newtonsoft.Json.JsonProperty("exp_info")] + [System.Text.Json.Serialization.JsonPropertyName("exp_info")] + public Types.ExperienceInfo? ExperienceInfo { get; set; } + + /// + /// 获取或设置线上版信息。 + /// + [Newtonsoft.Json.JsonProperty("release_info")] + [System.Text.Json.Serialization.JsonPropertyName("release_info")] + public Types.ReleaseInfo? ReleaseInfo { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaComponent/Code/WxaGetVersionInfoResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaComponent/Code/WxaGetVersionInfoResponse.json new file mode 100644 index 00000000..a2399a0c --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaComponent/Code/WxaGetVersionInfoResponse.json @@ -0,0 +1,14 @@ +{ + "errcode": 0, + "errmsg": "ok", + "exp_info": { + "exp_time": 1640762988, + "exp_version": "V1.0", + "exp_desc": "test" + }, + "release_info": { + "release_time": 1640763902, + "release_version": "V1.5", + "release_desc": "test" + } +}