From bddc7924ee6720dfde49881092f673caa9e8aa5e Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Wed, 26 Oct 2022 17:26:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E4=BB=A3?= =?UTF-8?q?=E5=95=86=E5=AE=B6=E6=B3=A8=E5=86=8C=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=BF=AB=E9=80=9F=E6=B3=A8=E5=86=8C=E4=B8=AA=E4=BA=BA=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotifyThirdFastRegisterEvent.cs | 35 +++++++++++----- ...iClientExecuteCgibinComponentExtensions.cs | 42 +++++++++++++++++++ ...tFastRegisterPersonalWeappCreateRequest.cs | 36 ++++++++++++++++ ...FastRegisterPersonalWeappCreateResponse.cs | 29 +++++++++++++ ...ntFastRegisterPersonalWeappQueryRequest.cs | 22 ++++++++++ ...tFastRegisterPersonalWeappQueryResponse.cs | 9 ++++ ...astRegisterPersonalWeappCreateRequest.json | 5 +++ ...stRegisterPersonalWeappCreateResponse.json | 7 ++++ ...FastRegisterPersonalWeappQueryRequest.json | 3 ++ ...astRegisterPersonalWeappQueryResponse.json | 7 ++++ 10 files changed, 184 insertions(+), 11 deletions(-) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/OpenComponent/NotifyThirdFastRegisterEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/OpenComponent/NotifyThirdFastRegisterEvent.cs index 6b7a322e..c3b93492 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/OpenComponent/NotifyThirdFastRegisterEvent.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/OpenComponent/NotifyThirdFastRegisterEvent.cs @@ -1,8 +1,9 @@ -namespace SKIT.FlurlHttpClient.Wechat.Api.Events +namespace SKIT.FlurlHttpClient.Wechat.Api.Events { /// /// 表示 INFO.notify_third_fasteregister 事件的数据。 /// REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html + /// REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-registration-ind/fastRegisterPersonalMp.html /// public class NotifyThirdFastRegisterEvent : WechatApiEvent, WechatApiEvent.Serialization.IXmlSerializable { @@ -13,32 +14,44 @@ /// /// 获取或设置企业名称。 /// - [System.Xml.Serialization.XmlElement("name")] - public string EnterpriseName { get; set; } = default!; + [System.Xml.Serialization.XmlElement("name", IsNullable = true)] + public string? EnterpriseName { get; set; } /// /// 获取或设置企业代码类型。 /// - [System.Xml.Serialization.XmlElement("code_type")] - public int LicenseType { get; set; } + [System.Xml.Serialization.XmlElement("code_type", IsNullable = true)] + public int? LicenseType { get; set; } /// /// 获取或设置企业代码。 /// - [System.Xml.Serialization.XmlElement("code")] - public string LicenseNumber { get; set; } = default!; + [System.Xml.Serialization.XmlElement("code", IsNullable = true)] + public string? LicenseNumber { get; set; } = default!; /// /// 获取或设置法人姓名。 /// - [System.Xml.Serialization.XmlElement("legal_persona_name")] - public string LegalPersonName { get; set; } = default!; + [System.Xml.Serialization.XmlElement("legal_persona_name", IsNullable = true)] + public string? LegalPersonName { get; set; } /// /// 获取或设置法人微信号。 /// - [System.Xml.Serialization.XmlElement("legal_persona_wechat")] - public string LegalPersonWxname { get; set; } = default!; + [System.Xml.Serialization.XmlElement("legal_persona_wechat", IsNullable = true)] + public string? LegalPersonWxname { get; set; } + + /// + /// 获取或设置用户姓名。 + /// + [System.Xml.Serialization.XmlElement("legal_persona_wechat", IsNullable = true)] + public string? IdName { get; set; } + + /// + /// 获取或设置用户微信号。 + /// + [System.Xml.Serialization.XmlElement("wxuser", IsNullable = true)] + public string? Wxname { get; set; } /// /// 获取或设置第三方联系电话。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs index 202ef68b..0aa458c8 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinComponentExtensions.cs @@ -262,6 +262,48 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + /// + /// 异步调用 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=create 接口。 + /// REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-registration-ind/fastRegisterPersonalMp.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinComponentFastRegisterPersonalWeappCreateAsync(this WechatApiClient client, Models.CgibinComponentFastRegisterPersonalWeappCreateRequest 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", "component", "fastregisterpersonalweapp") + .SetQueryParam("action", "create") + .SetQueryParam("component_access_token", request.ComponentAccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=query 接口。 + /// REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/register-management/fast-registration-ind/fastRegisterPersonalMp.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinComponentFastRegisterPersonalWeappQueryAsync(this WechatApiClient client, Models.CgibinComponentFastRegisterPersonalWeappQueryRequest 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", "component", "fastregisterpersonalweapp") + .SetQueryParam("action", "query") + .SetQueryParam("component_access_token", request.ComponentAccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + /// /// 异步调用 [POST] /cgi-bin/component/modify_wxa_server_domain 接口。 /// REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/domain/modify_server_domain.html diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.cs new file mode 100644 index 00000000..21d76e05 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.cs @@ -0,0 +1,36 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=create 接口的请求。 + /// + public class CgibinComponentFastRegisterPersonalWeappCreateRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置第三方平台 AccessToken。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ComponentAccessToken { get; set; } = string.Empty; + + /// + /// 获取或设置个人用户名字。 + /// + [Newtonsoft.Json.JsonProperty("idname")] + [System.Text.Json.Serialization.JsonPropertyName("idname")] + public string IdName { get; set; } = string.Empty; + + /// + /// 获取或设置个人用户微信号。 + /// + [Newtonsoft.Json.JsonProperty("wxuser")] + [System.Text.Json.Serialization.JsonPropertyName("wxuser")] + public string Wxname { get; set; } = string.Empty; + + /// + /// 获取或设置第三方联系电话。 + /// + [Newtonsoft.Json.JsonProperty("component_phone")] + [System.Text.Json.Serialization.JsonPropertyName("component_phone")] + public string? ComponentPhoneNumber { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.cs new file mode 100644 index 00000000..adbcf939 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.cs @@ -0,0 +1,29 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=create 接口的响应。 + /// + public class CgibinComponentFastRegisterPersonalWeappCreateResponse : WechatApiResponse + { + /// + /// 获取或设置任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("taskid")] + [System.Text.Json.Serialization.JsonPropertyName("taskid")] + public string TaskId { get; set; } = default!; + + /// + /// 获取或设置任务状态。 + /// + [Newtonsoft.Json.JsonProperty("status")] + [System.Text.Json.Serialization.JsonPropertyName("status")] + public int Status { get; set; } + + /// + /// 获取或设置扫码认证链接。 + /// + [Newtonsoft.Json.JsonProperty("authorize_url")] + [System.Text.Json.Serialization.JsonPropertyName("authorize_url")] + public string? AuthorizeUrl { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.cs new file mode 100644 index 00000000..83cbab62 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.cs @@ -0,0 +1,22 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=query 接口的请求。 + /// + public class CgibinComponentFastRegisterPersonalWeappQueryRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置第三方平台 AccessToken。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string ComponentAccessToken { get; set; } = string.Empty; + + /// + /// 获取或设置任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("taskid")] + [System.Text.Json.Serialization.JsonPropertyName("taskid")] + public string TaskId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.cs new file mode 100644 index 00000000..54ccb8a2 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/component/fastregisterpersonalweapp?action=query 接口的响应。 + /// + public class CgibinComponentFastRegisterPersonalWeappQueryResponse : CgibinComponentFastRegisterPersonalWeappCreateResponse + { + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.json new file mode 100644 index 00000000..008ed643 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateRequest.json @@ -0,0 +1,5 @@ +{ + "idname": "tencent", + "wxuser": "wxidnnn", + "component_phone": "1234567" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.json new file mode 100644 index 00000000..dd1aa709 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappCreateResponse.json @@ -0,0 +1,7 @@ +{ + "errcode": 0, + "errmsg": "OK", + "taskid": "xxxxx", + "authorize_url": "https://mp.weixin.qq.com/xxxx", + "status": 0 +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.json new file mode 100644 index 00000000..cfde2e72 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryRequest.json @@ -0,0 +1,3 @@ +{ + "taskid": "xxxxx" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.json new file mode 100644 index 00000000..186f394b --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinComponent/CgibinComponentFastRegisterPersonalWeappQueryResponse.json @@ -0,0 +1,7 @@ +{ + "errcode": 0, + "errmsg": "OK", + "taskid": "xxxxx", + "authorize_url": "https://mp.weixin.qq.com/xxxx", + "status": 0 +}