mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 02:29:40 +08:00
feat(wxapi): 新增统一消息服务相关接口
This commit is contained in:
@@ -11,6 +11,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
|||||||
{
|
{
|
||||||
public static class WechatApiClientExecuteCgibinMessageWxopenExtensions
|
public static class WechatApiClientExecuteCgibinMessageWxopenExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>异步调用 [POST] /cgi-bin/message/wxopen/template/uniform_send 接口。</para>
|
||||||
|
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/uniform-message/uniformMessage.send.html </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<Models.CgibinMessageWxopenTemplateUniformSendResponse> ExecuteCgibinMessageWxopenTemplateUniformSendAsync(this WechatApiClient client, Models.CgibinMessageWxopenTemplateUniformSendRequest 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, "cgi-bin", "message", "wxopen", "template", "uniform_send")
|
||||||
|
.SetQueryParam("access_token", request.AccessToken);
|
||||||
|
|
||||||
|
return await client.SendRequestWithJsonAsync<Models.CgibinMessageWxopenTemplateUniformSendResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>异步调用 [POST] /cgi-bin/message/wxopen/activityid/create 接口。</para>
|
/// <para>异步调用 [POST] /cgi-bin/message/wxopen/activityid/create 接口。</para>
|
||||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/updatable-message/updatableMessage.createActivityId.html </para>
|
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/updatable-message/updatableMessage.createActivityId.html </para>
|
||||||
|
@@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /cgi-bin/message/wxopen/template/uniform_send 接口的请求。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinMessageWxopenTemplateUniformSendRequest : WechatApiRequest
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class MpTemplateMessage
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class MiniProgram : CgibinMessageTemplateSendRequest.Types.MiniProgram
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DataItem : CgibinMessageTemplateSendRequest.Types.DataItem
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置公众号 AppId。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("appid")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("appid")]
|
||||||
|
public string AppId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置模板 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("template_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("template_id")]
|
||||||
|
public string TemplateId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置点击消息跳转的链接。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("url")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||||
|
public string? Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置点击消息跳转的小程序信息。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("miniprogram")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("miniprogram")]
|
||||||
|
public Types.MiniProgram? MiniProgram { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置消息正文。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("data")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("data")]
|
||||||
|
public IDictionary<string, Types.DataItem>? Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置接收消息的用户 OpenId。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("touser")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("touser")]
|
||||||
|
public string ToUserOpenId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置公众号模板消息信息。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("mp_template_msg")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("mp_template_msg")]
|
||||||
|
public Types.MpTemplateMessage? MpTemplateMessage { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /cgi-bin/message/wxopen/template/uniform_send 接口的响应。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class CgibinMessageWxopenTemplateUniformSendResponse : WechatApiResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user