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
4f75482624
commit
a3d2404149
@ -1,4 +1,4 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Events
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 EVENT.wxa_media_check 事件的数据。</para>
|
||||
@ -90,7 +90,7 @@
|
||||
[Newtonsoft.Json.JsonProperty("extra_info_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("extra_info_json")]
|
||||
[System.Xml.Serialization.XmlElement("extra_info_json", IsNullable = true)]
|
||||
public string? JsonExtra { get; set; }
|
||||
public string? ExtraJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置小程序 AppId。
|
||||
|
@ -1005,6 +1005,68 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UserNotify
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/set_user_notify 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/setUserNotify.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaSetUserNotifyResponse> ExecuteWxaSetUserNotifyAsync(this WechatApiClient client, Models.WxaSetUserNotifyRequest 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", "set_user_notify")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaSetUserNotifyResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/get_user_notify 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/getUserNotify.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaGetUserNotifyResponse> ExecuteWxaGetUserNotifyAsync(this WechatApiClient client, Models.WxaGetUserNotifyRequest 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", "get_user_notify")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaGetUserNotifyResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/set_user_notifyext 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/setUserNotifyExt.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.WxaSetUserNotifyExtraResponse> ExecuteWxaSetUserNotifyExtraAsync(this WechatApiClient client, Models.WxaSetUserNotifyExtraRequest 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", "set_user_notifyext")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.WxaSetUserNotifyExtraResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WxaCode
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /wxa/getwxacode 接口。</para>
|
||||
|
@ -0,0 +1,29 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/get_user_notify 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaGetUserNotifyRequest : WechatApiRequest, IInferable<WxaGetUserNotifyRequest, WxaGetUserNotifyResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户的 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置卡片类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_type")]
|
||||
public int NotifyType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置动态更新令牌。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_code")]
|
||||
public string NotifyCode { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/get_user_notify 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaGetUserNotifyResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class NotifyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置卡片类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_type")]
|
||||
public int NotifyType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置通知状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("code_state")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("code_state")]
|
||||
public int CodeState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置通知过期时间戳。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("code_expire_time")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("code_expire_time")]
|
||||
public long CodeExpireTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置卡片状态与状态相关字段 JSON 数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("content_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("content_json")]
|
||||
public string? ContentJson { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置服务卡片信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_info")]
|
||||
public Types.NotifyInfo NotifyInfo { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/set_user_notifyext 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaSetUserNotifyExtraRequest : WechatApiRequest, IInferable<WxaSetUserNotifyExtraRequest, WxaSetUserNotifyExtraResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户的 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置通知类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_type")]
|
||||
public int NotifyType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置动态更新令牌。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_code")]
|
||||
public string NotifyCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置扩展信息 JSON 数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("ext_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("ext_json")]
|
||||
public string? ExtraJson { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/set_user_notifyext 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaSetUserNotifyExtraResponse : WechatApiResponse
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/set_user_notify 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class WxaSetUserNotifyRequest : WechatApiRequest, IInferable<WxaSetUserNotifyRequest, WxaSetUserNotifyResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户的 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置通知类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_type")]
|
||||
public int NotifyType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置动态更新令牌。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("notify_code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("notify_code")]
|
||||
public string NotifyCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置卡片状态与状态相关字段 JSON 数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("content_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("content_json")]
|
||||
public string? ContentJson { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置微信支付订单号验证字段 JSON 数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("check_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("check_json")]
|
||||
public string? CheckJson { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/set_user_notify 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class WxaSetUserNotifyResponse : WechatApiResponse
|
||||
{
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /wxa/commit 接口的请求。</para>
|
||||
@ -17,7 +17,7 @@
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("ext_json")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("ext_json")]
|
||||
public string JsonExtra { get; set; } = "{}";
|
||||
public string ExtraJson { get; set; } = "{}";
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户自定义版本号。
|
||||
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"openid": "xxx",
|
||||
"notify_type": 1001,
|
||||
"notify_code": "xxx"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"notify_info": {
|
||||
"notify_type": 1001,
|
||||
"content_json": "{\"cur_status\":2,\"license_plate\":\"粤A·12345A\",\"arrival_time\":1679569348,\"wxa_path_query\":\"\"}",
|
||||
"code_state": 1,
|
||||
"code_expire_time": 1681906267
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"notify_type": 1003,
|
||||
"openid": "xxx",
|
||||
"notify_code": "xxx",
|
||||
"ext_json": "{\"pay_info\":\"{\\\"transaction_id\\\":\\\"4200001855202305090060871147\\\",\\\"pay_amount\\\":2001,\\\"pay_time\\\":1683546394}\",\"store_info\":\"{\\\"store_name\\\":\\\"westore\\\",\\\"store_address\\\":\\\"深圳市南山区南山大道18号\\\",\\\"latitude\\\":22,\\\"longitude\\\":114}\"}"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"notify_type": 1001,
|
||||
"openid": "xxx",
|
||||
"notify_code": "xxx",
|
||||
"check_json": "{\"pay_amount\":1005,\"pay_time\": 1683525070}",
|
||||
"content_json": "{\"cur_status\":2,\"license_plate\":\"粤A12345A\",\"arrival_time\":1679569348,\"wxa_path_query\":\"\"}"
|
||||
}
|
Loading…
Reference in New Issue
Block a user