feat(wxapi): 新增视频号助手直播大屏数据相关接口

This commit is contained in:
Fu Diwei
2024-07-15 09:18:53 +08:00
parent 8c6fc91ff8
commit 70e5d501da
9 changed files with 222 additions and 0 deletions

View File

@@ -4320,5 +4320,53 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
return await client.SendFlurlRequestAsJsonAsync<Models.ChannelsLeadsGetLeadsComponentIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
#region LiveDashboard
/// <summary>
/// <para>异步调用 [POST] /channels/livedashboard/getlivelist 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.weixin.qq.com/doc/channels/API/livedashboard/getlivelist.html ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsLiveDashboardGetLiveListResponse> ExecuteChannelsLiveDashboardGetLiveListAsync(this WechatApiClient client, Models.ChannelsLiveDashboardGetLiveListRequest 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", "livedashboard", "getlivelist")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendFlurlRequestAsJsonAsync<Models.ChannelsLiveDashboardGetLiveListResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /channels/livedashboard/getlivedata 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.weixin.qq.com/doc/channels/API/livedashboard/getlivedata.html ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ChannelsLiveDashboardGetLiveDataResponse> ExecuteChannelsLiveDashboardGetLiveDataAsync(this WechatApiClient client, Models.ChannelsLiveDashboardGetLiveDataRequest 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", "livedashboard", "getlivedata")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendFlurlRequestAsJsonAsync<Models.ChannelsLiveDashboardGetLiveDataResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/livedashboard/getlivedata 接口的请求。</para>
/// </summary>
public class ChannelsLiveDashboardGetLiveDataRequest : WechatApiRequest, IInferable<ChannelsLiveDashboardGetLiveDataRequest, ChannelsLiveDashboardGetLiveDataResponse>
{
/// <summary>
/// 获取或设置直播唯一 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("export_id")]
[System.Text.Json.Serialization.JsonPropertyName("export_id")]
public string ExportId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,64 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/livedashboard/getlivedata 接口的响应。</para>
/// </summary>
public class ChannelsLiveDashboardGetLiveDataResponse : WechatApiResponse
{
/// <summary>
/// 获取或设置直播大屏基础数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_dashboard_data")]
[System.Text.Json.Serialization.JsonPropertyName("live_dashboard_data")]
public string LiveDashboardDataJson { get; set; } = default!;
/// <summary>
/// 获取或设置直播内容力数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_comparison_index")]
[System.Text.Json.Serialization.JsonPropertyName("live_comparison_index")]
public string LiveComparisonIndexJson { get; set; } = default!;
/// <summary>
/// 获取或设置电商数据概要数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_ec_data_summary")]
[System.Text.Json.Serialization.JsonPropertyName("live_ec_data_summary")]
public string LiveECDataSummaryJson { get; set; } = default!;
/// <summary>
/// 获取或设置电商转化力数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_ec_conversion_metric")]
[System.Text.Json.Serialization.JsonPropertyName("live_ec_conversion_metric")]
public string LiveECConversionMetricJson { get; set; } = default!;
/// <summary>
/// 获取或设置电商画像数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_ec_profile")]
[System.Text.Json.Serialization.JsonPropertyName("live_ec_profile")]
public string LiveECProfileJson { get; set; } = default!;
/// <summary>
/// 获取或设置电商渠道分布数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_distribution_channel")]
[System.Text.Json.Serialization.JsonPropertyName("live_distribution_channel")]
public string LiveDistributionChannelJson { get; set; } = default!;
/// <summary>
/// 获取或设置电商商品数据 JSON 字符串。
/// </summary>
[Newtonsoft.Json.JsonProperty("single_live_ec_spu_data_page_v2")]
[System.Text.Json.Serialization.JsonPropertyName("single_live_ec_spu_data_page_v2")]
public string SingleLiveECSPUDataPageV2Json { get; set; } = default!;
/// <summary>
/// 获取或设置追踪 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("trace_id")]
[System.Text.Json.Serialization.JsonPropertyName("trace_id")]
public string TraceId { get; set; } = default!;
}
}

View File

@@ -0,0 +1,17 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/livedashboard/getlivelist 接口的请求。</para>
/// </summary>
public class ChannelsLiveDashboardGetLiveListRequest : WechatApiRequest, IInferable<ChannelsLiveDashboardGetLiveListRequest, ChannelsLiveDashboardGetLiveListResponse>
{
/// <summary>
/// 获取或设置日期字符串格式yyyyMMdd
/// </summary>
[Newtonsoft.Json.JsonProperty("ds")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.Common.NumericalStringConverter))]
[System.Text.Json.Serialization.JsonPropertyName("ds")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringConverter))]
public string DateString { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,49 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /channels/livedashboard/getlivelist 接口的响应。</para>
/// </summary>
public class ChannelsLiveDashboardGetLiveListResponse : WechatApiResponse
{
public static class Types
{
public class LiveItem
{
/// <summary>
/// 获取或设置直播唯一 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("export_id")]
[System.Text.Json.Serialization.JsonPropertyName("export_id")]
public string ExportId { get; set; } = default!;
/// <summary>
/// 获取或设置直播创建时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
public long CreateTimestamp { get; set; }
}
}
/// <summary>
/// 获取或设置直播数据列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("live_items")]
[System.Text.Json.Serialization.JsonPropertyName("live_items")]
public Types.LiveItem[] LiveItemList { get; set; } = default!;
/// <summary>
/// 获取或设置是否还有更多数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("has_more")]
[System.Text.Json.Serialization.JsonPropertyName("has_more")]
public bool HasMore { get; set; }
/// <summary>
/// 获取或设置追踪 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("trace_id")]
[System.Text.Json.Serialization.JsonPropertyName("trace_id")]
public string TraceId { get; set; } = default!;
}
}

View File

@@ -0,0 +1,3 @@
{
"export_id": "export/UzFf*****************************************************************************************64V"
}

View File

@@ -0,0 +1,11 @@
{
"errcode": 0,
"errmsg": "ok",
"live_dashboard_data": "{}",
"live_comparison_index": "{}",
"live_ec_data_summary": "{}",
"live_ec_conversion_metric": "{}",
"live_ec_profile": "{}",
"live_distribution_channel": "{}",
"single_live_ec_spu_data_page_v2": "{}"
}

View File

@@ -0,0 +1,12 @@
{
"errcode": 0,
"errmsg": "ok",
"trace_id": "",
"live_items": [
{
"export_id": "",
"create_time": 1234567890
}
],
"has_more": false
}