diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs index 88a9b759..d9cf70c5 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinExtensions.cs @@ -15,6 +15,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html /// REF: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/access-token/auth.getAccessToken.html /// REF: https://developers.weixin.qq.com/doc/channels/API/basics/getaccesstoken.html + /// REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/getaccesstoken.html /// /// /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs index 8363b315..b76c6468 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteChannelsExtensions.cs @@ -54,5 +54,47 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } } #endregion + + #region ECWindow + /// + /// 异步调用 [POST] /channels/ec/window/product/add 接口。 + /// REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/add.html + /// + /// + /// + /// + /// + public static async Task ExecuteChannelsECWindowProductAddAsync(this WechatApiClient client, Models.ChannelsECWindowProductAddRequest 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, "channels", "ec", "window", "product", "add") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /channels/ec/window/product/off 接口。 + /// REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/off.html + /// + /// + /// + /// + /// + public static async Task ExecuteChannelsECWindowProductOffAsync(this WechatApiClient client, Models.ChannelsECWindowProductOffRequest 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, "channels", "ec", "window", "product", "off") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + #endregion } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddRequest.cs new file mode 100644 index 00000000..60364bdb --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddRequest.cs @@ -0,0 +1,29 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/window/product/add 接口的请求。 + /// + public class ChannelsECWindowProductAddRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置商品 ID。 + /// + [Newtonsoft.Json.JsonProperty("product_id")] + [System.Text.Json.Serialization.JsonPropertyName("product_id")] + public long ProductId { get; set; } + + /// + /// 获取或设置商品来源店铺的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("appid")] + [System.Text.Json.Serialization.JsonPropertyName("appid")] + public string AppId { get; set; } = string.Empty; + + /// + /// 获取或设置是否需要在个人橱窗页隐藏。 + /// + [Newtonsoft.Json.JsonProperty("is_hide_for_window")] + [System.Text.Json.Serialization.JsonPropertyName("is_hide_for_window")] + public bool? IsHideForWindow { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddResponse.cs new file mode 100644 index 00000000..cf1276fd --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductAddResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/window/product/add 接口的响应。 + /// + public class ChannelsECWindowProductAddResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffRequest.cs new file mode 100644 index 00000000..a7efb739 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffRequest.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/window/product/off 接口的请求。 + /// + public class ChannelsECWindowProductOffRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置商品 ID。 + /// + [Newtonsoft.Json.JsonProperty("product_id")] + [System.Text.Json.Serialization.JsonPropertyName("product_id")] + public long ProductId { get; set; } + + /// + /// 获取或设置商品来源店铺的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("appid")] + [System.Text.Json.Serialization.JsonPropertyName("appid")] + public string AppId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffResponse.cs new file mode 100644 index 00000000..15529f0d --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Channels/ECWindow/ChannelsECWindowProductOffResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /channels/ec/window/product/off 接口的响应。 + /// + public class ChannelsECWindowProductOffResponse : WechatApiResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECWindow/ChannelsECWindowProductAddRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECWindow/ChannelsECWindowProductAddRequest.json new file mode 100644 index 00000000..515a0540 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Channels/ECWindow/ChannelsECWindowProductAddRequest.json @@ -0,0 +1,5 @@ +{ + "product_id": "100234056", + "appid": "wxee9f94a3360ad25f", + "is_hide_for_window": true +}