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" + } +}