-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
823 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
....FlurlHttpClient.ByteDance.DouyinOpen/Extensions/DouyinOpenClientExecuteRoomExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Flurl.Http; | ||
|
||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen | ||
{ | ||
public static class DouyinOpenClientExecuteRoomExtensions | ||
{ | ||
/// <summary> | ||
/// <para>异步调用 [GET] /room/data/room_id/get/ 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/data-open-service/live-data/live-id ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.RoomDataRoomIdGetResponse> ExecuteRoomDataRoomIdGetAsync(this DouyinOpenClient client, Models.RoomDataRoomIdGetRequest 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.Get, "room", "data", "room_id", "get/") | ||
.WithHeader("access-token", request.AccessToken) | ||
.SetQueryParam("open_id", request.OpenId) | ||
.SetQueryParam("start_time", request.StartTimestamp) | ||
.SetQueryParam("end_time", request.EndTimestamp); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.RoomDataRoomIdGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [GET] /room/data/interactive/get/ 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/data-open-service/live-data/live-interactive-data ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.RoomDataInteractiveGetResponse> ExecuteRoomDataInteractiveGetAsync(this DouyinOpenClient client, Models.RoomDataInteractiveGetRequest 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.Get, "room", "data", "interactive", "get/") | ||
.WithHeader("access-token", request.AccessToken) | ||
.SetQueryParam("open_id", request.OpenId) | ||
.SetQueryParam("live_id", request.LiveId) | ||
.SetQueryParam("room_id", request.RoomId); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.RoomDataInteractiveGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [GET] /room/data/audience/get/ 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/data-open-service/live-data/live-audience-data ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.RoomDataAudienceGetResponse> ExecuteRoomDataAudienceGetAsync(this DouyinOpenClient client, Models.RoomDataAudienceGetRequest 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.Get, "room", "data", "audience", "get/") | ||
.WithHeader("access-token", request.AccessToken) | ||
.SetQueryParam("open_id", request.OpenId) | ||
.SetQueryParam("live_id", request.LiveId) | ||
.SetQueryParam("room_id", request.RoomId); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.RoomDataAudienceGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [GET] /room/data/base/get/ 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/data-open-service/live-data/live-base-data ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.RoomDataBaseGetResponse> ExecuteRoomDataBaseGetAsync(this DouyinOpenClient client, Models.RoomDataBaseGetRequest 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.Get, "room", "data", "base", "get/") | ||
.WithHeader("access-token", request.AccessToken) | ||
.SetQueryParam("open_id", request.OpenId) | ||
.SetQueryParam("live_id", request.LiveId) | ||
.SetQueryParam("room_id", request.RoomId); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.RoomDataBaseGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/JS/JSGetTicketRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/JS/JSGetTicketResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/Room/RoomDataAudienceGetRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /room/data/audience/get/ 接口的请求。</para> | ||
/// </summary> | ||
public class RoomDataAudienceGetRequest : DouyinOpenRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置业务线。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? LiveId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置用户唯一标识。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string OpenId { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置直播间 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string RoomId { get; set; } = string.Empty; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/Room/RoomDataAudienceGetResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /room/data/audience/get/ 接口的响应。</para> | ||
/// </summary> | ||
public class RoomDataAudienceGetResponse : DouyinOpenResponse | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
public static class Types | ||
{ | ||
public class DataReadyStatusInfo : RoomDataInteractiveGetResponse.Types.Data.Types.DataReadyStatusInfo | ||
Check notice Code scanning / CodeQL Class has same name as super class Note
Class has the same name as its base class.
|
||
{ | ||
} | ||
|
||
public class Statistics : RoomDataInteractiveGetResponse.Types.Data.Types.Statistics | ||
Check notice Code scanning / CodeQL Class has same name as super class Note
Class has the same name as its base class.
|
||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置数据就绪状态列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("data_ready_status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("data_ready_status")] | ||
public Types.DataReadyStatusInfo[] DataReadyStatusList { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置统计数据列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("stats")] | ||
[System.Text.Json.Serialization.JsonPropertyName("stats")] | ||
public Types.Statistics[] StatisticsList { get; set; } = default!; | ||
} | ||
} | ||
|
||
[Newtonsoft.Json.JsonProperty("err_no")] | ||
[System.Text.Json.Serialization.JsonPropertyName("err_no")] | ||
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)] | ||
public int ErrorNumber { get; set; } | ||
|
||
[Newtonsoft.Json.JsonProperty("err_msg")] | ||
[System.Text.Json.Serialization.JsonPropertyName("err_msg")] | ||
public string? ErrorMessage { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置请求唯一标识。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("log_id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("log_id")] | ||
public string? LogId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置返回数据。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("data")] | ||
[System.Text.Json.Serialization.JsonPropertyName("data")] | ||
public Types.Data Data { get; set; } = default!; | ||
|
||
public override bool IsSuccessful() | ||
{ | ||
return GetRawStatus() == 200 && ErrorNumber == 0; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/Room/RoomDataBaseGetRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /room/data/base/get/ 接口的请求。</para> | ||
/// </summary> | ||
public class RoomDataBaseGetRequest : DouyinOpenRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置业务线。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? LiveId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置用户唯一标识。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string OpenId { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置直播间 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string RoomId { get; set; } = string.Empty; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/Room/RoomDataBaseGetResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /room/data/base/get/ 接口的响应。</para> | ||
/// </summary> | ||
public class RoomDataBaseGetResponse : DouyinOpenResponse | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
public static class Types | ||
{ | ||
public class DataReadyStatusInfo : RoomDataInteractiveGetResponse.Types.Data.Types.DataReadyStatusInfo | ||
Check notice Code scanning / CodeQL Class has same name as super class Note
Class has the same name as its base class.
|
||
{ | ||
} | ||
|
||
public class Statistics : RoomDataInteractiveGetResponse.Types.Data.Types.Statistics | ||
Check notice Code scanning / CodeQL Class has same name as super class Note
Class has the same name as its base class.
|
||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置数据就绪状态列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("data_ready_status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("data_ready_status")] | ||
public Types.DataReadyStatusInfo[] DataReadyStatusList { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置统计数据列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("stats")] | ||
[System.Text.Json.Serialization.JsonPropertyName("stats")] | ||
public Types.Statistics[] StatisticsList { get; set; } = default!; | ||
} | ||
} | ||
|
||
[Newtonsoft.Json.JsonProperty("err_no")] | ||
[System.Text.Json.Serialization.JsonPropertyName("err_no")] | ||
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)] | ||
public int ErrorNumber { get; set; } | ||
|
||
[Newtonsoft.Json.JsonProperty("err_msg")] | ||
[System.Text.Json.Serialization.JsonPropertyName("err_msg")] | ||
public string? ErrorMessage { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置请求唯一标识。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("log_id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("log_id")] | ||
public string? LogId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置返回数据。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("data")] | ||
[System.Text.Json.Serialization.JsonPropertyName("data")] | ||
public Types.Data Data { get; set; } = default!; | ||
|
||
public override bool IsSuccessful() | ||
{ | ||
return GetRawStatus() == 200 && ErrorNumber == 0; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/SKIT.FlurlHttpClient.ByteDance.DouyinOpen/Models/Room/RoomDataInteractiveGetRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.DouyinOpen.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /room/data/interactive/get/ 接口的请求。</para> | ||
/// </summary> | ||
public class RoomDataInteractiveGetRequest : DouyinOpenRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置业务线。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? LiveId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置用户唯一标识。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string OpenId { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// 获取或设置直播间 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public string RoomId { get; set; } = string.Empty; | ||
} | ||
} |
Oops, something went wrong.