Skip to content

Commit

Permalink
feat(work): 新增安全管理高级功能账号相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Mar 13, 2024
1 parent 8c0ad7d commit 61af80e
Show file tree
Hide file tree
Showing 24 changed files with 400 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/WechatApi/Migration_V3.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ bool ret = (bool)eret;

为了统一并规范化各个模块,我们调整了部分方法的命名参数。如果你在调用该方法时使用了命名实参,请注意修改。

涉及此变化的包括 `DeserializeEventFromJson()``DeserializeEventFromXml()``SerializeEventToJson``SerializeEventToXml``VerifyEventSignatureForEcho``VerifyEventSignatureFromJson``VerifyEventSignatureFromXml` 等扩展方法,及 `AESUtility``SHA1Utility``HMACUtility` 等工具类。
涉及此变化的包括 `DeserializeEventFromJson()``DeserializeEventFromXml()``SerializeEventToJson()``SerializeEventToXml()``VerifyEventSignatureForEcho()``VerifyEventSignatureFromJson()``VerifyEventSignatureFromXml()` 等扩展方法,及 `AESUtility``SHA1Utility``HMACUtility` 等工具类。
2 changes: 1 addition & 1 deletion docs/WechatTenpayV3/Migration_V3.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool ret = (bool)eret;

为了统一并规范化各个模块,我们调整了部分方法的命名参数。如果你在调用该方法时使用了命名实参,请注意修改。

涉及此变化的包括 `DeserializeEvent()``DecryptEventResource()``VerifyEventSignature``VerifyResponseSignature` 等扩展方法,及 `AESUtility``RSAUtility``SHA256Utility``SM2Utility``SM3Utility``SM4Utility` 等工具类。
涉及此变化的包括 `DeserializeEvent()``DecryptEventResource()``VerifyEventSignature()``VerifyResponseSignature()` 等扩展方法,及 `AESUtility``RSAUtility``SHA256Utility``SM2Utility``SM3Utility``SM4Utility` 等工具类。

### 遇到报错:"NotSupportedException: Private key format is not supported."

Expand Down
2 changes: 1 addition & 1 deletion docs/WechatWork/Migration_V3.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ bool ret = (bool)eret;

为了统一并规范化各个模块,我们调整了部分方法的命名参数。如果你在调用该方法时使用了命名实参,请注意修改。

涉及此变化的包括 `DeserializeEventFromJson()``DeserializeEventFromXml()``SerializeEventToJson``SerializeEventToXml``VerifyEventSignatureForEcho``VerifyEventSignatureFromJson``VerifyEventSignatureFromXml` 等扩展方法,及 `AESUtility``RSAUtility``SHA1Utility` 等工具类。
涉及此变化的包括 `DeserializeEventFromJson()``DeserializeEventFromXml()``SerializeEventToJson()``SerializeEventToXml()``VerifyEventSignatureForEcho()``VerifyEventSignatureFromJson()``VerifyEventSignatureFromXml()` 等扩展方法,及 `AESUtility``RSAUtility``SHA1Utility` 等工具类。
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,122 @@ public static class WechatWorkClientExecuteCgibinSecurityExtensions

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityGetFileOperateRecordResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

#region Vip
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/security/vip/submit_batch_add_job 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99503 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSecurityVipSubmitBatchAddJobResponse> ExecuteCgibinSecurityVipSubmitBatchAddJobAsync(this WechatWorkClient client, Models.CgibinSecurityVipSubmitBatchAddJobRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "security", "vip", "submit_batch_add_job")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityVipSubmitBatchAddJobResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/security/vip/batch_add_job_result 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99503 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSecurityVipBatchAddJobResultResponse> ExecuteCgibinSecurityVipBatchAddJobResultAsync(this WechatWorkClient client, Models.CgibinSecurityVipBatchAddJobResultRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "security", "vip", "batch_add_job_result")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityVipBatchAddJobResultResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/security/vip/submit_batch_del_job 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99505 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSecurityVipSubmitBatchDeleteJobResponse> ExecuteCgibinSecurityVipSubmitBatchDeleteJobAsync(this WechatWorkClient client, Models.CgibinSecurityVipSubmitBatchDeleteJobRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "security", "vip", "submit_batch_del_job")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityVipSubmitBatchDeleteJobResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/security/vip/batch_del_job_result 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99505 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSecurityVipBatchDeleteJobResultResponse> ExecuteCgibinSecurityVipBatchDeleteJobResultAsync(this WechatWorkClient client, Models.CgibinSecurityVipBatchDeleteJobResultRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "security", "vip", "batch_del_job_result")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityVipBatchDeleteJobResultResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// <para>异步调用 [POST] /cgi-bin/security/vip/list 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developer.work.weixin.qq.com/document/path/99506 ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinSecurityVipListResponse> ExecuteCgibinSecurityVipListAsync(this WechatWorkClient client, Models.CgibinSecurityVipListRequest 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
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "security", "vip", "list")
.SetQueryParam("access_token", request.AccessToken);

return await client.SendFlurlRequestAsJsonAsync<Models.CgibinSecurityVipListResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/batch_add_job_result 接口的请求。</para>
/// </summary>
public class CgibinSecurityVipBatchAddJobResultRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置任务 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("jobid")]
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
public string JobId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/batch_add_job_result 接口的响应。</para>
/// </summary>
public class CgibinSecurityVipBatchAddJobResultResponse : WechatWorkResponse
{
public static class Types
{
public class JobResult
{
/// <summary>
/// 获取或设置分配成功的成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("succ_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("succ_userid_list")]
public string[]? SuccessfulUserIdList { get; set; }

/// <summary>
/// 获取或设置分配失败的成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("fail_userid_list")]
public string[]? FailedUserIdList { get; set; }
}
}

/// <summary>
/// 获取或设置任务结果信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("job_result")]
[System.Text.Json.Serialization.JsonPropertyName("job_result")]
public Types.JobResult JobResult { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/batch_del_job_result 接口的请求。</para>
/// </summary>
public class CgibinSecurityVipBatchDeleteJobResultRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置任务 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("jobid")]
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
public string JobId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/batch_del_job_result 接口的响应。</para>
/// </summary>
public class CgibinSecurityVipBatchDeleteJobResultResponse : WechatWorkResponse
{
public static class Types
{
public class JobResult
{
/// <summary>
/// 获取或设置撤销分配成功的成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("succ_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("succ_userid_list")]
public string[]? SuccessfulUserIdList { get; set; }

/// <summary>
/// 获取或设置撤销分配失败的成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("fail_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("fail_userid_list")]
public string[]? FailedUserIdList { get; set; }
}
}

/// <summary>
/// 获取或设置任务结果信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("job_result")]
[System.Text.Json.Serialization.JsonPropertyName("job_result")]
public Types.JobResult JobResult { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/list 接口的请求。</para>
/// </summary>
public class CgibinSecurityVipListRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置分页每页数量。
/// </summary>
[Newtonsoft.Json.JsonProperty("limit")]
[System.Text.Json.Serialization.JsonPropertyName("limit")]
public int? Limit { get; set; }

/// <summary>
/// 获取或设置翻页标记。
/// </summary>
[Newtonsoft.Json.JsonProperty("cursor")]
[System.Text.Json.Serialization.JsonPropertyName("cursor")]
public string? Cursor { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/list 接口的响应。</para>
/// </summary>
public class CgibinSecurityVipListResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("userid_list")]
public string[] UserIdList { get; set; } = default!;

/// <summary>
/// 获取或设置是否还有更多数据。
/// </summary>
[Newtonsoft.Json.JsonProperty("has_more")]
[System.Text.Json.Serialization.JsonPropertyName("has_more")]
public bool HasMore { get; set; }

/// <summary>
/// 获取或设置翻页标记。
/// </summary>
[Newtonsoft.Json.JsonProperty("next_cursor")]
[System.Text.Json.Serialization.JsonPropertyName("next_cursor")]
public string? NextCursor { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/submit_batch_add_job 接口的请求。</para>
/// </summary>
public class CgibinSecurityVipSubmitBatchAddJobRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("userid_list")]
public IList<string>? UserIdList { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/submit_batch_add_job 接口的响应。</para>
/// </summary>
public class CgibinSecurityVipSubmitBatchAddJobResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置任务 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("jobid")]
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
public string JobId { get; set; } = default!;

/// <summary>
/// 获取或设置无效的成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("invalid_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("invalid_userid_list")]
public string[]? InvalidUserIdList { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/submit_batch_del_job 接口的请求。</para>
/// </summary>
public class CgibinSecurityVipSubmitBatchDeleteJobRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("userid_list")]
public IList<string>? UserIdList { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/security/vip/submit_batch_del_job 接口的响应。</para>
/// </summary>
public class CgibinSecurityVipSubmitBatchDeleteJobResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置任务 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("jobid")]
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
public string JobId { get; set; } = default!;

/// <summary>
/// 获取或设置成员账号列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("invalid_userid_list")]
[System.Text.Json.Serialization.JsonPropertyName("invalid_userid_list")]
public string[]? InvalidUserIdList { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jobid": "xxx"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"errcode": 0,
"errmsg": "ok",
"job_result": {
"succ_userid_list": [ "zhangsan", "lisi" ],
"fail_userid_list": [ "wangwu" ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jobid": "xxx"
}
Loading

0 comments on commit 61af80e

Please sign in to comment.