feat(work): 随官方更新上下游通讯录管理相关接口模型

This commit is contained in:
fudiwei
2023-01-12 10:10:18 +08:00
parent 233a780b94
commit 2bb89a58ad
10 changed files with 117 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

View File

@@ -71,6 +71,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
}
#region Corp
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/gettoken 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/93359 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinCorpGroupCorpGetTokenResponse> ExecuteCgibinCorpGroupCorpGetTokenAsync(this WechatWorkClient client, Models.CgibinCorpGroupCorpGetTokenRequest 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", "corp", "gettoken")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCorpGetTokenResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/list_app_share_info 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/93403 </para>
@@ -95,26 +115,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCorpListAppShareInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/gettoken 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/93359 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinCorpGroupCorpGetTokenResponse> ExecuteCgibinCorpGroupCorpGetTokenAsync(this WechatWorkClient client, Models.CgibinCorpGroupCorpGetTokenRequest 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", "corp", "gettoken")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCorpGetTokenResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /cgi-bin/corpgroup/corp/get_chain_list 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95315 </para>
@@ -214,6 +214,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCorpRemoveCorpResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/get_chain_user_custom_id 接口。</para>
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97441 </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinCorpGroupCorpGetChainUserCustomIdResponse> ExecuteCgibinCorpGroupCorpGetChainUserCustomIdAsync(this WechatWorkClient client, Models.CgibinCorpGroupCorpGetChainUserCustomIdRequest 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", "corp", "get_chain_user_custom_id")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCorpGetChainUserCustomIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
#region Rule

View File

@@ -35,6 +35,13 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Models
[Newtonsoft.Json.JsonProperty("mobile")]
[System.Text.Json.Serialization.JsonPropertyName("mobile")]
public string? MobileNumber { get; set; }
/// <summary>
/// 获取或设置上下游用户自定义 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_custom_id")]
[System.Text.Json.Serialization.JsonPropertyName("user_custom_id")]
public string? UserCustomId { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/corpgroup/corp/get_chain_user_custom_id 接口的请求。</para>
/// </summary>
public class CgibinCorpGroupCorpGetChainUserCustomIdRequest : WechatWorkRequest
{
/// <summary>
/// 获取或设置上下游 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("chain_id")]
[System.Text.Json.Serialization.JsonPropertyName("chain_id")]
public string ChainId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置下级企业 CorpId。
/// </summary>
[Newtonsoft.Json.JsonProperty("corpid")]
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
public string CorpId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置下级企业成员 UserId
/// </summary>
[Newtonsoft.Json.JsonProperty("userid")]
[System.Text.Json.Serialization.JsonPropertyName("userid")]
public string UserId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,15 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/corpgroup/corp/get_chain_user_custom_id 接口的响应。</para>
/// </summary>
public class CgibinCorpGroupCorpGetChainUserCustomIdResponse : WechatWorkResponse
{
/// <summary>
/// 获取或设置上下游用户自定义 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("user_custom_id")]
[System.Text.Json.Serialization.JsonPropertyName("user_custom_id")]
public string UserCustomId { get; set; } = default!;
}
}

View File

@@ -1,4 +1,4 @@
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/corpgroup/corp/remove_corp 接口的请求。</para>
@@ -17,6 +17,13 @@
/// </summary>
[Newtonsoft.Json.JsonProperty("corpid")]
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
public string CorpId { get; set; } = string.Empty;
public string? CorpId { get; set; }
/// <summary>
/// 获取或设置未加入的企业 CorpId。
/// </summary>
[Newtonsoft.Json.JsonProperty("pending_corpid")]
[System.Text.Json.Serialization.JsonPropertyName("pending_corpid")]
public string? PendingCorpId { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
{
{
"chain_id": "xxxxxx",
"contact_list": [
{
@@ -9,7 +9,8 @@
{
"name": "张三",
"identity_type": 1,
"mobile": "13000000001"
"mobile": "13000000001",
"user_custom_id": "100"
},
{
"name": "李四",

View File

@@ -0,0 +1,5 @@
{
"chain_id": "Chxxxxxx",
"corpid": "xxxxx",
"userid": "xxxxx"
}

View File

@@ -0,0 +1,5 @@
{
"errcode": 0,
"errmsg": "ok",
"user_custom_id": "1234"
}

View File

@@ -1,4 +1,5 @@
{
{
"chain_id": "xxxx",
"corpid": "xxxxx"
"corpid": "xxxxx",
"pending_corpid": "xxxx"
}