mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-21 02:58:06 +08:00
feat(work): 新增批量导入上下游联系人接口
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -9,7 +9,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
|||||||
{
|
{
|
||||||
public static class WechatWorkClientExecuteCgibinCorpGroupExtensions
|
public static class WechatWorkClientExecuteCgibinCorpGroupExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>异步调用 [POST] /cgi-bin/corpgroup/unionid_to_external_userid 接口。</para>
|
/// <para>异步调用 [POST] /cgi-bin/corpgroup/unionid_to_external_userid 接口。</para>
|
||||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95342 </para>
|
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95342 </para>
|
||||||
@@ -30,6 +29,47 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
|||||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupUnionidToExternalUserIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupUnionidToExternalUserIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>异步调用 [POST] /cgi-bin/corpgroup/import_chain_contact 接口。</para>
|
||||||
|
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95821 </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<Models.CgibinCorpGroupImportChainContactResponse> ExecuteCgibinCorpGroupImportChainContactAsync(this WechatWorkClient client, Models.CgibinCorpGroupImportChainContactRequest 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", "corpgroup", "import_chain_contact")
|
||||||
|
.SetQueryParam("access_token", request.AccessToken);
|
||||||
|
|
||||||
|
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupImportChainContactResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>异步调用 [GET] /cgi-bin/corpgroup/getresult 接口。</para>
|
||||||
|
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95823 </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<Models.CgibinCorpGroupGetResultResponse> ExecuteCgibinCorpGroupGetResultAsync(this WechatWorkClient client, Models.CgibinCorpGroupGetResultRequest 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", "corpgroup", "getresult")
|
||||||
|
.SetQueryParam("access_token", request.AccessToken)
|
||||||
|
.SetQueryParam("jobid", request.JobId);
|
||||||
|
|
||||||
|
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupGetResultResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
#region Corp
|
#region Corp
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/list_app_share_info 接口。</para>
|
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/list_app_share_info 接口。</para>
|
||||||
|
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [GET] /cgi-bin/corpgroup/getresult 接口的请求。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinCorpGroupGetResultRequest : WechatWorkRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置异步任务 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonIgnore]
|
||||||
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
|
public string JobId { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,117 @@
|
|||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [GET] /cgi-bin/corpgroup/getresult 接口的响应。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinCorpGroupGetResultResponse : WechatWorkResponse
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class Result
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class ChainContact
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class Contact
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置错误码。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("errcode")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("errcode")]
|
||||||
|
public int ErrorCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置错误描述。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("errmsg")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
|
||||||
|
public string? ErrorMessage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人手机号码。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("mobile")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("mobile")]
|
||||||
|
public string? MobileNumber { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置错误码。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("errcode")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("errcode")]
|
||||||
|
public int ErrorCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置错误描述。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("errmsg")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
|
||||||
|
public string? ErrorMessage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置企业名称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("corp_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("corp_name")]
|
||||||
|
public string CorpName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置自定义 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("custom_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("custom_id")]
|
||||||
|
public string? CustomId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("contact_info_list")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("contact_info_list")]
|
||||||
|
public Types.Contact[]? ContactList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置上下游 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("chain_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("chain_id")]
|
||||||
|
public string ChainId { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置导入状态。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("import_status")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("import_status")]
|
||||||
|
public int ImportStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置导入失败的联系人列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("fail_list")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("fail_list")]
|
||||||
|
public Types.ChainContact[]? FailedChainContactList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置任务状态。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("status")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("status")]
|
||||||
|
public int Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置结果信息。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("result")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||||
|
public Types.Result? Result { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,85 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /cgi-bin/corpgroup/import_chain_contact 接口的请求。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinCorpGroupImportChainContactRequest : WechatWorkRequest
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class ChainContact
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class Contact
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人姓名。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人身份类型。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("identity_type")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("identity_type")]
|
||||||
|
public int IdentityType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人手机号码。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("mobile")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("mobile")]
|
||||||
|
public string? MobileNumber { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置企业名称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("corp_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("corp_name")]
|
||||||
|
public string CorpName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置导入后企业所在分组。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("group_path")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("group_path")]
|
||||||
|
public string? GroupPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置自定义 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("custom_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("custom_id")]
|
||||||
|
public string? CustomId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("contact_info_list")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("contact_info_list")]
|
||||||
|
public IList<Types.Contact> ContactList { get; set; } = new List<Types.Contact>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置上下游 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("chain_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("chain_id")]
|
||||||
|
public string ChainId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置联系人列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("contact_list")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("contact_list")]
|
||||||
|
public IList<Types.ChainContact> ChainContactList { get; set; } = new List<Types.ChainContact>();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,15 @@
|
|||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /cgi-bin/corpgroup/import_chain_contact 接口的响应。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinCorpGroupImportChainContactResponse : WechatWorkResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置导入任务 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||||
|
public string JobId { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"errcode": 0,
|
||||||
|
"errmsg": "ok",
|
||||||
|
"status": 3,
|
||||||
|
"result": {
|
||||||
|
"chain_id": "xxxx",
|
||||||
|
"import_status": 2,
|
||||||
|
"fail_list": [
|
||||||
|
{
|
||||||
|
"corp_name": "飞飞培训学校2入2222",
|
||||||
|
"custom_id": "",
|
||||||
|
"errcode": 670016,
|
||||||
|
"errmsg": "invalid contact identity",
|
||||||
|
"contact_info_list": [
|
||||||
|
{
|
||||||
|
"mobile": "13000000001",
|
||||||
|
"errcode": 670016,
|
||||||
|
"errmsg": "invalid contact identity"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"chain_id": "xxxxxx",
|
||||||
|
"contact_list": [
|
||||||
|
{
|
||||||
|
"corp_name": "飞飞培训学校",
|
||||||
|
"group_path": "华北区/北京市/海淀区",
|
||||||
|
"custom_id": "wof3du51quo5sl1is",
|
||||||
|
"contact_info_list": [
|
||||||
|
{
|
||||||
|
"name": "张三",
|
||||||
|
"identity_type": 1,
|
||||||
|
"mobile": "13000000001"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "李四",
|
||||||
|
"identity_type": 2,
|
||||||
|
"mobile": "13000000001"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"errcode": 0,
|
||||||
|
"errmsg": "ok",
|
||||||
|
"jobid": "xxxxx"
|
||||||
|
}
|
Reference in New Issue
Block a user