Skip to content

Commit

Permalink
feat(microapp): 新增直播小玩法获取直播信息接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Jun 5, 2024
1 parent 78849d8 commit 20fd8e8
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http;

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast
{
public static class DouyinMicroAppWebcastClientExecuteWebcastMateExtensions
{
/// <summary>
/// <para>异步调用 [POST] /webcastmate/info 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/interaction/develop/server/live/webcastinfo ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.WebcastWebcastMateInfoResponse> ExecuteWebcastWebcastMateInfoAsync(this DouyinMicroAppWebcastClient client, Models.WebcastWebcastMateInfoRequest 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, "webcastmate", "info")
.WithHeader("X-Token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.WebcastWebcastMateInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Order
/// </summary>
[Newtonsoft.Json.JsonProperty("room_id")]
[System.Text.Json.Serialization.JsonPropertyName("room_id")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))]
public string RoomId { get; set; } = default!;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class FailedData
/// </summary>
[Newtonsoft.Json.JsonProperty("roomid")]
[System.Text.Json.Serialization.JsonPropertyName("roomid")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))]
public string RoomId { get; set; } = default!;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models
{
/// <summary>
/// <para>表示 [POST] /webcastmate/info 接口的请求。</para>
/// </summary>
public class WebcastWebcastMateInfoRequest : DouyinMicroAppWebcastRequest
{
/// <summary>
/// 获取或设置直播伴侣 Token。
/// </summary>
[Newtonsoft.Json.JsonProperty("token")]
[System.Text.Json.Serialization.JsonPropertyName("token")]
public string WebcastMateToken { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models
{
/// <summary>
/// <para>表示 [POST] /webcastmate/info 接口的响应。</para>
/// </summary>
public class WebcastWebcastMateInfoResponse : DouyinMicroAppWebcastResponse
{
public static class Types
{
public class Data
{
public static class Types
{
public class LiveInfo
{
/// <summary>
/// 获取或设置直播间 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("room_id")]
[System.Text.Json.Serialization.JsonPropertyName("room_id")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.NumericalStringReadOnlyConverter))]
public string RoomId { get; set; } = default!;

/// <summary>
/// 获取或设置主播的 OpenId。
/// </summary>
[Newtonsoft.Json.JsonProperty("anchor_open_id")]
[System.Text.Json.Serialization.JsonPropertyName("anchor_open_id")]
public string AnchorOpenId { get; set; } = default!;

/// <summary>
/// 获取或设置主播的昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("nick_name")]
[System.Text.Json.Serialization.JsonPropertyName("nick_name")]
public string AnchorNickname { get; set; } = default!;

/// <summary>
/// 获取或设置主播的头像 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("avatar_url")]
[System.Text.Json.Serialization.JsonPropertyName("avatar_url")]
public string AnchorAvatarUrl { get; set; } = default!;
}
}

/// <summary>
/// 获取或设置直播信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("info")]
[System.Text.Json.Serialization.JsonPropertyName("info")]
public Types.LiveInfo LiveInfo { get; set; } = default!;
}
}

/// <summary>
/// 获取或设置返回数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("data")]
[System.Text.Json.Serialization.JsonPropertyName("data")]
public Types.Data Data { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"token": "pJKr395h6O5x2ykBjgrBIxnuot8nn62djr70EocUFXtiN1s9VpsHHuEPdZYKHVJFzftyIOb8lj9i0lrLnUhQsK55pT8shfX98qGuUBO7PSKoIVRq6tWMRdsjPVw="
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"data": {
"info": {
"room_id": 7214015683695250235,
"anchor_open_id": "_000oJIu6APhomK7KIBGqSYm5XYPxCJB_xxx",
"avatar_url": "https://p11.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-avt-0015_973c31e8055f78a41d3f7de3def9821d.jpeg?from=3067671334",
"nick_name": "xxx"
}
}
}

0 comments on commit 20fd8e8

Please sign in to comment.