mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 10:38:10 +08:00
feat(work): 新增接口调用许可应用管理相关接口
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 INFO.auto_activate 事件的数据。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95994 </para>
|
||||
/// </summary>
|
||||
public class LicenseAutoActivateEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Account
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置激活码。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("ActiveCode")]
|
||||
public string ActiveCode { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置类型。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("Type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置许可到期时间戳。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("ExpireTime")]
|
||||
public long ExpireTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置成员 UserId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("UserId")]
|
||||
public string UserId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置之前的许可状态。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("PreviousStatus", IsNullable = true)]
|
||||
public int? PreviousStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置之前的激活码。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("PreviousActiveCode", IsNullable = true)]
|
||||
public string? PreviousActiveCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置服务商 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("ServiceCorpId")]
|
||||
public string ServiceCorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置授权方的 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AuthCorpId", IsNullable = true)]
|
||||
public string? AuthorizerCorpId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置许可自动激活场景值。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("Scene")]
|
||||
public int Scene { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置激活的许可帐号列表。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AccountList", Type = typeof(Types.Account))]
|
||||
public Types.Account[] AccountList { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 INFO.license_pay_success 事件的数据。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95716 </para>
|
||||
/// </summary>
|
||||
public class LicensePaySuccessEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置服务商 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("ServiceCorpId")]
|
||||
public string ServiceCorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置授权方的 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AuthCorpId", IsNullable = true)]
|
||||
public string? AuthorizerCorpId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置订单号。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("OrderId")]
|
||||
public string OrderId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置服务商内下单用户 UserId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("BuyerUserId", IsNullable = true)]
|
||||
public string? BuyerUserId { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 INFO.license_refund 事件的数据。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95805 </para>
|
||||
/// </summary>
|
||||
public class LicenseRefundEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置服务商 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("ServiceCorpId")]
|
||||
public string ServiceCorpId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置授权方的 CorpId。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AuthCorpId", IsNullable = true)]
|
||||
public string? AuthorizerCorpId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置订单号。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("OrderId")]
|
||||
public string OrderId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置订单状态。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("OrderStatus")]
|
||||
public int OrderStatus { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 EVENT.unlicensed_notify 事件的数据。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95716 </para>
|
||||
/// </summary>
|
||||
public class UnlicensedNotifyEvent : WechatWorkEvent, WechatWorkEvent.Serialization.IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置应用 ID。
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlElement("AgentID")]
|
||||
public int AgentId { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
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 WechatWorkClientExecuteCgibinLicenseExtensions
|
||||
{
|
||||
#region App
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/license/get_app_license_info 接口。</para>
|
||||
/// <para>REF: https://developer.work.weixin.qq.com/document/path/95844 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinLicenseGetAppLicenseInfoResponse> ExecuteCgibinLicenseGetAppLicenseInfoAsync(this WechatWorkClient client, Models.CgibinLicenseGetAppLicenseInfoRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (client is null) throw new ArgumentNullException(nameof(client));
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
if (request.SuiteId == null)
|
||||
request.SuiteId = client.Credentials.SuiteId;
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "license", "get_app_license_info")
|
||||
.SetQueryParam("access_token", request.ProviderAccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinLicenseGetAppLicenseInfoResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/license/get_app_license_info 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinLicenseGetAppLicenseInfoRequest : 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;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置第三方应用 SuiteId。如果不指定将使用构造 <see cref="WechatWorkClient"/> 时的 <see cref="WechatWorkClientOptions.SuiteId"/> 参数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("suite_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("suite_id")]
|
||||
public string? SuiteId { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/license/get_app_license_info 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinLicenseGetAppLicenseInfoResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class TrailInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置试用开始时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("start_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("start_time")]
|
||||
public long StartTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置试用到期时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("end_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("end_time")]
|
||||
public long EndTimestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置接口许可状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("license_status")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("license_status")]
|
||||
public int LicenseStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置试用期信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("trail_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("trail_info")]
|
||||
public Types.TrailInfo? TrailInfo { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user