diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Batch/BatchJobResultEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Batch/BatchJobResultEvent.cs index 945d04c3..ebf64992 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Batch/BatchJobResultEvent.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Events/Batch/BatchJobResultEvent.cs @@ -7,6 +7,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Events /// 表示 EVENT.batch_job_result 事件的数据。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/90973 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/90240 + /// REF; https://open.work.weixin.qq.com/api/doc/90000/90135/94946 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/91135 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/90376 /// REF: https://open.work.weixin.qq.com/api/doc/90002/90151/91167 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinExportExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinExportExtensions.cs new file mode 100644 index 00000000..f26e3ce4 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Extensions/WechatWorkClientExecuteCgibinExportExtensions.cs @@ -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 + { + /// + /// 异步调用 [POST] /cgi-bin/export/simple_user 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94849 + /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94950 + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken);; + } + + /// + /// 异步调用 [POST] /cgi-bin/export/user 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94851 + /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94951 + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/export/department 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94852 + /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94952 + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/export/taguser 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94853 + /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94953 + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [GET] /cgi-bin/export/get_result 接口。 + /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94854 + /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94954 + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentRequest.cs new file mode 100644 index 00000000..735a631a --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/department 接口的请求。 + /// + public class CgibinExportDepartmentRequest : WechatWorkRequest + { + /// + /// 获取或设置 Base64 编码的加密密钥。 + /// + [Newtonsoft.Json.JsonProperty("encoding_aeskey")] + [System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")] + public string EncodingAESKey { get; set; } = string.Empty; + + /// + /// 获取或设置每块数据的人员数。 + /// + [Newtonsoft.Json.JsonProperty("block_size")] + [System.Text.Json.Serialization.JsonPropertyName("block_size")] + public int? BlockSize { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentResponse.cs new file mode 100644 index 00000000..62e5edd2 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportDepartmentResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/department 接口的响应。 + /// + public class CgibinExportDepartmentResponse : WechatWorkResponse + { + /// + /// 获取或设置导出任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("jobid")] + [System.Text.Json.Serialization.JsonPropertyName("jobid")] + public string JobId { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultRequest.cs new file mode 100644 index 00000000..5e52565b --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [GET] /cgi-bin/export/get_result 接口的请求。 + /// + public class CgibinExportGetResultRequest : WechatWorkRequest + { + /// + /// 获取或设置导出任务 ID。 + /// + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string JobId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultResponse.cs new file mode 100644 index 00000000..c7bc84d4 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportGetResultResponse.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [GET] /cgi-bin/export/get_result 接口的响应。 + /// + public class CgibinExportGetResultResponse : WechatWorkResponse + { + public static class Types + { + public class Result + { + /// + /// 获取或设置任务状态。 + /// + [Newtonsoft.Json.JsonProperty("url")] + [System.Text.Json.Serialization.JsonPropertyName("url")] + public string Url { get; set; } = default!; + + /// + /// 获取或设置数据大小(单位:字节)。 + /// + [Newtonsoft.Json.JsonProperty("size")] + [System.Text.Json.Serialization.JsonPropertyName("size")] + public int Size { get; set; } + + /// + /// 获取或设置数据哈希值。 + /// + [Newtonsoft.Json.JsonProperty("md5")] + [System.Text.Json.Serialization.JsonPropertyName("md5")] + public string Hash { get; set; } = default!; + } + } + + /// + /// 获取或设置任务状态。 + /// + [Newtonsoft.Json.JsonProperty("status")] + [System.Text.Json.Serialization.JsonPropertyName("status")] + public int Status { get; set; } + + /// + /// 获取或设置结果列表。 + /// + [Newtonsoft.Json.JsonProperty("data_list")] + [System.Text.Json.Serialization.JsonPropertyName("data_list")] + public Types.Result[] ResultList { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserRequest.cs new file mode 100644 index 00000000..d8dac3c2 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/simple_user 接口的请求。 + /// + public class CgibinExportSimpleUserRequest : WechatWorkRequest + { + /// + /// 获取或设置 Base64 编码的加密密钥。 + /// + [Newtonsoft.Json.JsonProperty("encoding_aeskey")] + [System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")] + public string EncodingAESKey { get; set; } = string.Empty; + + /// + /// 获取或设置每块数据的人员数。 + /// + [Newtonsoft.Json.JsonProperty("block_size")] + [System.Text.Json.Serialization.JsonPropertyName("block_size")] + public int? BlockSize { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserResponse.cs new file mode 100644 index 00000000..552c0652 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportSimpleUserResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/simple_user 接口的响应。 + /// + public class CgibinExportSimpleUserResponse : WechatWorkResponse + { + /// + /// 获取或设置导出任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("jobid")] + [System.Text.Json.Serialization.JsonPropertyName("jobid")] + public string JobId { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserRequest.cs new file mode 100644 index 00000000..a8a21d5b --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserRequest.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/taguser 接口的请求。 + /// + public class CgibinExportTagUserRequest : WechatWorkRequest + { + /// + /// 获取或设置标签 ID。 + /// + [Newtonsoft.Json.JsonProperty("tagid")] + [System.Text.Json.Serialization.JsonPropertyName("tagid")] + public int TagId { get; set; } + + /// + /// 获取或设置 Base64 编码的加密密钥。 + /// + [Newtonsoft.Json.JsonProperty("encoding_aeskey")] + [System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")] + public string EncodingAESKey { get; set; } = string.Empty; + + /// + /// 获取或设置每块数据的人员数。 + /// + [Newtonsoft.Json.JsonProperty("block_size")] + [System.Text.Json.Serialization.JsonPropertyName("block_size")] + public int? BlockSize { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserResponse.cs new file mode 100644 index 00000000..f13a5533 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportTagUserResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/taguser 接口的响应。 + /// + public class CgibinExportTagUserResponse : WechatWorkResponse + { + /// + /// 获取或设置导出任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("jobid")] + [System.Text.Json.Serialization.JsonPropertyName("jobid")] + public string JobId { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserRequest.cs new file mode 100644 index 00000000..694eab10 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/user 接口的请求。 + /// + public class CgibinExportUserRequest : WechatWorkRequest + { + /// + /// 获取或设置 Base64 编码的加密密钥。 + /// + [Newtonsoft.Json.JsonProperty("encoding_aeskey")] + [System.Text.Json.Serialization.JsonPropertyName("encoding_aeskey")] + public string EncodingAESKey { get; set; } = string.Empty; + + /// + /// 获取或设置每块数据的人员数。 + /// + [Newtonsoft.Json.JsonProperty("block_size")] + [System.Text.Json.Serialization.JsonPropertyName("block_size")] + public int? BlockSize { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserResponse.cs new file mode 100644 index 00000000..a75d620a --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExport/CgibinExportUserResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Work.Models +{ + /// + /// 表示 [POST] /cgi-bin/export/user 接口的响应。 + /// + public class CgibinExportUserResponse : WechatWorkResponse + { + /// + /// 获取或设置导出任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("jobid")] + [System.Text.Json.Serialization.JsonPropertyName("jobid")] + public string JobId { get; set; } = default!; + } +}