diff --git a/docs/MicroApp/Basic_ModelDefinition.md b/docs/MicroApp/Basic_ModelDefinition.md index e127711d..8cfb48b8 100644 --- a/docs/MicroApp/Basic_ModelDefinition.md +++ b/docs/MicroApp/Basic_ModelDefinition.md @@ -8,7 +8,7 @@ 再有,每个对象的命名与官方文档的接口地址大体保持一致。例如刚刚提到的发送订阅消息,它的接口地址是 `[POST] /apps/message/custom/send`,将其中的反斜杠去掉、并以大驼峰命名法的方式调整它,就可以得到前文提到的几个对象了。如果路由中带有版本信息,那么版本号一般都在结尾处,例如接口 `[POST] /v2/tags/image` 对应的是 `TagsImageV2`。 -完整的模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.ByteDance.Api/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/SDK/OpenApi/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/SDK/ProductApi/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/SDK/RoleApi/Models_ 目录。 +完整的模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.ByteDance.Api/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/ExtendedSdk/OpenApi/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/ExtendedSdk/ProductApi/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/ExtendedSdk/RoleApi/Models_、_src/SKIT.FlurlHttpClient.ByteDance.Api/ExtendedSdk/Webcast/Models_ 目录。 --- @@ -76,3 +76,13 @@ | √ | 代商家入驻抖音开放平台 | | + +#### 4. 直播小玩法 + +
+ +[展开查看] + +| | 抖音 API | 备注 | +| :-: | :------: | :--: | +| √ | 直播能力 | | diff --git a/docs/MicroApp/README.md b/docs/MicroApp/README.md index ecd36a1c..041e5c35 100644 --- a/docs/MicroApp/README.md +++ b/docs/MicroApp/README.md @@ -71,7 +71,7 @@ else } ``` -### 独立的(服务商平台、泛知识课程库、泛知识角色系统等)扩展客户端: +### 独立的扩展客户端(服务商平台、泛知识课程库、泛知识角色系统、直播小玩法等): 部分 API 的接入点、接口模型公共参数等配置项与基础 API 完全不同,需要使用独立的扩展客户端。 @@ -114,6 +114,19 @@ var options = new DouyinMicroAppRoleApiClientOptions() var client = DouyinMicroAppRoleApiClientBuilder.Create(options).Build(); ``` +- 直播小玩法: + +```csharp +using SKIT.FlurlHttpClient.ByteDance.MicroApp.SDK.Webcast; + +var options = new DouyinMicroAppWebcastClientOptions() +{ + AppId = "抖音小程序 AppId", + AppSecret = "抖音小程序 AppSecret" +}; +var client = DouyinMicroAppWebcastClientBuilder.Create(options).Build(); +``` + 这些扩展客户端在用法上基础客户端完全相同,只需引入各自的命名空间即可。 --- diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClient.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClient.cs index fe2e51af..bfd2856a 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClient.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClient.cs @@ -16,16 +16,6 @@ public class DouyinMicroAppClient : CommonClientBase, ICommonClient /// public Settings.Credentials Credentials { get; } - /// - /// 获取当前客户端使用的抖音小程序 API 接入点。 - /// - protected internal string EndpointForDefault { get; } - - /// - /// 获取当前客户端使用的抖音小程序直播小玩法 API 接入点。 - /// - protected internal string EndpointForWebcast { get; } - /// /// 用指定的配置项初始化 类的新实例。 /// @@ -47,8 +37,6 @@ internal protected DouyinMicroAppClient(DouyinMicroAppClientOptions options, Htt if (options is null) throw new ArgumentNullException(nameof(options)); Credentials = new Settings.Credentials(options); - EndpointForDefault = options.Endpoint; - EndpointForWebcast = options.EndpointForWebcastAPI; FlurlClient.BaseUrl = options.Endpoint ?? DouyinMicroAppEndpoints.DEFAULT; FlurlClient.WithTimeout(options.Timeout <= 0 ? Timeout.InfiniteTimeSpan : TimeSpan.FromMilliseconds(options.Timeout)); diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClientOptions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClientOptions.cs index d57566b8..dc576861 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClientOptions.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppClientOptions.cs @@ -17,12 +17,6 @@ public class DouyinMicroAppClientOptions /// public string Endpoint { get; set; } = DouyinMicroAppEndpoints.DEFAULT; - /// - /// 获取或设置抖音小程序直播小玩法 API 入口点。 - /// 默认值: - /// - public string EndpointForWebcastAPI { get; set; } = DouyinMicroAppWebcastEndpoints.DEFAULT; - /// /// 获取或设置抖音小程序 AppId。 /// diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppEndpoints.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppEndpoints.cs index e3449019..6d7e0cad 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppEndpoints.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppEndpoints.cs @@ -15,15 +15,4 @@ public static class DouyinMicroAppEndpoints /// public const string SANGBOX = "https://open-sandbox.douyin.com/api"; } - - /// - /// 抖音小程序直播小玩法 API 接口域名。 - /// - public static class DouyinMicroAppWebcastEndpoints - { - /// - /// 主域名(默认)。 - /// - public const string DEFAULT = "https://webcast.bytedance.com/api"; - } } diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppRequest.cs index c4a16ca2..05eb8c9e 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/DouyinMicroAppRequest.cs @@ -7,7 +7,9 @@ public abstract class DouyinMicroAppRequest : CommonRequestBase, ICommonRequest { /// /// 获取或设置抖音小程序的 AccessToken。 - /// 注意:部分第三方平台的接口中该字段表示授权方的 AuthorizerAccessToken。 + /// + /// 注意:部分第三方平台的接口中该字段表示授权方的 AuthorizerAccessToken。 + /// /// [Newtonsoft.Json.JsonIgnore] [System.Text.Json.Serialization.JsonIgnore] diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClient.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClient.cs new file mode 100644 index 00000000..574ea53f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClient.cs @@ -0,0 +1,99 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Flurl.Http; + +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 一个抖音小程序直播小玩法 API HTTP 客户端。 + /// + public class DouyinMicroAppWebcastClient : CommonClientBase, ICommonClient + { + /// + /// 获取当前客户端使用的抖音小程序凭证。 + /// + public Settings.Credentials Credentials { get; } + + /// + /// 用指定的配置项初始化 类的新实例。 + /// + /// 配置项。 + public DouyinMicroAppWebcastClient(DouyinMicroAppWebcastClientOptions options) + : this(options, null) + { + } + + /// + /// + /// + /// + /// + /// + internal protected DouyinMicroAppWebcastClient(DouyinMicroAppWebcastClientOptions options, HttpClient? httpClient, bool disposeClient = true) + : base(httpClient, disposeClient) + { + if (options is null) throw new ArgumentNullException(nameof(options)); + + Credentials = new Settings.Credentials(options); + + FlurlClient.BaseUrl = options.Endpoint ?? DouyinMicroAppWebcastEndpoints.DEFAULT; + FlurlClient.WithTimeout(options.Timeout <= 0 ? Timeout.InfiniteTimeSpan : TimeSpan.FromMilliseconds(options.Timeout)); + } + + /// + /// 使用当前客户端生成一个新的 对象。 + /// + /// + /// + /// + /// + public IFlurlRequest CreateFlurlRequest(DouyinMicroAppWebcastRequest request, HttpMethod httpMethod, params object[] urlSegments) + { + IFlurlRequest flurlRequest = base.CreateFlurlRequest(request, httpMethod, urlSegments); + + return flurlRequest; + } + + /// + /// 异步发起请求。 + /// + /// + /// + /// + /// + /// + public async Task SendFlurlRequestAsync(IFlurlRequest flurlRequest, HttpContent? httpContent = null, CancellationToken cancellationToken = default) + where T : DouyinMicroAppWebcastResponse, new() + { + if (flurlRequest is null) throw new ArgumentNullException(nameof(flurlRequest)); + + using IFlurlResponse flurlResponse = await base.SendFlurlRequestAsync(flurlRequest, httpContent, cancellationToken).ConfigureAwait(false); + return await WrapFlurlResponseAsJsonAsync(flurlResponse, cancellationToken).ConfigureAwait(false); + } + + /// + /// 异步发起请求。 + /// + /// + /// + /// + /// + /// + public async Task SendFlurlRequestAsJsonAsync(IFlurlRequest flurlRequest, object? data = null, CancellationToken cancellationToken = default) + where T : DouyinMicroAppWebcastResponse, new() + { + if (flurlRequest is null) throw new ArgumentNullException(nameof(flurlRequest)); + + bool isSimpleRequest = data is null || + flurlRequest.Verb == HttpMethod.Get || + flurlRequest.Verb == HttpMethod.Head || + flurlRequest.Verb == HttpMethod.Options; + using IFlurlResponse flurlResponse = isSimpleRequest ? + await base.SendFlurlRequestAsync(flurlRequest, null, cancellationToken) : + await base.SendFlurlRequestAsJsonAsync(flurlRequest, data, cancellationToken).ConfigureAwait(false); + return await WrapFlurlResponseAsJsonAsync(flurlResponse, cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientBuilder.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientBuilder.cs new file mode 100644 index 00000000..3f193e99 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientBuilder.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; + +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 用于构造 实例的构造器。 + /// + public partial class DouyinMicroAppWebcastClientBuilder : ICommonClientBuilder + { + private readonly DouyinMicroAppWebcastClientOptions _options; + private readonly IList> _configures; + private readonly IList _interceptors; + private HttpClient? _httpClient; + private bool? _disposeClient; + + private DouyinMicroAppWebcastClientBuilder(DouyinMicroAppWebcastClientOptions options) + { + _options = options; + _configures = new List>(); + _interceptors = new List(); + } + + ICommonClientBuilder ICommonClientBuilder.ConfigureSettings(Action configure) + { + return ConfigureSettings(configure); + } + + ICommonClientBuilder ICommonClientBuilder.UseInterceptor(HttpInterceptor interceptor) + { + return UseInterceptor(interceptor); + } + + ICommonClientBuilder ICommonClientBuilder.UseHttpClient(HttpClient httpClient, bool disposeClient) + { + return UseHttpClient(httpClient, disposeClient); + } + + public DouyinMicroAppWebcastClientBuilder ConfigureSettings(Action configure) + { + if (configure is null) throw new ArgumentNullException(nameof(configure)); + + _configures.Add(configure); + return this; + } + + public DouyinMicroAppWebcastClientBuilder UseInterceptor(HttpInterceptor interceptor) + { + if (interceptor is null) throw new ArgumentNullException(nameof(interceptor)); + + _interceptors.Add(interceptor); + return this; + } + + public DouyinMicroAppWebcastClientBuilder UseHttpClient(HttpClient httpClient, bool disposeClient = true) + { + if (httpClient is null) throw new ArgumentNullException(nameof(httpClient)); + + _httpClient = httpClient; + _disposeClient = disposeClient; + return this; + } + + public DouyinMicroAppWebcastClient Build() + { + DouyinMicroAppWebcastClient client = _disposeClient.HasValue + ? new DouyinMicroAppWebcastClient(_options, _httpClient, _disposeClient.Value) + : new DouyinMicroAppWebcastClient(_options, _httpClient); + + foreach (Action configure in _configures) + { + client.Configure(configure); + } + + foreach (HttpInterceptor interceptor in _interceptors) + { + client.Interceptors.Add(interceptor); + } + + return client; + } + } + + partial class DouyinMicroAppWebcastClientBuilder + { + public static DouyinMicroAppWebcastClientBuilder Create(DouyinMicroAppWebcastClientOptions options) + { + if (options is null) throw new ArgumentNullException(nameof(options)); + + return new DouyinMicroAppWebcastClientBuilder(options); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientOptions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientOptions.cs new file mode 100644 index 00000000..f5ba3ade --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastClientOptions.cs @@ -0,0 +1,30 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 一个用于构造 时使用的配置项。 + /// + public class DouyinMicroAppWebcastClientOptions + { + /// + /// 获取或设置请求超时时间(单位:毫秒)。 + /// 默认值:30000 + /// + public int Timeout { get; set; } = 30 * 1000; + + /// + /// 获取或设置抖音小程序直播小玩法 API 入口点。 + /// 默认值: + /// + public string Endpoint { get; set; } = DouyinMicroAppWebcastEndpoints.DEFAULT; + + /// + /// 获取或设置抖音小程序 AppId。 + /// + public string AppId { get; set; } = default!; + + /// + /// 获取或设置抖音小程序 AppSecret。 + /// + public string AppSecret { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastEndpoints.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastEndpoints.cs new file mode 100644 index 00000000..a507d441 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastEndpoints.cs @@ -0,0 +1,13 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 抖音小程序直播小玩法 API 接口域名。 + /// + public static class DouyinMicroAppWebcastEndpoints + { + /// + /// 主域名(默认)。 + /// + public const string DEFAULT = "https://webcast.bytedance.com/api"; + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastRequest.cs new file mode 100644 index 00000000..49188a19 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 抖音小程序直播小玩法 API 请求的基类。 + /// + public abstract class DouyinMicroAppWebcastRequest : CommonRequestBase, ICommonRequest + { + /// + /// 获取或设置抖音小程序的 AccessToken。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public virtual string? AccessToken { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastResponse.cs new file mode 100644 index 00000000..07ddb23f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/DouyinMicroAppWebcastResponse.cs @@ -0,0 +1,34 @@ +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast +{ + /// + /// 抖音小程序直播小玩法 API 响应的基类。 + /// + public abstract class DouyinMicroAppWebcastResponse : CommonResponseBase, ICommonResponse + { + /// + /// 获取抖音小程序 API 返回的详细错误号。 + /// + [Newtonsoft.Json.JsonProperty("errcode")] + [System.Text.Json.Serialization.JsonPropertyName("errcode")] + public virtual long ErrorCode { get; set; } + + /// + /// 获取抖音小程序 API 返回的错误描述。 + /// + [Newtonsoft.Json.JsonProperty("errmsg")] + [System.Text.Json.Serialization.JsonPropertyName("errmsg")] + public virtual string? ErrorMessage { get; set; } + + /// + /// 获取一个值,该值指示调用抖音小程序 API 是否成功。 + /// + ///(即 HTTP 状态码为 200,且 值为 0) + /// + /// + /// + public override bool IsSuccessful() + { + return GetRawStatus() == 200 && ErrorCode == 0; + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteGiftExtensions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteGiftExtensions.cs new file mode 100644 index 00000000..278225ef --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteGiftExtensions.cs @@ -0,0 +1,37 @@ +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 DouyinMicroAppWebcastClientExecuteGiftExtensions + { + /// + /// 异步调用 [POST] /gift/top_gift 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWebcastGiftTopGiftAsync(this DouyinMicroAppWebcastClient client, Models.WebcastGiftTopGiftRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + if (request.AppId is null) + request.AppId = client.Credentials.AppId; + + IFlurlRequest flurlReq = client + .CreateFlurlRequest(request, HttpMethod.Post, "gift", "top_gift") + .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/Extensions/DouyinMicroAppWebcastClientExecuteLinkMicExtensions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteLinkMicExtensions.cs new file mode 100644 index 00000000..736d8b22 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteLinkMicExtensions.cs @@ -0,0 +1,37 @@ +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 DouyinMicroAppWebcastClientExecuteLinkMicExtensions + { + /// + /// 异步调用 [POST] /linkmic/query 接口。 + /// + /// REF:
+ /// + ///
+ ///
+ /// + /// + /// + /// + public static async Task ExecuteWebcastLinkMicQueryAsync(this DouyinMicroAppWebcastClient client, Models.WebcastLinkMicQueryRequest request, CancellationToken cancellationToken = default) + { + if (client is null) throw new ArgumentNullException(nameof(client)); + if (request is null) throw new ArgumentNullException(nameof(request)); + + if (request.AppId is null) + request.AppId = client.Credentials.AppId; + + IFlurlRequest flurlReq = client + .CreateFlurlRequest(request, HttpMethod.Post, "linkmic", "query") + .WithHeader("x-token", request.AccessToken); + + return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Extensions/DouyinMicroAppClientExecuteWebcastExtensions.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteLiveDataExtensions.cs similarity index 58% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Extensions/DouyinMicroAppClientExecuteWebcastExtensions.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteLiveDataExtensions.cs index fe74693a..d68d50d2 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Extensions/DouyinMicroAppClientExecuteWebcastExtensions.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Extensions/DouyinMicroAppWebcastClientExecuteLiveDataExtensions.cs @@ -4,11 +4,10 @@ using System.Threading.Tasks; using Flurl.Http; -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast { - public static class DouyinMicroAppClientExecuteWebcastExtensions + public static class DouyinMicroAppWebcastClientExecuteLiveDataExtensions { - #region LiveData /// /// 异步调用 [POST] /live_data/task/start 接口。 /// @@ -20,7 +19,7 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions /// /// /// - public static async Task ExecuteWebcastLiveDataTaskStartAsync(this DouyinMicroAppClient client, Models.WebcastLiveDataTaskStartRequest request, CancellationToken cancellationToken = default) + public static async Task ExecuteWebcastLiveDataTaskStartAsync(this DouyinMicroAppWebcastClient client, Models.WebcastLiveDataTaskStartRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); @@ -30,7 +29,6 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Post, "live_data", "task", "start") - .WithUrl($"{client.EndpointForWebcast}/live_data/task/start") .WithHeader("access-token", request.AccessToken); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -47,7 +45,7 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions /// /// /// - public static async Task ExecuteWebcastLiveDataTaskStopAsync(this DouyinMicroAppClient client, Models.WebcastLiveDataTaskStopRequest request, CancellationToken cancellationToken = default) + public static async Task ExecuteWebcastLiveDataTaskStopAsync(this DouyinMicroAppWebcastClient client, Models.WebcastLiveDataTaskStopRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); @@ -57,7 +55,6 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Post, "live_data", "task", "stop") - .WithUrl($"{client.EndpointForWebcast}/live_data/task/stop") .WithHeader("access-token", request.AccessToken); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -74,7 +71,7 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions /// /// /// - public static async Task ExecuteWebcastLiveDataTaskGetAsync(this DouyinMicroAppClient client, Models.WebcastLiveDataTaskGetRequest request, CancellationToken cancellationToken = default) + public static async Task ExecuteWebcastLiveDataTaskGetAsync(this DouyinMicroAppWebcastClient client, Models.WebcastLiveDataTaskGetRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); @@ -84,7 +81,6 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Get, "live_data", "task", "get") - .WithUrl($"{client.EndpointForWebcast}/live_data/task/get") .WithHeader("access-token", request.AccessToken) .WithHeader("appid", request.AppId) .WithHeader("roomid", request.RoomId) @@ -104,7 +100,7 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions /// /// /// - public static async Task ExecuteWebcastLiveDataTaskFailDataGetAsync(this DouyinMicroAppClient client, Models.WebcastLiveDataTaskFailDataGetRequest request, CancellationToken cancellationToken = default) + public static async Task ExecuteWebcastLiveDataTaskFailDataGetAsync(this DouyinMicroAppWebcastClient client, Models.WebcastLiveDataTaskFailDataGetRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); @@ -114,7 +110,6 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Get, "live_data", "task", "fail_data", "get") - .WithUrl($"{client.EndpointForWebcast}/live_data/task/fail_data/get") .WithHeader("access-token", request.AccessToken) .WithHeader("appid", request.AppId) .WithHeader("roomid", request.RoomId) @@ -124,64 +119,5 @@ public static class DouyinMicroAppClientExecuteWebcastExtensions return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } - #endregion - - #region Gift - /// - /// 异步调用 [POST] /gift/top_gift 接口。 - /// - /// REF:
- /// - ///
- ///
- /// - /// - /// - /// - public static async Task ExecuteWebcastGiftTopGiftAsync(this DouyinMicroAppClient client, Models.WebcastGiftTopGiftRequest request, CancellationToken cancellationToken = default) - { - if (client is null) throw new ArgumentNullException(nameof(client)); - if (request is null) throw new ArgumentNullException(nameof(request)); - - if (request.AppId is null) - request.AppId = client.Credentials.AppId; - - IFlurlRequest flurlReq = client - .CreateFlurlRequest(request, HttpMethod.Post, "gift", "top_gift") - .WithUrl($"{client.EndpointForWebcast}/gift/top_gift") - .WithHeader("x-token", request.AccessToken); - - return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); - } - #endregion - - #region LinkMic - /// - /// 异步调用 [POST] /linkmic/query 接口。 - /// - /// REF:
- /// - ///
- ///
- /// - /// - /// - /// - public static async Task ExecuteWebcastLinkMicQueryAsync(this DouyinMicroAppClient client, Models.WebcastLinkMicQueryRequest request, CancellationToken cancellationToken = default) - { - if (client is null) throw new ArgumentNullException(nameof(client)); - if (request is null) throw new ArgumentNullException(nameof(request)); - - if (request.AppId is null) - request.AppId = client.Credentials.AppId; - - IFlurlRequest flurlReq = client - .CreateFlurlRequest(request, HttpMethod.Post, "linkmic", "query") - .WithUrl($"{client.EndpointForWebcast}/linkmic/query") - .WithHeader("x-token", request.AccessToken); - - return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); - } - #endregion } } diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftRequest.cs similarity index 88% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftRequest.cs index bcb63b7b..d1064b0a 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftRequest.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /gift/top_gift 接口的请求。 /// - public class WebcastGiftTopGiftRequest : DouyinMicroAppRequest + public class WebcastGiftTopGiftRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftResponse.cs similarity index 89% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftResponse.cs index fcd5fe4e..69f00735 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/Gift/WebcastGiftTopGiftResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/Gift/WebcastGiftTopGiftResponse.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /gift/top_gift 接口的响应。 /// - public class WebcastGiftTopGiftResponse : DouyinMicroAppResponse + public class WebcastGiftTopGiftResponse : DouyinMicroAppWebcastResponse { public static class Types { diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryRequest.cs similarity index 83% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryRequest.cs index 4609e1fe..09615853 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryRequest.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /linkmic/query 接口的请求。 /// - public class WebcastLinkMicQueryRequest : DouyinMicroAppRequest + public class WebcastLinkMicQueryRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryResponse.cs similarity index 97% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryResponse.cs index ec7ff36a..00e7282c 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LinkMic/WebcastLinkMicQueryResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LinkMic/WebcastLinkMicQueryResponse.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /linkmic/query 接口的响应。 /// - public class WebcastLinkMicQueryResponse : DouyinMicroAppResponse + public class WebcastLinkMicQueryResponse : DouyinMicroAppWebcastResponse { public static class Types { diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs similarity index 94% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs index 5d987aac..88ebd713 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetRequest.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [GET] /live_data/task/fail_data/get 接口的请求。 /// - public class WebcastLiveDataTaskFailDataGetRequest : DouyinMicroAppRequest + public class WebcastLiveDataTaskFailDataGetRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs similarity index 93% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs index cef5530c..f5970df9 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskFailDataGetResponse.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [GET] /live_data/task/fail_data/get 接口的响应。 /// - public class WebcastLiveDataTaskFailDataGetResponse : DouyinMicroAppResponse + public class WebcastLiveDataTaskFailDataGetResponse : DouyinMicroAppWebcastResponse { public static class Types { @@ -59,26 +59,22 @@ public class FailedData } } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_no")] [System.Text.Json.Serialization.JsonPropertyName("err_no")] public override long ErrorCode { get; set; } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_msg")] [System.Text.Json.Serialization.JsonPropertyName("err_msg")] public override string? ErrorMessage { get; set; } /// - /// + /// 获取或设置请求日志 ID。 /// [Newtonsoft.Json.JsonProperty("logid")] [System.Text.Json.Serialization.JsonPropertyName("logid")] - public override string? LogId { get; set; } + public string? LogId { get; set; } /// /// 获取或设置返回数据。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetRequest.cs similarity index 86% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetRequest.cs index 91388bcf..48f44df6 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetRequest.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [GET] /live_data/task/get 接口的请求。 /// - public class WebcastLiveDataTaskGetRequest : DouyinMicroAppRequest + public class WebcastLiveDataTaskGetRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetResponse.cs similarity index 85% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetResponse.cs index 4626325c..c9f400b0 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskGetResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskGetResponse.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [GET] /live_data/task/get 接口的响应。 /// - public class WebcastLiveDataTaskGetResponse : DouyinMicroAppResponse + public class WebcastLiveDataTaskGetResponse : DouyinMicroAppWebcastResponse { public static class Types { @@ -18,26 +18,22 @@ public class Data } } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_no")] [System.Text.Json.Serialization.JsonPropertyName("err_no")] public override long ErrorCode { get; set; } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_msg")] [System.Text.Json.Serialization.JsonPropertyName("err_msg")] public override string? ErrorMessage { get; set; } /// - /// + /// 获取或设置请求日志 ID。 /// [Newtonsoft.Json.JsonProperty("logid")] [System.Text.Json.Serialization.JsonPropertyName("logid")] - public override string? LogId { get; set; } + public string? LogId { get; set; } /// /// 获取或设置返回数据。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartRequest.cs similarity index 92% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartRequest.cs index 941c93d9..0a5d4472 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartRequest.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /live_data/task/start 接口的请求。 /// - public class WebcastLiveDataTaskStartRequest : DouyinMicroAppRequest + public class WebcastLiveDataTaskStartRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartResponse.cs similarity index 85% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartResponse.cs index 20546f59..09cc7bb5 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStartResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStartResponse.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /live_data/task/start 接口的响应。 /// - public class WebcastLiveDataTaskStartResponse : DouyinMicroAppResponse + public class WebcastLiveDataTaskStartResponse : DouyinMicroAppWebcastResponse { public static class Types { @@ -18,26 +18,22 @@ public class Data } } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_no")] [System.Text.Json.Serialization.JsonPropertyName("err_no")] public override long ErrorCode { get; set; } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_msg")] [System.Text.Json.Serialization.JsonPropertyName("err_msg")] public override string? ErrorMessage { get; set; } /// - /// + /// 获取或设置请求日志 ID。 /// [Newtonsoft.Json.JsonProperty("logid")] [System.Text.Json.Serialization.JsonPropertyName("logid")] - public override string? LogId { get; set; } + public string? LogId { get; set; } /// /// 获取或设置返回数据。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopRequest.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopRequest.cs similarity index 92% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopRequest.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopRequest.cs index 7d90806a..1f675ace 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopRequest.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopRequest.cs @@ -1,9 +1,9 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /live_data/task/stop 接口的请求。 /// - public class WebcastLiveDataTaskStopRequest : DouyinMicroAppRequest + public class WebcastLiveDataTaskStopRequest : DouyinMicroAppWebcastRequest { /// /// 获取或设置小玩法的 AppId。如果不指定将使用构造 时的 参数。 diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopResponse.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopResponse.cs similarity index 76% rename from src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopResponse.cs rename to src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopResponse.cs index f6c45ea9..1145464c 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/Models/Webcast/LiveData/WebcastLiveDataTaskStopResponse.cs +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Models/LiveData/WebcastLiveDataTaskStopResponse.cs @@ -1,29 +1,25 @@ -namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models { /// /// 表示 [POST] /live_data/task/stop 接口的响应。 /// - public class WebcastLiveDataTaskStopResponse : DouyinMicroAppResponse + public class WebcastLiveDataTaskStopResponse : DouyinMicroAppWebcastResponse { - /// /// - /// [Newtonsoft.Json.JsonProperty("err_no")] [System.Text.Json.Serialization.JsonPropertyName("err_no")] public override long ErrorCode { get; set; } - /// /// - /// [Newtonsoft.Json.JsonProperty("err_msg")] [System.Text.Json.Serialization.JsonPropertyName("err_msg")] public override string? ErrorMessage { get; set; } /// - /// + /// 获取或设置请求日志 ID。 /// [Newtonsoft.Json.JsonProperty("logid")] [System.Text.Json.Serialization.JsonPropertyName("logid")] - public override string? LogId { get; set; } + public string? LogId { get; set; } } } diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Settings/Credentials.cs b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Settings/Credentials.cs new file mode 100644 index 00000000..96ebae60 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/ExtendedSDK/Webcast/Settings/Credentials.cs @@ -0,0 +1,25 @@ +using System; + +namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Settings +{ + public class Credentials + { + /// + /// 初始化客户端时 的副本。 + /// + public string AppId { get; } + + /// + /// 初始化客户端时 的副本。 + /// + public string AppSecret { get; } + + internal Credentials(DouyinMicroAppWebcastClientOptions options) + { + if (options is null) throw new ArgumentNullException(nameof(options)); + + AppId = options.AppId; + AppSecret = options.AppSecret; + } + } +} diff --git a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/SKIT.FlurlHttpClient.ByteDance.MicroApp.csproj b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/SKIT.FlurlHttpClient.ByteDance.MicroApp.csproj index 10f0b78b..e5f51554 100644 --- a/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/SKIT.FlurlHttpClient.ByteDance.MicroApp.csproj +++ b/src/SKIT.FlurlHttpClient.ByteDance.MicroApp/SKIT.FlurlHttpClient.ByteDance.MicroApp.csproj @@ -15,7 +15,7 @@ https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.ByteDance Flurl.Http ByteDance MicroApp 字节 字节跳动 头条 今日头条 抖音 字节小程序 字节跳动小程序 头条小程序 今日头条小程序 抖音小程序 3.0.0-preview.1 - 基于 Flurl.Http 的抖音小程序开放平台 API 客户端,支持小程序、小游戏、服务商平台、泛知识课程库+角色系统、直播小玩法等接口。 + 基于 Flurl.Http 的抖音小程序开放平台 API 客户端,支持小程序、小游戏、服务商平台、泛知识课程库、泛知识角色系统、直播小玩法等接口。 Fu Diwei git https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.ByteDance.git diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/IMPORTANT_CodeAnalyzeTests.cs b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/IMPORTANT_CodeAnalyzeTests.cs index 3deaca45..53c245cd 100644 --- a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/IMPORTANT_CodeAnalyzeTests.cs +++ b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/IMPORTANT_CodeAnalyzeTests.cs @@ -9,6 +9,7 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests using SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.OpenApi; using SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.ProductApi; using SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.RoleApi; + using SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast; public class CodeAnalyzeTests { @@ -210,6 +211,51 @@ public void CodeAnalyze() new SourceFileAnalyzer(options).AssertNoIssues(); })) ); + + Assert.Multiple( + () => Assert.Null(Record.Exception(() => + { + var options = new TypeDeclarationAnalyzerOptions() + { + SdkAssembly = Assembly.GetAssembly(typeof(DouyinMicroAppWebcastClient))!, + SdkRequestModelDeclarationNamespace = "SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models", + SdkResponseModelDeclarationNamespace = "SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models", + SdkExecutingExtensionDeclarationNamespace = "SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast", + ThrowOnNotFoundRequestModelTypes = true, + ThrowOnNotFoundResponseModelTypes = true, + ThrowOnNotFoundExecutingExtensionTypes = true + }; + new TypeDeclarationAnalyzer(options).AssertNoIssues(); + })), + + () => Assert.Null(Record.Exception(() => + { + string workdir = Environment.CurrentDirectory; + string projdir = Path.Combine(workdir, "../../../../../"); + + var options = new SourceFileAnalyzerOptions() + { + SdkAssembly = Assembly.GetAssembly(typeof(DouyinMicroAppWebcastClient))!, + SdkRequestModelDeclarationNamespace = "SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models", + SdkResponseModelDeclarationNamespace = "SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.Webcast.Models", + ProjectSourceRootDirectory = Path.Combine(projdir, "./src/SKIT.FlurlHttpClient.ByteDance.MicroApp/"), + ProjectSourceRequestModelClassCodeSubDirectory = "ExtendedSDK/Webcast/Models/", + ProjectSourceResponseModelClassCodeSubDirectory = "ExtendedSDK/Webcast/Models/", + ProjectSourceExecutingExtensionClassCodeSubDirectory = "ExtendedSDK/Webcast/Extensions/", + ProjectSourceWebhookEventClassCodeSubDirectory = "ExtendedSDK/Webcast/Events/", + ProjectTestRootDirectory = Path.Combine(projdir, "./test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/"), + ProjectTestRequestModelSerializationSampleSubDirectory = "ModelSamples/Webcast/", + ProjectTestResponseModelSerializationSampleSubDirectory = "ModelSamples/Webcast/", + ProjectTestWebhookEventSerializationSampleSubDirectory = "EventSamples/Webcast/", + ThrowOnNotFoundRequestModelClassCodeFiles = true, + ThrowOnNotFoundResponseModelClassCodeFiles = true, + ThrowOnNotFoundExecutingExtensionClassCodeFiles = true, + ThrowOnNotFoundRequestModelSerializationSampleFiles = true, + ThrowOnNotFoundResponseModelSerializationSampleFiles = true + }; + new SourceFileAnalyzer(options).AssertNoIssues(); + })) + ); } } } diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/Gift/WebcastGiftTopGiftRequest.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/Gift/WebcastGiftTopGiftRequest.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/Gift/WebcastGiftTopGiftRequest.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/Gift/WebcastGiftTopGiftRequest.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/Gift/WebcastGiftTopGiftResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/Gift/WebcastGiftTopGiftResponse.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/Gift/WebcastGiftTopGiftResponse.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/Gift/WebcastGiftTopGiftResponse.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LinkMic/WebcastLinkMicQueryRequest.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LinkMic/WebcastLinkMicQueryRequest.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LinkMic/WebcastLinkMicQueryRequest.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LinkMic/WebcastLinkMicQueryRequest.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LinkMic/WebcastLinkMicQueryResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LinkMic/WebcastLinkMicQueryResponse.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LinkMic/WebcastLinkMicQueryResponse.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LinkMic/WebcastLinkMicQueryResponse.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskFailDataGetResponse.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskGetResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskGetResponse.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskGetResponse.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskGetResponse.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStartRequest.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStartRequest.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStartRequest.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStartRequest.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStartResponse.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStartResponse.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStartResponse.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStartResponse.json diff --git a/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStopRequest.json b/test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStopRequest.json similarity index 100% rename from test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/_/Webcast/LiveData/WebcastLiveDataTaskStopRequest.json rename to test/SKIT.FlurlHttpClient.ByteDance.MicroApp.UnitTests/ModelSamples/Webcast/LiveData/WebcastLiveDataTaskStopRequest.json