From 5eae91e126f0dde178b6cd19974935fce5f5bc7e Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Fri, 1 Jul 2022 20:08:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E9=9A=8F=E5=AE=98=E6=96=B9?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=A2=E6=9C=8D=E7=AE=A1=E7=90=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...entExecuteCgibinCustomServiceExtensions.cs | 2 + ...ApiClientExecuteCustomServiceExtensions.cs | 67 ++++++++++++++++++- .../CgibinCustomServiceGetKfListResponse.cs | 7 ++ ...binCustomServiceGetOnlineKfListResponse.cs | 7 ++ .../CustomServiceKfAccountAddRequest.cs | 9 ++- ...viceKfAccountCancelAdminByOpenIdRequest.cs | 15 +++++ ...iceKfAccountCancelAdminByOpenIdResponse.cs | 9 +++ ...omServiceKfAccountDeleteByOpenIdRequest.cs | 15 +++++ ...mServiceKfAccountDeleteByOpenIdResponse.cs | 9 +++ ...ServiceKfAccountSetAdminByOpenIdRequest.cs | 15 +++++ ...erviceKfAccountSetAdminByOpenIdResponse.cs | 9 +++ 11 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdResponse.cs diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinCustomServiceExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinCustomServiceExtensions.cs index dfc4cb2c..0b467410 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinCustomServiceExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinCustomServiceExtensions.cs @@ -13,6 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [GET] /cgi-bin/customservice/getkflist 接口。 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#5 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Customer_Service_Management.html#0 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%9C%8D%E5%9F%BA%E6%9C%AC%E4%BF%A1%E6%81%AF /// /// /// @@ -33,6 +34,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// /// 异步调用 [GET] /cgi-bin/customservice/getonlinekflist 接口。 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Customer_Service_Management.html#0 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E8%8E%B7%E5%8F%96%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%9C%8D%E5%88%97%E8%A1%A8 /// /// /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCustomServiceExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCustomServiceExtensions.cs index f5c91317..435640e6 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCustomServiceExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCustomServiceExtensions.cs @@ -14,6 +14,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api /// 异步调用 [POST] /customservice/kfaccount/add 接口。 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#1 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Customer_Service_Management.html#2 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E6%B7%BB%E5%8A%A0%E5%AE%A2%E6%9C%8D%E8%B4%A6%E5%8F%B7 /// /// /// @@ -68,12 +69,32 @@ namespace SKIT.FlurlHttpClient.Wechat.Api IFlurlRequest flurlReq = client .CreateRequest(request, HttpMethod.Post, "customservice", "kfaccount", "del") - .SetQueryParam("access_token", request.AccessToken) - .SetQueryParam("kf_account", request.KfAccount); + .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + /// + /// 异步调用 [GET] /customservice/kfaccount/del 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E5%88%A0%E9%99%A4%E5%AE%A2%E6%9C%8D%E8%B4%A6%E5%8F%B7 + /// + /// + /// + /// + /// + public static async Task ExecuteCustomServiceKfAccountDeleteByOpenIdAsync(this WechatApiClient client, Models.CustomServiceKfAccountDeleteByOpenIdRequest 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.Get, "customservice", "kfaccount", "del") + .SetQueryParam("access_token", request.AccessToken) + .SetQueryParam("kf_openid", request.OpenId); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + /// /// 异步调用 [POST] /customservice/kfaccount/uploadheadimg 接口。 /// REF: https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#4 @@ -115,6 +136,48 @@ namespace SKIT.FlurlHttpClient.Wechat.Api return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } + + /// + /// 异步调用 [GET] /customservice/kfaccount/setadmin 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E8%AE%BE%E7%BD%AE%E5%AE%A2%E6%9C%8D%E7%AE%A1%E7%90%86%E5%91%98 + /// + /// + /// + /// + /// + public static async Task ExecuteCustomServiceKfAccountSetAdminByOpenIdAsync(this WechatApiClient client, Models.CustomServiceKfAccountSetAdminByOpenIdRequest 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.Get, "customservice", "kfaccount", "setadmin") + .SetQueryParam("access_token", request.AccessToken) + .SetQueryParam("kf_openid", request.OpenId); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [GET] /customservice/kfaccount/canceladmin 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E5%8F%96%E6%B6%88%E5%AE%A2%E6%9C%8D%E7%AE%A1%E7%90%86%E5%91%98 + /// + /// + /// + /// + /// + public static async Task ExecuteCustomServiceKfAccountCancelAdminByOpenIdAsync(this WechatApiClient client, Models.CustomServiceKfAccountCancelAdminByOpenIdRequest 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.Get, "customservice", "kfaccount", "canceladmin") + .SetQueryParam("access_token", request.AccessToken) + .SetQueryParam("kf_openid", request.OpenId); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } #endregion #region KfSession diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetKfListResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetKfListResponse.cs index e86b9d03..1ebf393d 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetKfListResponse.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetKfListResponse.cs @@ -44,6 +44,13 @@ [System.Text.Json.Serialization.JsonPropertyName("kf_wx")] public string? Wxname { get; set; } + /// + /// 获取或设置客服 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("kf_openid")] + [System.Text.Json.Serialization.JsonPropertyName("kf_openid")] + public string? OpenId { get; set; } + /// /// 获取或设置绑定邀请的微信号。 /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetOnlineKfListResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetOnlineKfListResponse.cs index 150627e0..38964198 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetOnlineKfListResponse.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinCustomService/CgibinCustomServiceGetOnlineKfListResponse.cs @@ -30,6 +30,13 @@ [System.Text.Json.Serialization.JsonPropertyName("status")] public int Status { get; set; } + /// + /// 获取或设置客服 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("kf_openid")] + [System.Text.Json.Serialization.JsonPropertyName("kf_openid")] + public string? OpenId { get; set; } + /// /// 获取或设置客服当前正在接待的会话数。 /// diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountAddRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountAddRequest.cs index 418b14b3..79eeb8c0 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountAddRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountAddRequest.cs @@ -10,7 +10,7 @@ /// [Newtonsoft.Json.JsonProperty("kf_account")] [System.Text.Json.Serialization.JsonPropertyName("kf_account")] - public string KfAccount { get; set; } = string.Empty; + public string? KfAccount { get; set; } /// /// 获取或设置客服昵称。 @@ -25,5 +25,12 @@ [Newtonsoft.Json.JsonProperty("password")] [System.Text.Json.Serialization.JsonPropertyName("password")] public string? Password { get; set; } + + /// + /// 获取或设置客服微信号。 + /// + [Newtonsoft.Json.JsonProperty("kf_wx")] + [System.Text.Json.Serialization.JsonPropertyName("kf_wx")] + public string? Wxname { get; set; } } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdRequest.cs new file mode 100644 index 00000000..c44d02a6 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/canceladmin 接口的请求。 + /// + public class CustomServiceKfAccountCancelAdminByOpenIdRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置客服 OpenId。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string OpenId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdResponse.cs new file mode 100644 index 00000000..0cc5fb6f --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountCancelAdminByOpenIdResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/canceladmin 接口的响应。 + /// + public class CustomServiceKfAccountCancelAdminByOpenIdResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdRequest.cs new file mode 100644 index 00000000..f472ecce --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/del 接口的请求。 + /// + public class CustomServiceKfAccountDeleteByOpenIdRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置客服 OpenId。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string OpenId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdResponse.cs new file mode 100644 index 00000000..f0386246 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountDeleteByOpenIdResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/del 接口的响应。 + /// + public class CustomServiceKfAccountDeleteByOpenIdResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdRequest.cs new file mode 100644 index 00000000..dc552a7e --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdRequest.cs @@ -0,0 +1,15 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/setadmin 接口的请求。 + /// + public class CustomServiceKfAccountSetAdminByOpenIdRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置客服 OpenId。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string OpenId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdResponse.cs new file mode 100644 index 00000000..609cfae1 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CustomService/KfAccount/CustomServiceKfAccountSetAdminByOpenIdResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [GET] /customservice/kfaccount/setadmin 接口的响应。 + /// + public class CustomServiceKfAccountSetAdminByOpenIdResponse : WechatApiResponse + { + } +}