mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-18 17:48:12 +08:00
feat(work): 适配企业微信帐号 ID 安全性全面升级
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 agree_external_userid_migration 事件的数据。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95327 </para>
|
||||
/// </summary>
|
||||
public class AgreeExternalUserIdMigrationEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable, WechatWorkEvent.Serialization.IJsonSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置服务商 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("ServiceCorpId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("ServiceCorpId")]
|
||||
[System.Xml.Serialization.XmlElement("ServiceCorpId")]
|
||||
public string ServiceCorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置授权方的 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("AuthCorpId")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("AuthCorpId")]
|
||||
[System.Xml.Serialization.XmlElement("AuthCorpId")]
|
||||
public string AuthorizerCorpId { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -585,5 +585,67 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinServiceMiniProgramJsCode2SessionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExternalContactMigration
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_new_external_userid 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95327 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExternalContactGetNewExternalUserIdResponse> ExecuteCgibinExternalContactGetNewExternalUserIdAsync(this WechatWorkClient client, Models.CgibinExternalContactGetNewExternalUserIdRequest 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_new_external_userid")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetNewExternalUserIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/service/externalcontact/finish_external_userid_migration 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95327 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinServiceExternalContactFinishExternalUserIdMigrationResponse> ExecuteCgibinServiceExternalContactFinishExternalUserIdMigrationAsync(this WechatWorkClient client, Models.CgibinServiceExternalContactFinishExternalUserIdMigrationRequest 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", "service", "externalcontact", "finish_external_userid_migration")
|
||||
.SetQueryParam("provider_access_token", request.ProviderAccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinServiceExternalContactFinishExternalUserIdMigrationResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/service/externalcontact/unionid_to_external_userid_3rd 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95327 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinServiceExternalContactUnionIdToExternalUserId3rdResponse> ExecuteCgibinServiceExternalContactUnionIdToExternalUserId3rdAsync(this WechatWorkClient client, Models.CgibinServiceExternalContactUnionIdToExternalUserId3rdRequest 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", "service", "externalcontact", "unionid_to_external_userid_3rd")
|
||||
.SetQueryParam("suite_access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinServiceExternalContactUnionIdToExternalUserId3rdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/get_new_external_userid 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactGetNewExternalUserIdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置原外部联系人账号列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_userid_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_userid_list")]
|
||||
public IList<string> ExternalUserIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/get_new_external_userid 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactGetNewExternalUserIdResponse : 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>
|
||||
/// 获取或设置新外部联系人账号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("new_external_userid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("new_external_userid")]
|
||||
public string NewExternalUserId { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置转换结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("items")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("items")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/service/externalcontact/finish_external_userid_migration 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinServiceExternalContactFinishExternalUserIdMigrationRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置服务商 AccessToken。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string ProviderAccessToken { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置迁移完成的企业 CorpId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("corpid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("corpid")]
|
||||
public string CorpId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/service/externalcontact/finish_external_userid_migration 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinServiceExternalContactFinishExternalUserIdMigrationResponse : WechatWorkResponse
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/service/externalcontact/unionid_to_external_userid_3rd 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinServiceExternalContactUnionIdToExternalUserId3rdRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置微信 UnionId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("unionid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("unionid")]
|
||||
public string UnionId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置微信 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <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/service/externalcontact/unionid_to_external_userid_3rd 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinServiceExternalContactUnionIdToExternalUserId3rdResponse : 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!;
|
||||
}
|
||||
}
|
@@ -66,16 +66,16 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
/// <summary>
|
||||
/// 获取或设置消息类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[Newtonsoft.Json.JsonProperty("InfoType")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("InfoType")]
|
||||
[XmlElement("InfoType", IsNullable = true)]
|
||||
public string? InfoType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置消息时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[Newtonsoft.Json.JsonProperty("TimeStamp")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("TimeStamp")]
|
||||
[XmlElement("TimeStamp", IsNullable = true)]
|
||||
public long? InfoTimestamp { get; set; }
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"AuthCorpId": "xxxx",
|
||||
"InfoType": "agree_external_userid_migration",
|
||||
"ServiceCorpId": "xxxx",
|
||||
"TimeStamp": 1403610513
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
<xml>
|
||||
<AuthCorpId><![CDATA[xxxx]]></AuthCorpId>
|
||||
<InfoType><![CDATA[agree_external_userid_migration]]></InfoType>
|
||||
<ServiceCorpId><![CDATA[xxxx]]></ServiceCorpId>
|
||||
<TimeStamp>1403610513</TimeStamp>
|
||||
</xml>
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"external_userid_list": [ "xxxxx", "yyyyyy" ]
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"items": [
|
||||
{
|
||||
"external_userid": "xxxxx",
|
||||
"new_external_userid": "AAAA"
|
||||
},
|
||||
{
|
||||
"external_userid": "yyyyy",
|
||||
"new_external_userid": "BBBB"
|
||||
}
|
||||
]
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"corpid": "xxxxx"
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok"
|
||||
}
|
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user