mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 09:54:44 +08:00
feat(work): 新增通讯录异步导出相关接口
This commit is contained in:
@@ -7,6 +7,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
/// <para>表示 EVENT.batch_job_result 事件的数据。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/90973 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/90240 </para>
|
||||
/// <para>REF; https://open.work.weixin.qq.com/api/doc/90000/90135/94946 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/91135 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/90376 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90002/90151/91167 </para>
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
public static class WechatWorkClientExecuteCgibinExportExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/export/simple_user 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94849 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94950 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExportSimpleUserResponse> ExecuteCgibinExportSimpleUserAsync(this WechatWorkClient client, Models.CgibinExportSimpleUserRequest 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", "export", "simple_user")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExportSimpleUserResponse>(flurlReq, data: request, cancellationToken: cancellationToken);;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/export/user 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94851 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94951 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExportUserResponse> ExecuteCgibinExportUserAsync(this WechatWorkClient client, Models.CgibinExportUserRequest 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", "export", "user")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExportUserResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/export/department 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94852 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94952 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExportDepartmentResponse> ExecuteCgibinExportDepartmentAsync(this WechatWorkClient client, Models.CgibinExportDepartmentRequest 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", "export", "department")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExportDepartmentResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/export/taguser 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94853 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94953 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExportTagUserResponse> ExecuteCgibinExportTagUserAsync(this WechatWorkClient client, Models.CgibinExportTagUserRequest 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", "export", "taguser")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExportTagUserResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/export/get_result 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94854 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94954 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExportGetResultResponse> ExecuteCgibinExportGetResultAsync(this WechatWorkClient client, Models.CgibinExportGetResultRequest 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", "export", "get_result")
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("jobid", request.JobId);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExportGetResultResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/department 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportDepartmentRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 Base64 编码的加密密钥。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("encoding_aeskey")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")]
|
||||
public string EncodingAESKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置每块数据的人员数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("block_size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("block_size")]
|
||||
public int? BlockSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/department 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportDepartmentResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/export/get_result 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportGetResultRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string JobId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/export/get_result 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportGetResultResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置任务状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置数据大小(单位:字节)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("size")]
|
||||
public int Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置数据哈希值。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("md5")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("md5")]
|
||||
public string Hash { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置任务状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("status")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("status")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("data_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("data_list")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/simple_user 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportSimpleUserRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 Base64 编码的加密密钥。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("encoding_aeskey")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")]
|
||||
public string EncodingAESKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置每块数据的人员数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("block_size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("block_size")]
|
||||
public int? BlockSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/simple_user 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportSimpleUserResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/taguser 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportTagUserRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置标签 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("tagid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("tagid")]
|
||||
public int TagId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Base64 编码的加密密钥。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("encoding_aeskey")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")]
|
||||
public string EncodingAESKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置每块数据的人员数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("block_size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("block_size")]
|
||||
public int? BlockSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/taguser 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportTagUserResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/user 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportUserRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 Base64 编码的加密密钥。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("encoding_aeskey")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")]
|
||||
public string EncodingAESKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置每块数据的人员数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("block_size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("block_size")]
|
||||
public int? BlockSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/export/user 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExportUserResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user