mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
feat(work): 新增接口调用许可应用管理相关接口
This commit is contained in:
parent
d6153646be
commit
8dc22d11b7
@ -97,8 +97,10 @@
|
||||
| √ | 政民沟通:巡查上报 | 企业 | |
|
||||
| √ | 政民沟通:居民上报 | 企业 | |
|
||||
| √ | 政民沟通:防疫场所码 | 企业 | |
|
||||
| √ | 接口调用许可 | 服务商 | |
|
||||
| √ | 应用授权 | 服务商 & 硬件接入 | |
|
||||
| √ | 推广二维码 | 服务商 & 硬件接入 | |
|
||||
| √ | 自建应用代开发 | 服务商 | |
|
||||
| √ | 设备管理 | 硬件接入 | |
|
||||
|
||||
</details>
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<xml>
|
||||
<ServiceCorpId><![CDATA[aaaa]]></ServiceCorpId>
|
||||
<InfoType><![CDATA[auto_activate]]></InfoType>
|
||||
<AuthCorpId><![CDATA[bbbb]]></AuthCorpId>
|
||||
<Scene>1</Scene>
|
||||
<TimeStamp>1403610513</TimeStamp>
|
||||
<AccountList>
|
||||
<ActiveCode><![CDATA[XXXX]]></ActiveCode>
|
||||
<Type>1</Type>
|
||||
<ExpireTime>1700000000</ExpireTime>
|
||||
<UserId><![CDATA[USERID]]></UserId>
|
||||
<PreviousStatus>1</PreviousStatus>
|
||||
<PreviousActiveCode><![CDATA[YYYY]]></PreviousActiveCode>
|
||||
</AccountList>
|
||||
</xml>
|
@ -0,0 +1,8 @@
|
||||
<xml>
|
||||
<ServiceCorpId><![CDATA[xxxx]]></ServiceCorpId>
|
||||
<InfoType><![CDATA[license_pay_success]]></InfoType>
|
||||
<AuthCorpId><![CDATA[yyyy]]></AuthCorpId>
|
||||
<OrderId><![CDATA[zzzz]]></OrderId>
|
||||
<BuyerUserId><![CDATA[USERID]]></BuyerUserId>
|
||||
<TimeStamp>1403610513</TimeStamp>
|
||||
</xml>
|
@ -0,0 +1,8 @@
|
||||
<xml>
|
||||
<ServiceCorpId><![CDATA[xxxx]]></ServiceCorpId>
|
||||
<InfoType><![CDATA[license_refund]]></InfoType>
|
||||
<AuthCorpId><![CDATA[yyyy]]></AuthCorpId>
|
||||
<OrderId><![CDATA[zzzz]]></OrderId>
|
||||
<OrderStatus>1</OrderStatus>
|
||||
<TimeStamp>1403610513</TimeStamp>
|
||||
</xml>
|
@ -0,0 +1,8 @@
|
||||
<xml>
|
||||
<ToUserName><![CDATA[toUser]]></ToUserName>
|
||||
<FromUserName><![CDATA[FromUser]]></FromUserName>
|
||||
<CreateTime>1408091189</CreateTime>
|
||||
<MsgType><![CDATA[event]]></MsgType>
|
||||
<Event><![CDATA[unlicensed_notify]]></Event>
|
||||
<AgentID>1</AgentID>
|
||||
</xml>
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"corpid": "xxxx",
|
||||
"suite_id": "xxxx"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"license_status": 1,
|
||||
"trail_info": {
|
||||
"start_time": 1651752000,
|
||||
"end_time": 1659700800
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user