feat(work): 新增管理聊天敏感词相关接口

This commit is contained in:
Fu Diwei
2021-09-30 15:49:17 +08:00
parent 8ea180cc7d
commit 2869492948
23 changed files with 562 additions and 3 deletions

View File

@@ -1516,5 +1516,112 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactDeleteProductAlbumResponse>(flurlReq, data: request, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactDeleteProductAlbumResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
} }
#endregion #endregion
#region InterceptRule
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalcontact/add_intercept_rule 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95097 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95130 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalContactAddInterceptRuleResponse> ExecuteCgibinExternalContactAddInterceptRuleAsync(this WechatWorkClient client, Models.CgibinExternalContactAddInterceptRuleRequest 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", "externalcontact", "add_intercept_rule")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactAddInterceptRuleResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_intercept_rule_list 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95097 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95130 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalContactGetInterceptRuleListResponse> ExecuteCgibinExternalContactGetInterceptRuleListAsync(this WechatWorkClient client, Models.CgibinExternalContactGetInterceptRuleListRequest 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", "externalcontact", "get_intercept_rule_list")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetInterceptRuleListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_intercept_rule 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95097 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95130 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalContactGetInterceptRuleResponse> ExecuteCgibinExternalContactGetInterceptRuleAsync(this WechatWorkClient client, Models.CgibinExternalContactGetInterceptRuleRequest 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", "externalcontact", "get_intercept_rule")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetInterceptRuleResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalcontact/update_intercept_rule 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95097 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95130 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalContactUpdateInterceptRuleResponse> ExecuteCgibinExternalContactUpdateInterceptRuleAsync(this WechatWorkClient client, Models.CgibinExternalContactUpdateInterceptRuleRequest 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", "externalcontact", "update_intercept_rule")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactUpdateInterceptRuleResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/externalcontact/del_intercept_rule 接口。</para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95097 </para>
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95130 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinExternalContactDeleteInterceptRuleResponse> ExecuteCgibinExternalContactDeleteInterceptRuleAsync(this WechatWorkClient client, Models.CgibinExternalContactDeleteInterceptRuleRequest 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", "externalcontact", "del_intercept_rule")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactDeleteInterceptRuleResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
} }
} }

View File

@@ -0,0 +1,65 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/add_intercept_rule 接口的请求。</para>
/// </summary>
public class CgibinExternalContactAddInterceptRuleRequest : WechatWorkRequest
{
public static class Types
{
public class ApplicableRange
{
/// <summary>
/// 获取或设置用户 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_list")]
[System.Text.Json.Serialization.JsonPropertyName("user_list")]
public IList<string>? UserIdList { get; set; }
/// <summary>
/// 获取或设置部门 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public IList<int>? DepartmentIdList { get; set; }
}
}
/// <summary>
/// 获取或设置规则名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_name")]
[System.Text.Json.Serialization.JsonPropertyName("rule_name")]
public string RuleName { get; set; } = string.Empty;
/// <summary>
/// 获取或设置敏感词列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("word_list")]
[System.Text.Json.Serialization.JsonPropertyName("word_list")]
public IList<string> WordList { get; set; } = new List<string>();
/// <summary>
/// 获取或设置拦截语义列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("semantics_list")]
[System.Text.Json.Serialization.JsonPropertyName("semantics_list")]
public IList<int>? SemanticsList { get; set; }
/// <summary>
/// 获取或设置拦截类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("intercept_type")]
[System.Text.Json.Serialization.JsonPropertyName("intercept_type")]
public int InterceptType { get; set; }
/// <summary>
/// 获取或设置生效范围。
/// </summary>
[Newtonsoft.Json.JsonProperty("applicable_range")]
[System.Text.Json.Serialization.JsonPropertyName("applicable_range")]
public Types.ApplicableRange? ApplicableRange { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/add_intercept_rule 接口的响应。</para>
/// </summary>
public class CgibinExternalContactAddInterceptRuleResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置规则 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_id")]
[System.Text.Json.Serialization.JsonPropertyName("rule_id")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalStringConverter))]
public string RuleId { get; set; } = default!;
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/del_intercept_rule 接口的请求。</para>
/// </summary>
public class CgibinExternalContactDeleteInterceptRuleRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置规则 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_id")]
[System.Text.Json.Serialization.JsonPropertyName("rule_id")]
public string RuleId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/del_intercept_rule 接口的响应。</para>
/// </summary>
public class CgibinExternalContactDeleteInterceptRuleResponse : WechatWorkResponse
{
}
}

View File

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

View File

@@ -0,0 +1,43 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/get_intercept_rule_list 接口的响应。</para>
/// </summary>
public class CgibinExternalContactGetInterceptRuleListResponse : WechatWorkResponse
{
public static class Types
{
public class Rule
{
/// <summary>
/// 获取或设置规则 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_id")]
[System.Text.Json.Serialization.JsonPropertyName("rule_id")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalStringConverter))]
public string RuleId { get; set; } = default!;
/// <summary>
/// 获取或设置规则名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_name")]
[System.Text.Json.Serialization.JsonPropertyName("rule_name")]
public string RuleName { get; set; } = default!;
/// <summary>
/// 获取或设置创建时间戳。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
public long CreateTimestamp { get; set; }
}
}
/// <summary>
/// 获取或设置规则列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_list")]
[System.Text.Json.Serialization.JsonPropertyName("rule_list")]
public Types.Rule[] RuleList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/get_intercept_rule 接口的请求。</para>
/// </summary>
public class CgibinExternalContactGetInterceptRuleRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置规则 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_id")]
[System.Text.Json.Serialization.JsonPropertyName("rule_id")]
public string RuleId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,79 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/get_intercept_rule 接口的响应。</para>
/// </summary>
public class CgibinExternalContactGetInterceptRuleResponse : WechatWorkResponse
{
public static class Types
{
public class Rule : CgibinExternalContactGetInterceptRuleListResponse.Types.Rule
{
public static class Types
{
public class ExtraRule
{
/// <summary>
/// 获取或设置拦截语义列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("semantics_list")]
[System.Text.Json.Serialization.JsonPropertyName("semantics_list")]
public int[]? SemanticsList { get; set; }
}
public class ApplicableRange
{
/// <summary>
/// 获取或设置用户 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_list")]
[System.Text.Json.Serialization.JsonPropertyName("user_list")]
public string[]? UserIdList { get; set; }
/// <summary>
/// 获取或设置部门 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("department_list")]
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
public int[]? DepartmentIdList { get; set; }
}
}
/// <summary>
/// 获取或设置敏感词列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("word_list")]
[System.Text.Json.Serialization.JsonPropertyName("word_list")]
public string[] WordList { get; set; } = default!;
/// <summary>
/// 获取或设置额外规则信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("extra_rule")]
[System.Text.Json.Serialization.JsonPropertyName("extra_rule")]
public Types.ExtraRule? ExtraRule { get; set; }
/// <summary>
/// 获取或设置拦截类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("intercept_type")]
[System.Text.Json.Serialization.JsonPropertyName("intercept_type")]
public int InterceptType { get; set; }
/// <summary>
/// 获取或设置生效范围。
/// </summary>
[Newtonsoft.Json.JsonProperty("applicable_range")]
[System.Text.Json.Serialization.JsonPropertyName("applicable_range")]
public Types.ApplicableRange? ApplicableRange { get; set; }
}
}
/// <summary>
/// 获取或设置规则信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule")]
[System.Text.Json.Serialization.JsonPropertyName("rule")]
public Types.Rule Rule { get; set; } = default!;
}
}

View File

@@ -0,0 +1,76 @@
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/update_intercept_rule 接口的请求。</para>
/// </summary>
public class CgibinExternalContactUpdateInterceptRuleRequest : WechatWorkRequest
{
public static class Types
{
public class ApplicableRange : CgibinExternalContactAddInterceptRuleRequest.Types.ApplicableRange
{
}
public class ExtraRule
{
/// <summary>
/// 获取或设置拦截语义列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("semantics_list")]
[System.Text.Json.Serialization.JsonPropertyName("semantics_list")]
public IList<int>? SemanticsList { get; set; }
}
}
/// <summary>
/// 获取或设置规则 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_id")]
[System.Text.Json.Serialization.JsonPropertyName("rule_id")]
public string RuleId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置规则名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("rule_name")]
[System.Text.Json.Serialization.JsonPropertyName("rule_name")]
public string RuleName { get; set; } = string.Empty;
/// <summary>
/// 获取或设置敏感词列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("word_list")]
[System.Text.Json.Serialization.JsonPropertyName("word_list")]
public IList<string> WordList { get; set; } = new List<string>();
/// <summary>
/// 获取或设置额外规则信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("extra_rule")]
[System.Text.Json.Serialization.JsonPropertyName("extra_rule")]
public Types.ExtraRule? ExtraRule { get; set; }
/// <summary>
/// 获取或设置拦截类型。
/// </summary>
[Newtonsoft.Json.JsonProperty("intercept_type")]
[System.Text.Json.Serialization.JsonPropertyName("intercept_type")]
public int? InterceptType { get; set; }
/// <summary>
/// 获取或设置要新增的生效范围。
/// </summary>
[Newtonsoft.Json.JsonProperty("add_applicable_range")]
[System.Text.Json.Serialization.JsonPropertyName("add_applicable_range")]
public Types.ApplicableRange? AddApplicableRange { get; set; }
/// <summary>
/// 获取或设置要删除的生效范围。
/// </summary>
[Newtonsoft.Json.JsonProperty("remove_applicable_range")]
[System.Text.Json.Serialization.JsonPropertyName("remove_applicable_range")]
public Types.ApplicableRange? RemoveApplicableRange { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/externalcontact/update_intercept_rule 接口的响应。</para>
/// </summary>
public class CgibinExternalContactUpdateInterceptRuleResponse : WechatWorkResponse
{
}
}

View File

@@ -14,7 +14,7 @@
/// </summary> /// </summary>
[Newtonsoft.Json.JsonProperty("create_time")] [Newtonsoft.Json.JsonProperty("create_time")]
[System.Text.Json.Serialization.JsonPropertyName("create_time")] [System.Text.Json.Serialization.JsonPropertyName("create_time")]
public long CreateTimetamp { get; set; } public long CreateTimestamp { get; set; }
} }
} }

View File

@@ -26,14 +26,14 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
/// </summary> /// </summary>
[Newtonsoft.Json.JsonProperty("description")] [Newtonsoft.Json.JsonProperty("description")]
[System.Text.Json.Serialization.JsonPropertyName("description")] [System.Text.Json.Serialization.JsonPropertyName("description")]
public string Description { get; set; } = string.Empty; public string? Description { get; set; }
/// <summary> /// <summary>
/// 获取或设置商品价格(单位:分)。 /// 获取或设置商品价格(单位:分)。
/// </summary> /// </summary>
[Newtonsoft.Json.JsonProperty("price")] [Newtonsoft.Json.JsonProperty("price")]
[System.Text.Json.Serialization.JsonPropertyName("price")] [System.Text.Json.Serialization.JsonPropertyName("price")]
public int Price { get; set; } public int? Price { get; set; }
/// <summary> /// <summary>
/// 获取或设置商品编码。 /// 获取或设置商品编码。

View File

@@ -0,0 +1,22 @@
{
"rule_name": "rulename",
"word_list": [
"敏感词1",
"敏感词2"
],
"semantics_list": [
1,
2,
3
],
"intercept_type": 1,
"applicable_range": {
"user_list": [
"zhangshan"
],
"department_list": [
2,
3
]
}
}

View File

@@ -0,0 +1,11 @@
{
"errcode": 0,
"errmsg": "ok",
"rule_list": [
{
"rule_id": "xxxx",
"rule_name": "rulename",
"create_time": 1600000000
}
]
}

View File

@@ -0,0 +1,29 @@
{
"errcode": 0,
"errmsg": "ok",
"rule": {
"rule_id": 1,
"rule_name": "rulename",
"word_list": [
"敏感词1",
"敏感词2"
],
"extra_rule": {
"semantics_list": [
1,
2,
3
]
},
"intercept_type": 1,
"applicable_range": {
"user_list": [
"zhangshan"
],
"department_list": [
2,
3
]
}
}
}

View File

@@ -0,0 +1,34 @@
{
"rule_id": "xxxx",
"rule_name": "rulename",
"word_list": [
"敏感词1",
"敏感词2"
],
"extra_rule": {
"semantics_list": [
1,
2,
3
]
},
"intercept_type": 1,
"add_applicable_range": {
"user_list": [
"zhangshan"
],
"department_list": [
2,
3
]
},
"remove_applicable_range": {
"user_list": [
"zhangshan"
],
"department_list": [
2,
3
]
}
}