-
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
7 changed files
with
163 additions
and
29 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
43 changes: 43 additions & 0 deletions
43
...croApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteQuizExtensions.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,43 @@ | ||
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 DouyinMicroAppWebcastClientExecuteQuizExtensions | ||
{ | ||
/// <summary> | ||
/// <para>异步调用 [GET] /quiz/get 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developer.open-douyin.com/docs/resource/zh-CN/interaction/develop/server/live/get_quiz_list ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.WebcastQuizGetResponse> ExecuteWebcastQuizGetAsync(this DouyinMicroAppWebcastClient client, Models.WebcastQuizGetRequest 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, "quiz", "get") | ||
.WithHeader("x-token", request.AccessToken); | ||
|
||
if (request.Level is not null) | ||
flurlReq.SetQueryParam("level", request.Level.Value); | ||
|
||
if (request.Type is not null) | ||
flurlReq.SetQueryParam("type", request.Type.Value); | ||
|
||
if (request.Number is not null) | ||
flurlReq.SetQueryParam("num", request.Number.Value); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.WebcastQuizGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
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
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
...urlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Quiz/WebcastQuizGetRequest.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.MicroApp.ExtendedSDK.Webcast.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /quiz/get 接口的请求。</para> | ||
/// </summary> | ||
public class WebcastQuizGetRequest : DouyinMicroAppWebcastRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置难度等级。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? Level { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置题目类型。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? Type { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置题目数量。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonIgnore] | ||
[System.Text.Json.Serialization.JsonIgnore] | ||
public int? Number { get; set; } | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...rlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Quiz/WebcastQuizGetResponse.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,62 @@ | ||
namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [GET] /quiz/get 接口的响应。</para> | ||
/// </summary> | ||
public class WebcastQuizGetResponse : DouyinMicroAppWebcastResponse | ||
{ | ||
public static class Types | ||
{ | ||
public class Data | ||
{ | ||
public static class Types | ||
{ | ||
public class Quiz | ||
{ | ||
/// <summary> | ||
/// 获取或设置题目 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("id")] | ||
public string Id { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置题目标题。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("title")] | ||
[System.Text.Json.Serialization.JsonPropertyName("title")] | ||
public string Title { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置题目选项列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("options")] | ||
[System.Text.Json.Serialization.JsonPropertyName("options")] | ||
public string[] OptionList { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// 获取或设置题目答案下标。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("answer")] | ||
[System.Text.Json.Serialization.JsonPropertyName("answer")] | ||
public int AnswerIndex { get; set; } | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置题目列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("list")] | ||
[System.Text.Json.Serialization.JsonPropertyName("list")] | ||
public Types.Quiz[] QuizList { get; set; } = default!; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置返回数据。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("data")] | ||
[System.Text.Json.Serialization.JsonPropertyName("data")] | ||
public Types.Data Data { get; set; } = default!; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...Client.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/Quiz/WebcastQuizGetResponse.json
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,28 @@ | ||
{ | ||
"data": { | ||
"list": [ | ||
{ | ||
"title": "题目1", | ||
"options": [ | ||
"选项1", | ||
"选项2", | ||
"选项3", | ||
"选项4" | ||
], | ||
"answer": 1, | ||
"id": "EYDnokrgyVeOeFa" | ||
}, | ||
{ | ||
"title": "题目2", | ||
"options": [ | ||
"选项1", | ||
"选项2", | ||
"选项3", | ||
"选项4" | ||
], | ||
"answer": 4, | ||
"id": "TlL6LwvWapkoBMv" | ||
} | ||
] | ||
} | ||
} |