From 20fd8e8f11a502a65106eb2859aca87c525ccf89 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Wed, 5 Jun 2024 21:47:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(microapp):=20=E6=96=B0=E5=A2=9E=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E5=B0=8F=E7=8E=A9=E6=B3=95=E8=8E=B7=E5=8F=96=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...bcastClientExecuteWebcastMateExtensions.cs | 34 ++++++++++ ...stBusinessDiamondReconciliationResponse.cs | 1 + .../WebcastLiveDataTaskFailDataGetResponse.cs | 1 + .../WebcastWebcastMateInfoRequest.cs | 15 +++++ .../WebcastWebcastMateInfoResponse.cs | 63 +++++++++++++++++++ .../WebcastWebcastMateInfoRequest.json | 3 + .../WebcastWebcastMateInfoResponse.json | 10 +++ 7 files changed, 127 insertions(+) create mode 100644 src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteWebcastMateExtensions.cs create mode 100644 src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoRequest.json create mode 100644 test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoResponse.json diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteWebcastMateExtensions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteWebcastMateExtensions.cs new file mode 100644 index 00000000..60a95431 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteWebcastMateExtensions.cs @@ -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 + { + /// + /// 异步调用 [POST] /webcastmate/info 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Business/WebcastBusinessDiamondReconciliationResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Business/WebcastBusinessDiamondReconciliationResponse.cs index 60d7865b..24efafed 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Business/WebcastBusinessDiamondReconciliationResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Business/WebcastBusinessDiamondReconciliationResponse.cs @@ -16,6 +16,7 @@ public class Order /// [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!; /// diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs index f5970df9..16976240 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs @@ -18,6 +18,7 @@ public class FailedData /// [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!; /// diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoRequest.cs new file mode 100644 index 00000000..896b64cf --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models +{ + /// + /// 表示 [POST] /webcastmate/info 接口的请求。 + /// + public class WebcastWebcastMateInfoRequest : DouyinMicroAppWebcastRequest + { + /// + /// 获取或设置直播伴侣 Token。 + /// + [Newtonsoft.Json.JsonProperty("token")] + [System.Text.Json.Serialization.JsonPropertyName("token")] + public string WebcastMateToken { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoResponse.cs new file mode 100644 index 00000000..4c4f319d --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/WebcastMate/WebcastWebcastMateInfoResponse.cs @@ -0,0 +1,63 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models +{ + /// + /// 表示 [POST] /webcastmate/info 接口的响应。 + /// + public class WebcastWebcastMateInfoResponse : DouyinMicroAppWebcastResponse + { + public static class Types + { + public class Data + { + public static class Types + { + public class LiveInfo + { + /// + /// 获取或设置直播间 ID。 + /// + [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!; + + /// + /// 获取或设置主播的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("anchor_open_id")] + [System.Text.Json.Serialization.JsonPropertyName("anchor_open_id")] + public string AnchorOpenId { get; set; } = default!; + + /// + /// 获取或设置主播的昵称。 + /// + [Newtonsoft.Json.JsonProperty("nick_name")] + [System.Text.Json.Serialization.JsonPropertyName("nick_name")] + public string AnchorNickname { get; set; } = default!; + + /// + /// 获取或设置主播的头像 URL。 + /// + [Newtonsoft.Json.JsonProperty("avatar_url")] + [System.Text.Json.Serialization.JsonPropertyName("avatar_url")] + public string AnchorAvatarUrl { get; set; } = default!; + } + } + + /// + /// 获取或设置直播信息。 + /// + [Newtonsoft.Json.JsonProperty("info")] + [System.Text.Json.Serialization.JsonPropertyName("info")] + public Types.LiveInfo LiveInfo { get; set; } = default!; + } + } + + /// + /// 获取或设置返回数据。 + /// + [Newtonsoft.Json.JsonProperty("data")] + [System.Text.Json.Serialization.JsonPropertyName("data")] + public Types.Data Data { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoRequest.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoRequest.json new file mode 100644 index 00000000..23eadf56 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoRequest.json @@ -0,0 +1,3 @@ +{ + "token": "pJKr395h6O5x2ykBjgrBIxnuot8nn62djr70EocUFXtiN1s9VpsHHuEPdZYKHVJFzftyIOb8lj9i0lrLnUhQsK55pT8shfX98qGuUBO7PSKoIVRq6tWMRdsjPVw=" +} diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoResponse.json new file mode 100644 index 00000000..6f177b51 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/WebcastMate/WebcastWebcastMateInfoResponse.json @@ -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" + } + } +}