diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/WxaSecurity/WxaMediaCheckEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/WxaSecurity/WxaMediaCheckEvent.cs index 00d6216e..9a655c4c 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/WxaSecurity/WxaMediaCheckEvent.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/WxaSecurity/WxaMediaCheckEvent.cs @@ -1,4 +1,4 @@ -namespace SKIT.FlurlHttpClient.Wechat.Api.Events +namespace SKIT.FlurlHttpClient.Wechat.Api.Events { /// /// 表示 EVENT.wxa_media_check 事件的数据。 @@ -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; } /// /// 获取或设置小程序 AppId。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs index a88ee3a3..b16e2cd0 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteWxaExtensions.cs @@ -1005,6 +1005,68 @@ namespace SKIT.FlurlHttpClient.Wechat.Api } #endregion + #region UserNotify + /// + /// 异步调用 [POST] /wxa/set_user_notify 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/setUserNotify.html + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /wxa/get_user_notify 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/getUserNotify.html + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /wxa/set_user_notifyext 接口。 + /// REF: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/setUserNotifyExt.html + /// + /// + /// + /// + /// + public static async Task 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(flurlReq, data: request, cancellationToken: cancellationToken); + } + #endregion + #region WxaCode /// /// 异步调用 [POST] /wxa/getwxacode 接口。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyRequest.cs new file mode 100644 index 00000000..80bef478 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyRequest.cs @@ -0,0 +1,29 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/get_user_notify 接口的请求。 + /// + public class WxaGetUserNotifyRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置用户的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("openid")] + [System.Text.Json.Serialization.JsonPropertyName("openid")] + public string OpenId { get; set; } = string.Empty; + + /// + /// 获取或设置卡片类型。 + /// + [Newtonsoft.Json.JsonProperty("notify_type")] + [System.Text.Json.Serialization.JsonPropertyName("notify_type")] + public int NotifyType { get; set; } + + /// + /// 获取或设置动态更新令牌。 + /// + [Newtonsoft.Json.JsonProperty("notify_code")] + [System.Text.Json.Serialization.JsonPropertyName("notify_code")] + public string NotifyCode { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyResponse.cs new file mode 100644 index 00000000..05e666e5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaGetUserNotifyResponse.cs @@ -0,0 +1,49 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/get_user_notify 接口的响应。 + /// + public class WxaGetUserNotifyResponse : WechatApiResponse + { + public static class Types + { + public class NotifyInfo + { + /// + /// 获取或设置卡片类型。 + /// + [Newtonsoft.Json.JsonProperty("notify_type")] + [System.Text.Json.Serialization.JsonPropertyName("notify_type")] + public int NotifyType { get; set; } + + /// + /// 获取或设置通知状态。 + /// + [Newtonsoft.Json.JsonProperty("code_state")] + [System.Text.Json.Serialization.JsonPropertyName("code_state")] + public int CodeState { get; set; } + + /// + /// 获取或设置通知过期时间戳。 + /// + [Newtonsoft.Json.JsonProperty("code_expire_time")] + [System.Text.Json.Serialization.JsonPropertyName("code_expire_time")] + public long CodeExpireTimestamp { get; set; } + + /// + /// 获取或设置卡片状态与状态相关字段 JSON 数据。 + /// + [Newtonsoft.Json.JsonProperty("content_json")] + [System.Text.Json.Serialization.JsonPropertyName("content_json")] + public string? ContentJson { get; set; } + } + } + + /// + /// 获取或设置服务卡片信息。 + /// + [Newtonsoft.Json.JsonProperty("notify_info")] + [System.Text.Json.Serialization.JsonPropertyName("notify_info")] + public Types.NotifyInfo NotifyInfo { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.cs new file mode 100644 index 00000000..26395204 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.cs @@ -0,0 +1,36 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/set_user_notifyext 接口的请求。 + /// + public class WxaSetUserNotifyExtraRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置用户的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("openid")] + [System.Text.Json.Serialization.JsonPropertyName("openid")] + public string OpenId { get; set; } = string.Empty; + + /// + /// 获取或设置通知类型。 + /// + [Newtonsoft.Json.JsonProperty("notify_type")] + [System.Text.Json.Serialization.JsonPropertyName("notify_type")] + public int NotifyType { get; set; } + + /// + /// 获取或设置动态更新令牌。 + /// + [Newtonsoft.Json.JsonProperty("notify_code")] + [System.Text.Json.Serialization.JsonPropertyName("notify_code")] + public string NotifyCode { get; set; } = string.Empty; + + /// + /// 获取或设置扩展信息 JSON 数据。 + /// + [Newtonsoft.Json.JsonProperty("ext_json")] + [System.Text.Json.Serialization.JsonPropertyName("ext_json")] + public string? ExtraJson { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraResponse.cs new file mode 100644 index 00000000..a4c535fd --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyExtraResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/set_user_notifyext 接口的响应。 + /// + public class WxaSetUserNotifyExtraResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyRequest.cs new file mode 100644 index 00000000..123549f6 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyRequest.cs @@ -0,0 +1,43 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/set_user_notify 接口的请求。 + /// + public class WxaSetUserNotifyRequest : WechatApiRequest, IInferable + { + /// + /// 获取或设置用户的 OpenId。 + /// + [Newtonsoft.Json.JsonProperty("openid")] + [System.Text.Json.Serialization.JsonPropertyName("openid")] + public string OpenId { get; set; } = string.Empty; + + /// + /// 获取或设置通知类型。 + /// + [Newtonsoft.Json.JsonProperty("notify_type")] + [System.Text.Json.Serialization.JsonPropertyName("notify_type")] + public int NotifyType { get; set; } + + /// + /// 获取或设置动态更新令牌。 + /// + [Newtonsoft.Json.JsonProperty("notify_code")] + [System.Text.Json.Serialization.JsonPropertyName("notify_code")] + public string NotifyCode { get; set; } = string.Empty; + + /// + /// 获取或设置卡片状态与状态相关字段 JSON 数据。 + /// + [Newtonsoft.Json.JsonProperty("content_json")] + [System.Text.Json.Serialization.JsonPropertyName("content_json")] + public string? ContentJson { get; set; } + + /// + /// 获取或设置微信支付订单号验证字段 JSON 数据。 + /// + [Newtonsoft.Json.JsonProperty("check_json")] + [System.Text.Json.Serialization.JsonPropertyName("check_json")] + public string? CheckJson { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyResponse.cs new file mode 100644 index 00000000..820c33b0 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/Wxa/UserNotify/WxaSetUserNotifyResponse.cs @@ -0,0 +1,9 @@ +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /wxa/set_user_notify 接口的响应。 + /// + public class WxaSetUserNotifyResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaCommitRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaCommitRequest.cs index eeb0bc02..54f49a44 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaCommitRequest.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/WxaComponent/Code/WxaCommitRequest.cs @@ -1,4 +1,4 @@ -namespace SKIT.FlurlHttpClient.Wechat.Api.Models +namespace SKIT.FlurlHttpClient.Wechat.Api.Models { /// /// 表示 [POST] /wxa/commit 接口的请求。 @@ -17,7 +17,7 @@ /// [Newtonsoft.Json.JsonProperty("ext_json")] [System.Text.Json.Serialization.JsonPropertyName("ext_json")] - public string JsonExtra { get; set; } = "{}"; + public string ExtraJson { get; set; } = "{}"; /// /// 获取或设置用户自定义版本号。 diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyRequest.json new file mode 100644 index 00000000..3b91f61e --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyRequest.json @@ -0,0 +1,5 @@ +{ + "openid": "xxx", + "notify_type": 1001, + "notify_code": "xxx" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyResponse.json new file mode 100644 index 00000000..0aea10bf --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaGetUserNotifyResponse.json @@ -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 + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.json new file mode 100644 index 00000000..3a7cdbe8 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyExtraRequest.json @@ -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}\"}" +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyRequest.json new file mode 100644 index 00000000..6dafeaac --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/Wxa/UserNotify/WxaSetUserNotifyRequest.json @@ -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\":\"\"}" +}