mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
feat(wxapi): 新增微信红包封面相关接口
This commit is contained in:
parent
f2a097d8a4
commit
12034895a6
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
{
|
||||
public static class WechatApiClientExecuteRedPacketCoverExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /redpacketcover/wxapp/cover_url/get_by_token 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/redpacketcover/redpacketcover.getAuthenticationUrl.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.RedPacketCoverWxAppCoverUrlGetByTokenResponse> ExecuteRedPacketCoverWxAppCoverUrlGetByTokenAsync(this WechatApiClient client, Models.RedPacketCoverWxAppCoverUrlGetByTokenRequest 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, "redpacketcover", "wxapp", "cover_url", "get_by_token")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.RedPacketCoverWxAppCoverUrlGetByTokenResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /redpacketcover/wxapp/cover_url/get_by_token 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class RedPacketCoverWxAppCoverUrlGetByTokenRequest : WechatApiRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置可领取用户的 OpenId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置红包封面平台的发放 CToken。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("ctoken")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("ctoken")]
|
||||
public string CToken { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /redpacketcover/wxapp/cover_url/get_by_token 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class RedPacketCoverWxAppCoverUrlGetByTokenResponse : WechatApiResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户领取的链接。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置返回数据。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("data")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("data")]
|
||||
public Types.Data Data { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"openid": "xxxxxxxxxxmTo5lAUQxxxxxxxxxx",
|
||||
"ctoken": "xxxxxqpHPu1xxxxx"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"data": {
|
||||
"url": "<https://xxx.xxx.xxx.xxx/xxx>"
|
||||
},
|
||||
"errcode": 0,
|
||||
"errmsg": "success"
|
||||
}
|
Loading…
Reference in New Issue
Block a user