diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs index 395b9dcc..91bfe79a 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs @@ -3281,6 +3281,31 @@ namespace SKIT.FlurlHttpClient.Wechat.Api #endregion #endregion + #region ECOpen + /// + /// 异步调用 [POST] /channels/ec/open/get_download_url 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteChannelsECOpenGetDownloadUrlAsync(this WechatApiClient client, Models.ChannelsECOpenGetDownloadUrlRequest 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, "channels", "ec", "open", "get_download_url") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + #endregion + #region ECOrder /// /// 异步调用 [POST] /channels/ec/order/search 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.cs new file mode 100644 index 00000000..84fdb9c3 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/open/get_download_url 接口的请求。 + /// + public class ChannelsECOpenGetDownloadUrlRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置用户的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("openid")] + [System.Text.Json.Serialization.JsonPropertyName("openid")] + public string OpenId { get; set; } = string.Empty; + + /// + /// 获取或设置订单 ID。 + /// + [Newtonsoft.Json.JsonProperty("order_id")] + [System.Text.Json.Serialization.JsonPropertyName("order_id")] + public string OrderId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.cs new file mode 100644 index 00000000..339d00db --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/open/get_download_url 接口的响应。 + /// + public class ChannelsECOpenGetDownloadUrlResponse : WechatApiResponse + { + /// + /// 获取或设置文件下载链接。 + /// + [Newtonsoft.Json.JsonProperty("download_url")] + [System.Text.Json.Serialization.JsonPropertyName("download_url")] + public string DownloadUrl { get; set; } = default!; + + /// + /// 获取或设置链接到期时间戳。 + /// + [Newtonsoft.Json.JsonProperty("expire_time")] + [System.Text.Json.Serialization.JsonPropertyName("expire_time")] + public long ExpireTimestamp { get; set; } + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.json new file mode 100644 index 00000000..88ca08f2 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlRequest.json @@ -0,0 +1,4 @@ +{ + "openid": "23982ADD2323", + "order_id": "239829312" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.json new file mode 100644 index 00000000..a08ae4fd --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECOpen/ChannelsECOpenGetDownloadUrlResponse.json @@ -0,0 +1,6 @@ +{ + "errcode": 0, + "errmsg": "成功", + "download_url": "https://cos.tencent.com/image/test.png", + "expire_time": 17823232312 +}