mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 14:04:32 +08:00
feat(work): 新增上下游相关接口
This commit is contained in:
parent
06586b08be
commit
d808721c99
@ -52,5 +52,92 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCropGetTokenResponse>(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>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinCorpGroupCropGetChainListResponse> ExecuteCgibinCorpGroupCropGetChainListAsync(this WechatWorkClient client, Models.CgibinCorpGroupCropGetChainListRequest 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", "corpgroup", "corp", "get_chain_list")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCropGetChainListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/corpgroup/corp/get_chain_group 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95315 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinCorpGroupCropGetChainGroupResponse> ExecuteCgibinCorpGroupCropGetChainGroupAsync(this WechatWorkClient client, Models.CgibinCorpGroupCropGetChainGroupRequest 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_group")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCropGetChainGroupResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/corpgroup/corp/get_chain_corpinfo_list 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95315 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinCorpGroupCropGetChainCorpInfoListResponse> ExecuteCgibinCorpGroupCropGetChainCorpInfoListAsync(this WechatWorkClient client, Models.CgibinCorpGroupCropGetChainCorpInfoListRequest 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", "corpgroup", "corp", "get_chain_corpinfo_list")
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("chain_id", request.ChainId);
|
||||
|
||||
if (request.GroupId != null)
|
||||
flurlReq.SetQueryParam("groupid", request.GroupId.Value);
|
||||
|
||||
if (request.RequireFetchChild != null)
|
||||
flurlReq.SetQueryParam("fetch_child", request.RequireFetchChild.Value ? 1 : 0);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupCropGetChainCorpInfoListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/corpgroup/unionid_to_external_userid 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95342 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinCorpGroupUnionidToExternalUserIdResponse> ExecuteCgibinCorpGroupUnionidToExternalUserIdAsync(this WechatWorkClient client, Models.CgibinCorpGroupUnionidToExternalUserIdRequest 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", "unionid_to_external_userid")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinCorpGroupUnionidToExternalUserIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/corpgroup/corp/get_chain_corpinfo_list 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainCorpInfoListRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置上下游 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string ChainId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分组 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public int? GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否递归获取子分组企业。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public bool? RequireFetchChild { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/corpgroup/corp/get_chain_corpinfo_list 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainCorpInfoListResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class GroupCorp
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置分组 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("groupid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("groupid")]
|
||||
public int GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置企业 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("corpid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
|
||||
public string CorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置企业名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("corp_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("corp_name")]
|
||||
public string CorpName { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置自定义 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("custom_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("custom_id")]
|
||||
public string? CustomId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置企业上下游通讯录分组下的企业详情列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("group_corps")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("group_corps")]
|
||||
public Types.GroupCorp[] GroupCorpList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/corpgroup/corp/get_chain_group 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainGroupRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置上下游 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("chain_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("chain_id")]
|
||||
public string ChainId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/corpgroup/corp/get_chain_group 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainGroupResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Group
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置分组 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("groupid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("groupid")]
|
||||
public int GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分组名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("group_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("group_name")]
|
||||
public string GroupName { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置上级分组名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("parentid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("parentid")]
|
||||
public int ParentGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置在上级分组中的次序值。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("order")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("order")]
|
||||
public long GroupOrder { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置企业上下游通讯录分组列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("groups")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("groups")]
|
||||
public Types.Group[] GroupList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/corpgroup/corp/get_chain_list 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainListRequest : WechatWorkRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /cgi-bin/corpgroup/corp/get_chain_list 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupCropGetChainListResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Chain
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置上下游 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("chain_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("chain_id")]
|
||||
public string ChainId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置上下游名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("chain_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("chain_name")]
|
||||
public string ChainName { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置企业上下游列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("chains")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("chains")]
|
||||
public Types.Chain[] ChainList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/corpgroup/unionid_to_external_userid 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupUnionidToExternalUserIdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户 UnionId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("unionid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("unionid")]
|
||||
public string? UnionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string? OpenId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置需要换取的企业 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("corpid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
|
||||
public string? CorpId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/corpgroup/unionid_to_external_userid 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinCorpGroupUnionidToExternalUserIdResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class ExternalUser
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置企业 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("corpid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
|
||||
public string CorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置外部联系人账号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid")]
|
||||
public string ExternalUserId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置外部联系人列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid_info")]
|
||||
public Types.ExternalUser[] ExternalUserList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"group_corps": [
|
||||
{
|
||||
"groupid": 2,
|
||||
"corpid": "wwxxxx",
|
||||
"corp_name": "美馨粮油公司",
|
||||
"custom_id": "wof3du51quo5sl1is"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"chain_id": "Chxxxxxx"
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"groups": [
|
||||
{
|
||||
"groupid": 2,
|
||||
"group_name": "一级经销商",
|
||||
"parentid": 1,
|
||||
"order": 1
|
||||
},
|
||||
{
|
||||
"groupid": 3,
|
||||
"group_name": "二级经销商",
|
||||
"parentid": 2,
|
||||
"order": 3
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"chains": [
|
||||
{
|
||||
"chain_id": "chainid1",
|
||||
"chain_name": "能源供应链"
|
||||
},
|
||||
{
|
||||
"chain_id": "chainid2",
|
||||
"chain_name": "原材料供应链"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"unionid": "xxxxx",
|
||||
"openid": "xxxxx",
|
||||
"corpid": "xxxxx"
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"external_userid_info": [
|
||||
{
|
||||
"corpid": "AAAAA",
|
||||
"external_userid": "BBBB"
|
||||
},
|
||||
{
|
||||
"corpid": "CCCCC",
|
||||
"external_userid": "DDDDD"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user