mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
feat(work): 新增第三方代开发账号 ID 转换相关接口
This commit is contained in:
parent
f4fde0733b
commit
e0bb4d7ca0
@ -0,0 +1,21 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 INFO.corp_arch_auth 事件的数据。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97378 </para>
|
||||
/// </summary>
|
||||
public class CorpArchitectureAuthEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置第三方应用的 SuiteId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("SuiteId")]
|
||||
public string SuiteId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置授权方的 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AuthCorpId")]
|
||||
public string AuthorizerCorpId { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
{
|
||||
public static class WechatWorkClientExecuteCgibinIdConvertExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/idconvert/unionid_to_external_userid 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95926 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinIdConvertUnionIdToExternalUserIdResponse> ExecuteCgibinIdConvertUnionIdToExternalUserIdAsync(this WechatWorkClient client, Models.CgibinIdConvertUnionIdToExternalUserIdRequest 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", "idconvert", "unionid_to_external_userid")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinIdConvertUnionIdToExternalUserIdResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/idconvert/batch/external_userid_to_pending_id 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95926 </para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95900 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinIdConvertBatchExternalUserIdToPendingIdResponse> ExecuteCgibinIdConvertBatchExternalUserIdToPendingIdAsync(this WechatWorkClient client, Models.CgibinIdConvertBatchExternalUserIdToPendingIdRequest 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", "idconvert", "batch", "external_userid_to_pending_id")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinIdConvertBatchExternalUserIdToPendingIdResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/idconvert/external_tagid 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95926 </para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/96169 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinIdConvertExternalTagIdResponse> ExecuteCgibinIdConvertExternalTagIdAsync(this WechatWorkClient client, Models.CgibinIdConvertExternalTagIdRequest 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", "idconvert", "external_tagid")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinIdConvertExternalTagIdResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/idconvert/open_kfid 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/97064 </para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/96169 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinIdConvertOpenKfIdResponse> ExecuteCgibinIdConvertOpenKfIdAsync(this WechatWorkClient client, Models.CgibinIdConvertOpenKfIdRequest 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", "idconvert", "open_kfid")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinIdConvertOpenKfIdResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/batch/external_userid_to_pending_id 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertBatchExternalUserIdToPendingIdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置群聊 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("chat_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("chat_id")]
|
||||
public string? ChatId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置外部联系人账号列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid")]
|
||||
public IList<string> ExternalUserIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/batch/external_userid_to_pending_id 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertBatchExternalUserIdToPendingIdResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置外部联系人账号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid")]
|
||||
public string ExternalUserId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置临时部联系人账号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pending_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pending_id")]
|
||||
public string PendingExternalUserId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("result")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/external_tagid 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertExternalTagIdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置客户标签 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_tagid_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_tagid_list")]
|
||||
public IList<string> ExternalTagIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/external_tagid 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertExternalTagIdResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置客户标签 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_tagid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_tagid")]
|
||||
public string ExternalTagId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置服务商下的客户标签 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("open_external_tagid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("open_external_tagid")]
|
||||
public string OpenExternalTagId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("items")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("items")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置无效的客户标签 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("invalid_external_tagid_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("invalid_external_tagid_list")]
|
||||
public string[]? InvalidExternalTagIdList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/open_kfid 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertOpenKfIdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置客服账号 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("open_kfid_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("open_kfid_list")]
|
||||
public IList<string> OpenKfIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/open_kfid 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertOpenKfIdResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置客服账号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("open_kfid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("open_kfid")]
|
||||
public string OpenKfId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置服务商下的客服账号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("new_open_kfid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("new_open_kfid")]
|
||||
public string NewOpenKfId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("items")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("items")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置无效的客服账号 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("invalid_open_kfid_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("invalid_open_kfid_list")]
|
||||
public string[]? InvalidOpenKfIdList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/unionid_to_external_userid 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertUnionIdToExternalUserIdRequest : 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>
|
||||
/// 获取或设置主体类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("subject_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("subject_type")]
|
||||
public int SubjectType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/idconvert/unionid_to_external_userid 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinIdConvertUnionIdToExternalUserIdResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置外部联系人账号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid")]
|
||||
public string? ExternalUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置临时部联系人账号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pending_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pending_id")]
|
||||
public string? PendingExternalUserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<xml>
|
||||
<SuiteId><![CDATA[ww4asffe99e54c0fxxxx]]></SuiteId>
|
||||
<AuthCorpId><![CDATA[wxf8b4f85f3a79xxxx]]></AuthCorpId>
|
||||
<InfoType><![CDATA[corp_arch_auth]]></InfoType>
|
||||
<TimeStamp>1403610513</TimeStamp>
|
||||
</xml>
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"chat_id": "xxxxxx",
|
||||
"external_userid": ["oAAAAAAA", "oBBBBB"]
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"result": [
|
||||
{
|
||||
"external_userid": "oAAAAAAA",
|
||||
"pending_id": "pAAAAA"
|
||||
},
|
||||
{
|
||||
"external_userid": "oBBBBB",
|
||||
"pending_id": "pBBBBB"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"external_tagid_list": ["TAG_ID1", "TAG_ID2", "TAG_ID3", "TAG_ID4"]
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"items": [
|
||||
{
|
||||
"external_tagid": "TAG_ID1",
|
||||
"open_external_tagid": "OPEN_TAG_ID1"
|
||||
},
|
||||
{
|
||||
"external_tagid": "TAG_ID2",
|
||||
"open_external_tagid": "OPEN_TAG_ID2"
|
||||
}
|
||||
],
|
||||
"invalid_external_tagid_list": ["TAG_ID3", "TAG_ID4"]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"open_kfid_list": ["KFID1", "KFID2", "KFID3", "KFID4"]
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"items": [
|
||||
{
|
||||
"open_kfid": "KFID1",
|
||||
"new_open_kfid": "NEW_KFID1"
|
||||
},
|
||||
{
|
||||
"open_kfid": "KFID2",
|
||||
"new_open_kfid": "NEW_KFID2"
|
||||
}
|
||||
],
|
||||
"invalid_open_kfid_list": ["KFID3", "KFID4"]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"unionid": "oAAAAAAA",
|
||||
"openid": "oBBBB",
|
||||
"subject_type": 1
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"external_userid": "ooAAAAAAAAAAA",
|
||||
"pending_id": "ooBBBBBB"
|
||||
}
|
Loading…
Reference in New Issue
Block a user