diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs index 640a18ee..abaad1bb 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinServiceExtensions.cs @@ -184,6 +184,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Work return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + /// + /// 异步调用 [POST] /cgi-bin/service/get_customized_auth_url 接口。 + /// REF: https://developer.work.weixin.qq.com/document/path/95436 + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinServiceGetCustomizedAuthUrlAsync(this WechatWorkClient client, Models.CgibinServiceGetCustomizedAuthUrlRequest 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 + .CreateRequest(request, HttpMethod.Post, "cgi-bin", "service", "get_customized_auth_url") + .SetQueryParam("provider_access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + #region Register /// /// 异步调用 [POST] /cgi-bin/service/get_register_code 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.cs new file mode 100644 index 00000000..7010da99 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/service/get_customized_auth_url 接口的请求。 + /// + public class CgibinServiceGetCustomizedAuthUrlRequest : WechatWorkRequest + { + /// + /// 获取或设置服务商 AccessToken。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ProviderAccessToken { get; set; } = string.Empty; + + /// + /// 获取或设置自定义参数。 + /// + [Newtonsoft.Json.JsonProperty("state")] + [System.Text.Json.Serialization.JsonPropertyName("state")] + public string State { get; set; } = string.Empty; + + /// + /// 获取或设置代开发自建应用模版 ID 列表。 + /// + [Newtonsoft.Json.JsonProperty("templateid_list")] + [System.Text.Json.Serialization.JsonPropertyName("templateid_list")] + public IList PermanentAuthCode { get; set; } = new List(); + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.cs new file mode 100644 index 00000000..824f663b --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/service/get_customized_auth_url 接口的响应。 + /// + public class CgibinServiceGetCustomizedAuthUrlResponse : WechatWorkResponse + { + /// + /// 获取或设置二维码 URL。 + /// + [Newtonsoft.Json.JsonProperty("qrcode_url")] + [System.Text.Json.Serialization.JsonPropertyName("qrcode_url")] + public string QrcodeUrl { get; set; } = default!; + + /// + /// 获取或设置二维码有效期(单位:秒)。 + /// + [Newtonsoft.Json.JsonProperty("expires_in")] + [System.Text.Json.Serialization.JsonPropertyName("expires_in")] + public int ExpiresIn { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetPermanentCodeResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetPermanentCodeResponse.cs index b5b3a1d0..b789bc10 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetPermanentCodeResponse.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinService/CgibinServiceGetPermanentCodeResponse.cs @@ -136,5 +136,12 @@ [Newtonsoft.Json.JsonProperty("register_code_info")] [System.Text.Json.Serialization.JsonPropertyName("register_code_info")] public Types.Register? Register { get; set; } + + /// + /// 获取或设置扫码或者授权链接中的自定义参数。 + /// + [Newtonsoft.Json.JsonProperty("state")] + [System.Text.Json.Serialization.JsonPropertyName("state")] + public string? State { get; set; } } } diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.json new file mode 100644 index 00000000..b57b3f27 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlRequest.json @@ -0,0 +1,4 @@ +{ + "state": "test", + "templateid_list": [ "dk1", "dk2" ] +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.json new file mode 100644 index 00000000..b57b3f27 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Work.UnitTests/ModelSamples/CgibinService/CgibinServiceGetCustomizedAuthUrlResponse.json @@ -0,0 +1,4 @@ +{ + "state": "test", + "templateid_list": [ "dk1", "dk2" ] +} \ No newline at end of file