feat(work): 新增获取观看、未观看直播统计 V2 版接口

This commit is contained in:
Fu Diwei 2022-06-23 11:37:33 +08:00
parent fea1c8061e
commit 2580119416
9 changed files with 412 additions and 0 deletions

View File

@ -656,6 +656,48 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolLivingGetUnwatchStatisticsResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/school/living/get_watch_stat_v2 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95793 </para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95799 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSchoolLivingGetWatchStatisticsV2Response> ExecuteCgibinSchoolLivingGetWatchStatisticsV2Async(this WechatWorkClient client, Models.CgibinSchoolLivingGetWatchStatisticsV2Request 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, "cgi-bin", "school", "living", "get_watch_stat_v2")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolLivingGetWatchStatisticsV2Response>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/school/living/get_unwatch_stat_v2 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95795 </para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95799 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSchoolLivingGetUnwatchStatisticsV2Response> ExecuteCgibinSchoolLivingGetUnwatchStatisticsV2Async(this WechatWorkClient client, Models.CgibinSchoolLivingGetUnwatchStatisticsV2Request 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, "cgi-bin", "school", "living", "get_unwatch_stat_v2")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinSchoolLivingGetUnwatchStatisticsV2Response>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
#region Payment

View File

@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/school/living/get_unwatch_stat_v2 接口的请求。</para>
/// </summary>
public class CgibinSchoolLivingGetUnwatchStatisticsV2Request : CgibinSchoolLivingGetWatchStatisticsV2Request
{
}
}

View File

@ -0,0 +1,81 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/school/living/get_unwatch_stat_v2 接口的响应。</para>
/// </summary>
public class CgibinSchoolLivingGetUnwatchStatisticsV2Response : WechatWorkResponse
{
public static class Types
{
public class Statistics
{
public static class Types
{
public class Student
{
/// <summary>
/// 获取或设置学生账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("student_userid")]
[System.Text.Json.Serialization.JsonPropertyName("student_userid")]
public string StudentUserId { get; set; } = default!;
/// <summary>
/// 获取或设置学生所在的部门 ID即班级列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public long[] DepartmentIdList { get; set; } = default!;
}
public class Parent : Student
{
/// <summary>
/// 获取或设置家长账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("parent_userid")]
[System.Text.Json.Serialization.JsonPropertyName("parent_userid")]
public string ParentUserId { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置学生列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("students")]
[System.Text.Json.Serialization.JsonPropertyName("students")]
public Types.Student[] StudentList { get; set; } = default!;
/// <summary>
/// 获取或设置家长列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("parents")]
[System.Text.Json.Serialization.JsonPropertyName("parents")]
public Types.Parent[] ParentList { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置统计信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("stat_info")]
[System.Text.Json.Serialization.JsonPropertyName("stat_info")]
public Types.Statistics Statistics { get; set; } = default!;
/// <summary>
/// 获取或设置是否还有更多。
/// </summary>
[Newtonsoft.Json.JsonProperty("has_more")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalBooleanConverter))]
[System.Text.Json.Serialization.JsonPropertyName("has_more")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalBooleanConverter))]
public bool HasMore { get; set; }
/// <summary>
/// 获取或设置翻页标记。
/// </summary>
[Newtonsoft.Json.JsonProperty("next_cursor")]
[System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
public string? NextCursor { get; set; }
}
}

View File

@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/school/living/get_watch_stat_v2 接口的请求。</para>
/// </summary>
public class CgibinSchoolLivingGetWatchStatisticsV2Request : WechatWorkRequest
{
/// <summary>
/// 获取或设置直播 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("livingid")]
[System.Text.Json.Serialization.JsonPropertyName("livingid")]
public string LivingId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置翻页标记。
/// </summary>
[Newtonsoft.Json.JsonProperty("next_cursor")]
[System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
public string? Cursor { get; set; }
}
}

View File

@ -0,0 +1,158 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/school/living/get_watch_stat_v2 接口的响应。</para>
/// </summary>
public class CgibinSchoolLivingGetWatchStatisticsV2Response : WechatWorkResponse
{
public static class Types
{
public class Statistics
{
public static class Types
{
public class Student
{
/// <summary>
/// 获取或设置学生账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("student_userid")]
[System.Text.Json.Serialization.JsonPropertyName("student_userid")]
public string StudentUserId { get; set; } = default!;
/// <summary>
/// 获取或设置学生所在的部门 ID即班级列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("partyids")]
[System.Text.Json.Serialization.JsonPropertyName("partyids")]
public long[] DepartmentIdList { get; set; } = default!;
/// <summary>
/// 获取或设置观看时长(单位:秒)。
/// </summary>
[Newtonsoft.Json.JsonProperty("watch_time")]
[System.Text.Json.Serialization.JsonPropertyName("watch_time")]
public int WatchTime { get; set; }
/// <summary>
/// 获取或设置首次进入直播时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("enter_time")]
[System.Text.Json.Serialization.JsonPropertyName("enter_time")]
public long EnterTimestamp { get; set; }
/// <summary>
/// 获取或设置最后离开直播时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("leave_time")]
[System.Text.Json.Serialization.JsonPropertyName("leave_time")]
public long LeaveTimestamp { get; set; }
/// <summary>
/// 获取或设置是否评论。
/// </summary>
[Newtonsoft.Json.JsonProperty("is_comment")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalBooleanConverter))]
[System.Text.Json.Serialization.JsonPropertyName("is_comment")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalBooleanConverter))]
public bool IsComment { get; set; }
}
public class Parent : Student
{
/// <summary>
/// 获取或设置家长账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("parent_userid")]
[System.Text.Json.Serialization.JsonPropertyName("parent_userid")]
public string ParentUserId { get; set; } = default!;
}
public class Visitor
{
/// <summary>
/// 获取或设置微信昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("nickname")]
[System.Text.Json.Serialization.JsonPropertyName("nickname")]
public string? Nickname { get; set; }
/// <summary>
/// 获取或设置观看时长(单位:秒)。
/// </summary>
[Newtonsoft.Json.JsonProperty("watch_time")]
[System.Text.Json.Serialization.JsonPropertyName("watch_time")]
public int WatchTime { get; set; }
/// <summary>
/// 获取或设置首次进入直播时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("enter_time")]
[System.Text.Json.Serialization.JsonPropertyName("enter_time")]
public long EnterTimestamp { get; set; }
/// <summary>
/// 获取或设置最后离开直播时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("leave_time")]
[System.Text.Json.Serialization.JsonPropertyName("leave_time")]
public long LeaveTimestamp { get; set; }
/// <summary>
/// 获取或设置是否评论。
/// </summary>
[Newtonsoft.Json.JsonProperty("is_comment")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalBooleanConverter))]
[System.Text.Json.Serialization.JsonPropertyName("is_comment")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalBooleanConverter))]
public bool IsComment { get; set; }
}
}
/// <summary>
/// 获取或设置学生列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("students")]
[System.Text.Json.Serialization.JsonPropertyName("students")]
public Types.Student[] StudentList { get; set; } = default!;
/// <summary>
/// 获取或设置家长列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("parents")]
[System.Text.Json.Serialization.JsonPropertyName("parents")]
public Types.Parent[] ParentList { get; set; } = default!;
/// <summary>
/// 获取或设置观众列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("visitors")]
[System.Text.Json.Serialization.JsonPropertyName("visitors")]
public Types.Visitor[] VisitorList { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置统计信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("stat_info")]
[System.Text.Json.Serialization.JsonPropertyName("stat_info")]
public Types.Statistics Statistics { get; set; } = default!;
/// <summary>
/// 获取或设置是否还有更多。
/// </summary>
[Newtonsoft.Json.JsonProperty("has_more")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalBooleanConverter))]
[System.Text.Json.Serialization.JsonPropertyName("has_more")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalBooleanConverter))]
public bool HasMore { get; set; }
/// <summary>
/// 获取或设置翻页标记。
/// </summary>
[Newtonsoft.Json.JsonProperty("next_cursor")]
[System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
public string? NextCursor { get; set; }
}
}

View File

@ -0,0 +1,4 @@
{
"livingid": "livingid1",
"next_cursor": "NEXT_CURSOR"
}

View File

@ -0,0 +1,30 @@
{
"errcode": 0,
"errmsg": "ok",
"has_more": 1,
"next_cursor": "NEXT_CURSOR",
"stat_info": {
"students": [
{
"student_userid": "zhansan_child",
"partyids": [10, 11]
},
{
"student_userid": "lisi_child",
"partyids": [5]
}
],
"parents": [
{
"parent_userid": "zhangsan",
"student_userid": "zhansan_child",
"partyids": [10, 11]
},
{
"parent_userid": "lisi",
"student_userid": "lisi_child",
"partyids": [5]
}
]
}
}

View File

@ -0,0 +1,4 @@
{
"livingid": "livingid1",
"next_cursor": "NEXT_CURSOR"
}

View File

@ -0,0 +1,62 @@
{
"errcode": 0,
"errmsg": "ok",
"has_more": 1,
"next_cursor": "NEXT_CURSOR",
"stat_info": {
"students": [
{
"student_userid": "zhansan_child",
"partyids": [10, 11],
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 1
},
{
"student_userid": "lisi_child",
"partyids": [10, 11],
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 0
}
],
"parents": [
{
"parent_userid": "zhangsan",
"student_userid": "zhansan_child",
"partyids": [10, 11],
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 1
},
{
"parent_userid": "lisi",
"student_userid": "lisi_child",
"partyids": [10, 11],
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 0
}
],
"visitors": [
{
"nickname": "wx_nickname1",
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 1
},
{
"nickname": "wx_nickname2",
"watch_time": 30,
"enter_time": 1586433904,
"leave_time": 1586434000,
"is_comment": 0
}
]
}
}