From 2cb4a262d72bacc22c0f882ab9707bf0697b3c99 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Fri, 15 Mar 2024 01:06:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E7=9F=AD?= =?UTF-8?q?=E5=89=A7=E5=AA=92=E8=B5=84=E7=AE=A1=E7=90=86=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=8E=88=E6=9D=83=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 --- .../WechatApiClientExecuteWxaSecExtensions.cs | 98 ++++++++++++++++++- .../Vod/App/WxaSecVodAuthorizeAppRequest.cs | 22 +++++ .../Vod/App/WxaSecVodAuthorizeAppResponse.cs | 9 ++ .../Vod/App/WxaSecVodDeauthorizeAppRequest.cs | 15 +++ .../App/WxaSecVodDeauthorizeAppResponse.cs | 9 ++ .../App/WxaSecVodGetAuthorizeAppsRequest.cs | 9 ++ .../App/WxaSecVodGetAuthorizeAppsResponse.cs | 41 ++++++++ .../App/WxaSecVodGetAuthorizedAppsRequest.cs | 9 ++ .../App/WxaSecVodGetAuthorizedAppsResponse.cs | 41 ++++++++ .../Vod/App/WxaSecVodAuthorizeAppRequest.json | 4 + .../App/WxaSecVodDeauthorizeAppRequest.json | 3 + .../WxaSecVodGetAuthorizeAppsResponse.json | 16 +++ .../WxaSecVodGetAuthorizedAppsResponse.json | 11 +++ 13 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaSecExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaSecExtensions.cs index aa48901d..229c825d 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaSecExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaSecExtensions.cs @@ -294,6 +294,100 @@ namespace SKIT.FlurlHttpClient.Wechat.Api #endregion #region Vod + #region Vod/App + /// + /// 异步调用 [POST] /wxa/sec/vod/authorizeapp 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWxaSecVodAuthorizeAppAsync(this WechatApiClient client, Models.WxaSecVodAuthorizeAppRequest 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 + .CreateFlurlRequest(request, HttpMethod.Post, "wxa", "sec", "vod", "authorizeapp") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// 异步调用 [POST] /wxa/sec/vod/deauthorizeapp 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWxaSecVodDeauthorizeAppAsync(this WechatApiClient client, Models.WxaSecVodDeauthorizeAppRequest 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 + .CreateFlurlRequest(request, HttpMethod.Post, "wxa", "sec", "vod", "deauthorizeapp") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// 异步调用 [GET] /wxa/sec/vod/getauthorizeapps 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWxaSecVodGetAuthorizeAppsAsync(this WechatApiClient client, Models.WxaSecVodGetAuthorizeAppsRequest 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 + .CreateFlurlRequest(request, HttpMethod.Get, "wxa", "sec", "vod", "getauthorizeapps") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// 异步调用 [GET] /wxa/sec/vod/getauthorizedapps 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWxaSecVodGetAuthorizedAppsAsync(this WechatApiClient client, Models.WxaSecVodGetAuthorizedAppsRequest 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 + .CreateFlurlRequest(request, HttpMethod.Get, "wxa", "sec", "vod", "getauthorizedapps") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + #endregion + #region Vod/Upload /// /// 异步调用 [POST] /wxa/sec/vod/singlefileupload 接口。 @@ -442,7 +536,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion - #region /Vod/Media + #region Vod/Media /// /// 异步调用 [POST] /wxa/sec/vod/listmedia 接口。 /// @@ -536,7 +630,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion - #region /Vod/Drama + #region Vod/Drama /// /// 异步调用 [POST] /wxa/sec/vod/auditdrama 接口。 /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.cs new file mode 100644 index 00000000..4015a3b6 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/sec/vod/authorizeapp 接口的请求。 + /// + public class WxaSecVodAuthorizeAppRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置被授权方小程序 AppId。 + /// + [Newtonsoft.Json.JsonProperty("authorized_appid")] + [System.Text.Json.Serialization.JsonPropertyName("authorized_appid")] + public string AuthorizedAppId { get; set; } = string.Empty; + + /// + /// 获取或设置授权到期时间戳。 + /// + [Newtonsoft.Json.JsonProperty("authz_expire_time")] + [System.Text.Json.Serialization.JsonPropertyName("authz_expire_time")] + public long? ExpireTimestamp { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppResponse.cs new file mode 100644 index 00000000..5696ae82 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodAuthorizeAppResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/sec/vod/authorizeapp 接口的响应。 + /// + public class WxaSecVodAuthorizeAppResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.cs new file mode 100644 index 00000000..f766e158 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/sec/vod/deauthorizeapp 接口的请求。 + /// + public class WxaSecVodDeauthorizeAppRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置被授权方小程序 AppId。 + /// + [Newtonsoft.Json.JsonProperty("authorized_appid")] + [System.Text.Json.Serialization.JsonPropertyName("authorized_appid")] + public string AuthorizedAppId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppResponse.cs new file mode 100644 index 00000000..7b3ffaf5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodDeauthorizeAppResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/sec/vod/deauthorizeapp 接口的响应。 + /// + public class WxaSecVodDeauthorizeAppResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsRequest.cs new file mode 100644 index 00000000..0a3bda81 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsRequest.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /wxa/sec/vod/getauthorizeapps 接口的请求。 + /// + public class WxaSecVodGetAuthorizeAppsRequest : WechatApiRequest, IInferable + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.cs new file mode 100644 index 00000000..24d1bf8f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.cs @@ -0,0 +1,41 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /wxa/sec/vod/getauthorizeapps 接口的响应。 + /// + public class WxaSecVodGetAuthorizeAppsResponse : WechatApiResponse + { + public static class Types + { + public class Object + { + /// 获取或设置被授权方小程序 AppId。 + /// + [Newtonsoft.Json.JsonProperty("authorized_appid")] + [System.Text.Json.Serialization.JsonPropertyName("authorized_appid")] + public string AuthorizedAppId { get; set; } = default!; + + /// + /// 获取或设置授权时间戳。 + /// + [Newtonsoft.Json.JsonProperty("authorized_time")] + [System.Text.Json.Serialization.JsonPropertyName("authorized_time")] + public long AuthorizeTimestamp { get; set; } + + /// + /// 获取或设置授权到期时间戳。 + /// + [Newtonsoft.Json.JsonProperty("authz_expire_time")] + [System.Text.Json.Serialization.JsonPropertyName("authz_expire_time")] + public long? ExpireTimestamp { get; set; } + } + } + + /// + /// 获取或设置授权列表。 + /// + [Newtonsoft.Json.JsonProperty("objects")] + [System.Text.Json.Serialization.JsonPropertyName("objects")] + public Types.Object[] ObjectList { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsRequest.cs new file mode 100644 index 00000000..9ea2119d --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsRequest.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /wxa/sec/vod/getauthorizedapps 接口的请求。 + /// + public class WxaSecVodGetAuthorizedAppsRequest : WechatApiRequest, IInferable + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.cs new file mode 100644 index 00000000..e0effee3 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.cs @@ -0,0 +1,41 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /wxa/sec/vod/getauthorizedapps 接口的响应。 + /// + public class WxaSecVodGetAuthorizedAppsResponse : WechatApiResponse + { + public static class Types + { + public class Object + { + /// 获取或设置授权方小程序 AppId。 + /// + [Newtonsoft.Json.JsonProperty("authorizer_appid")] + [System.Text.Json.Serialization.JsonPropertyName("authorizer_appid")] + public string AuthorizerAppId { get; set; } = default!; + + /// + /// 获取或设置授权时间戳。 + /// + [Newtonsoft.Json.JsonProperty("authorized_time")] + [System.Text.Json.Serialization.JsonPropertyName("authorized_time")] + public long AuthorizeTimestamp { get; set; } + + /// + /// 获取或设置授权到期时间戳。 + /// + [Newtonsoft.Json.JsonProperty("authz_expire_time")] + [System.Text.Json.Serialization.JsonPropertyName("authz_expire_time")] + public long? ExpireTimestamp { get; set; } + } + } + + /// + /// 获取或设置授权列表。 + /// + [Newtonsoft.Json.JsonProperty("objects")] + [System.Text.Json.Serialization.JsonPropertyName("objects")] + public Types.Object[] ObjectList { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.json new file mode 100644 index 00000000..6267ef2a --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodAuthorizeAppRequest.json @@ -0,0 +1,4 @@ +{ + "authorized_appid": "wx*************", + "authz_expire_time": 0 +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.json new file mode 100644 index 00000000..7b17d0ce --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodDeauthorizeAppRequest.json @@ -0,0 +1,3 @@ +{ + "authorized_appid": "wx*************" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.json new file mode 100644 index 00000000..7c384693 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizeAppsResponse.json @@ -0,0 +1,16 @@ +{ + "errcode": 0, + "errmsg": "ok", + "objects": [ + { + "authorized_appid": "wx**********", + "authorized_time": 1702020510, + "authz_expire_time": 0 + }, + { + "authorized_appid": "wx**********", + "authorized_time": 1702020549, + "authz_expire_time": 1703120549 + } + ] +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.json new file mode 100644 index 00000000..7ebdb710 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/WxaSec/Vod/App/WxaSecVodGetAuthorizedAppsResponse.json @@ -0,0 +1,11 @@ +{ + "errcode": 0, + "errmsg": "ok", + "objects": [ + { + "authorizer_appid": "wx**********", + "authorized_time": 1702020510, + "authz_expire_time": 0 + } + ] +}