feat(work): 新增客服获取基础信息相关接口

This commit is contained in:
Fu Diwei 2021-09-30 17:19:53 +08:00
parent f0d19e79a0
commit 45c8d6d024
21 changed files with 173 additions and 0 deletions

View File

@ -289,6 +289,47 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinKfCustomerCancelUpgradeServiceResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/kf/customer/batchget 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95159 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95149 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinKfCustomerBatchGetResponse> ExecuteCgibinKfCustomerBatchGetAsync(this WechatWorkClient client, Models.CgibinKfCustomerBatchGetRequest 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", "kf", "customer", "batchget")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinKfCustomerBatchGetResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /cgi-bin/kf/get_corp_qualification 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95153 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinKfGetCorpQualificationResponse> ExecuteCgibinKfGetCorpQualificationAsync(this WechatWorkClient client, Models.CgibinKfGetCorpQualificationRequest 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, "cgi-bin", "kf", "get_corp_qualification")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinKfGetCorpQualificationResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
/// <summary>

View File

@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [GET] /cgi-bin/kf/get_corp_qualification 接口的请求。</para>
/// </summary>
public class CgibinKfGetCorpQualificationRequest : WechatWorkRequest
{
}
}

View File

@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [GET] /cgi-bin/kf/get_corp_qualification 接口的响应。</para>
/// </summary>
public class CgibinKfGetCorpQualificationResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置是否已绑定视频号。
/// </summary>
[Newtonsoft.Json.JsonProperty("wechat_channels_binding")]
[System.Text.Json.Serialization.JsonPropertyName("wechat_channels_binding")]
public bool IsWechatChannelsBound { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/kf/customer/batchget 接口的请求。</para>
/// </summary>
public class CgibinKfCustomerBatchGetRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置外部联系人账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("external_userid_list")]
public IList<string> ExternalUserIdList { get; set; } = new List<string>();
}
}

View File

@ -0,0 +1,63 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/kf/customer/batchget 接口的响应。</para>
/// </summary>
public class CgibinKfCustomerBatchGetResponse : WechatWorkResponse
{
public static class Types
{
public class Customer
{
/// <summary>
/// 获取或设置外部联系人账号。
/// </summary>
[Newtonsoft.Json.JsonProperty("external_userid")]
[System.Text.Json.Serialization.JsonPropertyName("external_userid")]
public string ExternalUserId { get; set; } = default!;
/// <summary>
/// 获取或设置昵称。
/// </summary>
[Newtonsoft.Json.JsonProperty("nickname")]
[System.Text.Json.Serialization.JsonPropertyName("nickname")]
public string Nickname { get; set; } = default!;
/// <summary>
/// 获取或设置头像 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("avatar")]
[System.Text.Json.Serialization.JsonPropertyName("avatar")]
public string AvatarUrl { get; set; } = default!;
/// <summary>
/// 获取或设置性别。
/// </summary>
[Newtonsoft.Json.JsonProperty("gender")]
[System.Text.Json.Serialization.JsonPropertyName("gender")]
public int Gender { get; set; }
/// <summary>
/// 获取或设置用户 UnionId。
/// </summary>
[Newtonsoft.Json.JsonProperty("unionid")]
[System.Text.Json.Serialization.JsonPropertyName("unionid")]
public string? UnionId { get; set; }
}
}
/// <summary>
/// 获取或设置客户列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("customer_list")]
[System.Text.Json.Serialization.JsonPropertyName("customer_list")]
public Types.Customer[] CustomerLsit { get; set; } = default!;
/// <summary>
/// 获取或设置无效的外部联系人账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("invalid_external_userid")]
[System.Text.Json.Serialization.JsonPropertyName("invalid_external_userid")]
public string[] InvalidExternalUserIdList { get; set; } = default!;
}
}

View File

@ -0,0 +1,5 @@
{
"errcode": 0,
"errmsg": "ok",
"wechat_channels_binding": true
}

View File

@ -0,0 +1,6 @@
{
"external_userid_list": [
"wmxxxxxxxxxxxxxxxxxxxxxx",
"zhangsan"
]
}

View File

@ -0,0 +1,16 @@
{
"errcode": 0,
"errmsg": "ok",
"customer_list": [
{
"external_userid": "wmxxxxxxxxxxxxxxxxxxxxxx",
"nickname": "张三",
"avatar": "http://xxxxx",
"gender": 1,
"unionid": "oxasdaosaosdasdasdasd"
}
],
"invalid_external_userid": [
"zhangsan"
]
}