diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinOpenExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinOpenExtensions.cs index 76b99b79..f9a397ed 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinOpenExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinOpenExtensions.cs @@ -29,6 +29,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + /// + /// 异步调用 [POST] /cgi-bin/open/have 接口。 + /// REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinOpenHaveAsync(this WechatApiClient client, Models.CgibinOpenHaveRequest 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", "open", "have") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + /// /// 异步调用 [POST] /cgi-bin/open/bind 接口。 /// REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/account/bind.html diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenBindRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenBindRequest.cs index 1f071b55..9a431d30 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenBindRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenBindRequest.cs @@ -3,8 +3,15 @@ /// /// 表示 [POST] /cgi-bin/open/bind 接口的请求。 /// - public class CgibinOpenBindRequest : CgibinOpenCreateRequest, IInferable + public class CgibinOpenBindRequest : WechatApiRequest, IInferable { + /// + /// 获取或设置授权方的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("appid")] + [System.Text.Json.Serialization.JsonPropertyName("appid")] + public string AuthorizerAppId { get; set; } = string.Empty; + /// /// 获取或设置开放平台的 AppId。 /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetRequest.cs index b0695d13..2820c8cc 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetRequest.cs @@ -3,7 +3,13 @@ /// /// 表示 [POST] /cgi-bin/open/get 接口的请求。 /// - public class CgibinOpenGetRequest : CgibinOpenCreateRequest, IInferable + public class CgibinOpenGetRequest : WechatApiRequest, IInferable { + /// + /// 获取或设置授权方的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("appid")] + [System.Text.Json.Serialization.JsonPropertyName("appid")] + public string AuthorizerAppId { get; set; } = string.Empty; } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetResponse.cs index 3ab27d64..819b7aa9 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetResponse.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenGetResponse.cs @@ -3,7 +3,13 @@ /// /// 表示 [POST] /cgi-bin/open/get 接口的响应。 /// - public class CgibinOpenGetResponse : CgibinOpenCreateResponse + public class CgibinOpenGetResponse : WechatApiResponse { + /// + /// 获取或设置开放平台的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("open_appid")] + [System.Text.Json.Serialization.JsonPropertyName("open_appid")] + public string OpenAppId { get; set; } = default!; } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveRequest.cs new file mode 100644 index 00000000..c89ea336 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveRequest.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/open/have 接口的请求。 + /// + public class CgibinOpenHaveRequest : WechatApiRequest, IInferable + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveResponse.cs new file mode 100644 index 00000000..1f4fef20 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenHaveResponse.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/open/have 接口的响应。 + /// + public class CgibinOpenHaveResponse : WechatApiResponse + { + /// + /// 获取或设置是否绑定开放平台帐号。 + /// + [Newtonsoft.Json.JsonProperty("have_open")] + [System.Text.Json.Serialization.JsonPropertyName("have_open")] + public bool IsHaveOpen { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenUnbindRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenUnbindRequest.cs index 763ee374..39bd284f 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenUnbindRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinOpen/CgibinOpenUnbindRequest.cs @@ -3,7 +3,20 @@ /// /// 表示 [POST] /cgi-bin/open/unbind 接口的请求。 /// - public class CgibinOpenUnbindRequest : CgibinOpenBindRequest, IInferable + public class CgibinOpenUnbindRequest : WechatApiRequest, IInferable { + /// + /// 获取或设置授权方的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("appid")] + [System.Text.Json.Serialization.JsonPropertyName("appid")] + public string AuthorizerAppId { get; set; } = string.Empty; + + /// + /// 获取或设置开放平台的 AppId。 + /// + [Newtonsoft.Json.JsonProperty("open_appid")] + [System.Text.Json.Serialization.JsonPropertyName("open_appid")] + public string OpenAppId { get; set; } = string.Empty; } } diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinOpen/CgibinOpenHaveResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinOpen/CgibinOpenHaveResponse.json new file mode 100644 index 00000000..f5ca7831 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinOpen/CgibinOpenHaveResponse.json @@ -0,0 +1,5 @@ +{ + "have_open": true, + "errcode": 0, + "errmsg": "ok" +} \ No newline at end of file