mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
feat(wxapi): 新增小程序硬件设备激活相关接口
This commit is contained in:
parent
a3d2404149
commit
f778449d1b
@ -322,6 +322,68 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region License
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/license/activedevice 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/activeLicenseDevice.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaBusinessLicenseActiveDeviceResponse> ExecuteWxaBusinessLicenseActiveDeviceAsync(this WechatApiClient client, Models.WxaBusinessLicenseActiveDeviceRequest 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, "wxa", "business", "license", "activedevice")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessLicenseActiveDeviceResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/license/getdeviceinfo 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/getLicenseDeviceInfo.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaBusinessLicenseGetDeviceInfoResponse> ExecuteWxaBusinessLicenseGetDeviceInfoAsync(this WechatApiClient client, Models.WxaBusinessLicenseGetDeviceInfoRequest 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, "wxa", "business", "license", "getdeviceinfo")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessLicenseGetDeviceInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/license/getpkglist 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/hardware-device/getLicensePkgList.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaBusinessLicenseGetPackageListResponse> ExecuteWxaBusinessLicenseGetPackageListAsync(this WechatApiClient client, Models.WxaBusinessLicenseGetPackageListRequest 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, "wxa", "business", "license", "getpkglist")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaBusinessLicenseGetPackageListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LiveBroadcast
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/business/applyliveinfo 接口。</para>
|
||||
|
@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/activedevice 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseActiveDeviceRequest : WechatApiRequest, IInferable<WxaBusinessLicenseActiveDeviceRequest, WxaBusinessLicenseActiveDeviceResponse>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置设备型号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("model_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("model_id")]
|
||||
public string ModelId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备序列号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sn")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("sn")]
|
||||
public string SerialNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置激活码序号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("active_number")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("active_number")]
|
||||
public int ActiveNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("device_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("device_list")]
|
||||
public IList<Types.Device> DeviceList { get; set; } = new List<Types.Device>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源包类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_type")]
|
||||
public int PackageType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/activedevice 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseActiveDeviceResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置设备型号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("model_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("model_id")]
|
||||
public string ModelId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备序列号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sn")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("sn")]
|
||||
public string SerialNumber { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备过期时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expire_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expire_time")]
|
||||
public long? ExpireTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置错误码。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("errcode")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("errcode")]
|
||||
public int ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("device_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("device_list")]
|
||||
public Types.Result[] ResultList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/getdeviceinfo 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseGetDeviceInfoRequest : WechatApiRequest, IInferable<WxaBusinessLicenseGetDeviceInfoRequest, WxaBusinessLicenseGetDeviceInfoResponse>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置设备型号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("model_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("model_id")]
|
||||
public string ModelId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备序列号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sn")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("sn")]
|
||||
public string SerialNumber { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("device_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("device_list")]
|
||||
public IList<Types.Device> DeviceList { get; set; } = new List<Types.Device>();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/getdeviceinfo 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseGetDeviceInfoResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置设备型号 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("model_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("model_id")]
|
||||
public string ModelId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备序列号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sn")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("sn")]
|
||||
public string SerialNumber { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备过期时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expire_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expire_time")]
|
||||
public long? ExpireTimestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置设备列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("device_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("device_list")]
|
||||
public Types.Device[] DeviceList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/getpkglist 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseGetPackageListRequest : WechatApiRequest, IInferable<WxaBusinessLicenseGetPackageListRequest, WxaBusinessLicenseGetPackageListResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置资源包类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_type")]
|
||||
public int PackageType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/business/license/getpkglist 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaBusinessLicenseGetPackageListResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Package
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置资源包 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_id")]
|
||||
public string PackageId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源包类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_type")]
|
||||
public int PackageType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源包状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_status")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_status")]
|
||||
public int PackageStatus { get; set; }
|
||||
|
||||
/// <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("used")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("used")]
|
||||
public int UsedQuota { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源包总量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("all")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("all")]
|
||||
public int TotalQuota { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置资源包列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("pkg_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("pkg_list")]
|
||||
public Types.Package[] PackageList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置最大激活码序号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("max_active_number")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("max_active_number")]
|
||||
public int? MaxActiveNumber { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"pkg_type": 0,
|
||||
"device_list": [
|
||||
{
|
||||
"model_id": "MODEL_ID1",
|
||||
"sn": "SN1",
|
||||
"active_number": 1
|
||||
},
|
||||
{
|
||||
"model_id": "MODEL_ID2",
|
||||
"sn": "SN2",
|
||||
"active_number": 2
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"device_list": [
|
||||
{
|
||||
"model_id": "MODEL_ID1",
|
||||
"sn": "SN1",
|
||||
"errcode": 0
|
||||
},
|
||||
{
|
||||
"model_id": "MODEL_ID2",
|
||||
"sn": "SN2",
|
||||
"errcode": 0
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"device_list": [
|
||||
{
|
||||
"model_id": "MODEL_ID1",
|
||||
"sn": "SN1"
|
||||
},
|
||||
{
|
||||
"model_id": "MODEL_ID2",
|
||||
"sn": "SN2"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"device_list": [
|
||||
{
|
||||
"model_id": "MODEL_ID1",
|
||||
"sn": "SN1",
|
||||
"expire_time": 1630425600
|
||||
},
|
||||
{
|
||||
"model_id": "MODEL_ID2",
|
||||
"sn": "SN2",
|
||||
"expire_time": 1630425600
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"pkg_type": 0
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "success",
|
||||
"pkg_list": [
|
||||
{
|
||||
"pkg_id": "ZY100000000",
|
||||
"pkg_type": 1,
|
||||
"start_time": 1629907200,
|
||||
"end_time": 1630425600,
|
||||
"pkg_status": 1,
|
||||
"used": 10,
|
||||
"all": 100
|
||||
},
|
||||
{
|
||||
"pkg_id": "ZY100000001",
|
||||
"pkg_type": 2,
|
||||
"start_time": 1629907200,
|
||||
"end_time": 1630425600,
|
||||
"pkg_status": 1,
|
||||
"used": 20,
|
||||
"all": 200
|
||||
}
|
||||
],
|
||||
"max_active_number": 300
|
||||
}
|
Loading…
Reference in New Issue
Block a user