feat(wxapi): 新增视频号橱窗上下架商品接口

This commit is contained in:
Fu Diwei
2022-10-31 22:42:59 +08:00
parent dd722a9899
commit c8dcd0baa2
7 changed files with 117 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html </para> /// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html </para>
/// <para>REF: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/access-token/auth.getAccessToken.html </para> /// <para>REF: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/access-token/auth.getAccessToken.html </para>
/// <para>REF: https://developers.weixin.qq.com/doc/channels/API/basics/getaccesstoken.html </para> /// <para>REF: https://developers.weixin.qq.com/doc/channels/API/basics/getaccesstoken.html </para>
/// <para>REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/getaccesstoken.html </para>
/// </summary> /// </summary>
/// <param name="client"></param> /// <param name="client"></param>
/// <param name="request"></param> /// <param name="request"></param>

View File

@@ -54,5 +54,47 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
} }
} }
#endregion #endregion
#region ECWindow
/// <summary>
/// <para>异步调用 [POST] /channels/ec/window/product/add 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/add.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsECWindowProductAddResponse> 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<Models.ChannelsECWindowProductAddResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /channels/ec/window/product/off 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/channels/API/windowproduct/off.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsECWindowProductOffResponse> 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<Models.ChannelsECWindowProductOffResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
} }
} }

View File

@@ -0,0 +1,29 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/window/product/add 接口的请求。</para>
/// </summary>
public class ChannelsECWindowProductAddRequest : WechatApiRequest, IInferable<ChannelsECWindowProductAddRequest, ChannelsECWindowProductAddResponse>
{
/// <summary>
/// 获取或设置商品 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("product_id")]
[System.Text.Json.Serialization.JsonPropertyName("product_id")]
public long ProductId { get; set; }
/// <summary>
/// 获取或设置商品来源店铺的 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置是否需要在个人橱窗页隐藏。
/// </summary>
[Newtonsoft.Json.JsonProperty("is_hide_for_window")]
[System.Text.Json.Serialization.JsonPropertyName("is_hide_for_window")]
public bool? IsHideForWindow { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/window/product/add 接口的响应。</para>
/// </summary>
public class ChannelsECWindowProductAddResponse : WechatApiResponse
{
}
}

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/window/product/off 接口的请求。</para>
/// </summary>
public class ChannelsECWindowProductOffRequest : WechatApiRequest, IInferable<ChannelsECWindowProductOffRequest, ChannelsECWindowProductOffResponse>
{
/// <summary>
/// 获取或设置商品 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("product_id")]
[System.Text.Json.Serialization.JsonPropertyName("product_id")]
public long ProductId { get; set; }
/// <summary>
/// 获取或设置商品来源店铺的 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/ec/window/product/off 接口的响应。</para>
/// </summary>
public class ChannelsECWindowProductOffResponse : WechatApiResponse
{
}
}

View File

@@ -0,0 +1,5 @@
{
"product_id": "100234056",
"appid": "wxee9f94a3360ad25f",
"is_hide_for_window": true
}