feat(wxapi): 新增使用 AppSecret 重置 API 调用次数接口

This commit is contained in:
Fu Diwei
2024-08-07 21:45:25 +08:00
parent 0e8f123907
commit 7de3ee50c9
3 changed files with 61 additions and 0 deletions

View File

@@ -37,6 +37,36 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
return await client.SendFlurlRequestAsJsonAsync<Models.CgibinClearQuotaResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/clear_quota/v2 接口。</para>
/// <para>
/// REF: <br/>
/// <![CDATA[ https://developers.weixin.qq.com/doc/offiaccount/openApi/clearQuotaByAppSecret.html ]]>
/// </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinClearQuotaV2Response> ExecuteCgibinClearQuotaV2Async(this WechatApiClient client, Models.CgibinClearQuotaV2Request request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.AppId is null)
request.AppId = client.Credentials.AppId;
if (request.AppSecret is null)
request.AppSecret = client.Credentials.AppSecret;
IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "cgi-bin", "clear_quota")
.SetQueryParam("appid", request.AppId)
.SetQueryParam("appsecret", request.AppSecret);
return await client.SendFlurlRequestAsJsonAsync<Models.CgibinClearQuotaV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/openapi/quota/get 接口。</para>
/// <para>

View File

@@ -0,0 +1,22 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/clear_quota/v2 接口的请求。</para>
/// </summary>
public class CgibinClearQuotaV2Request : WechatApiRequest, IInferable<CgibinClearQuotaV2Request, CgibinClearQuotaV2Response>
{
/// <summary>
/// 获取或设置微信 AppId。如果不指定将使用构造 <see cref="WechatApiClient"/> 时的 <see cref="WechatApiClientOptions.AppId"/> 参数。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string? AppId { get; set; }
/// <summary>
/// 获取或设置微信 AppSecret。如果不指定将使用构造 <see cref="WechatApiClient"/> 时的 <see cref="WechatApiClientOptions.AppSecret"/> 参数。
/// </summary>
[Newtonsoft.Json.JsonProperty("appsecret")]
[System.Text.Json.Serialization.JsonPropertyName("appsecret")]
public string? AppSecret { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /cgi-bin/clear_quota/v2 接口的响应。</para>
/// </summary>
public class CgibinClearQuotaV2Response : WechatApiResponse
{
}
}