feat(wxapi): 新增使用 AppSecret 重置第三方平台 API 调用次数接口

This commit is contained in:
Fu Diwei
2022-10-26 17:08:51 +08:00
parent 38956334f7
commit 1a9c782bfa
3 changed files with 64 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -388,5 +388,30 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
using var httpContent = Utilities.FileHttpContentBuilder.Build(fileName: request.FileName, fileBytes: request.FileBytes, fileContentType: request.FileContentType, formDataName: "file");
return await client.SendRequestAsync<Models.CgibinComponentUploadPrivacyExtraFileResponse>(flurlReq, httpContent: httpContent, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /cgi-bin/component/clear_quota/v2 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/openapi/clearComponentQuotaByAppSecret.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.CgibinComponentClearQuotaV2Response> ExecuteCgibinComponentClearQuotaV2Async(this WechatApiClient client, Models.CgibinComponentClearQuotaV2Request request, CancellationToken cancellationToken = default)
{
if (client is null) throw new ArgumentNullException(nameof(client));
if (request is null) throw new ArgumentNullException(nameof(request));
if (request.ComponentAppId == null)
request.ComponentAppId = client.Credentials.AppId;
if (request.ComponentAppSecret == null)
request.ComponentAppSecret = client.Credentials.AppSecret;
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Post, "cgi-bin", "component", "clear_quota", "v2");
return await client.SendRequestWithJsonAsync<Models.CgibinComponentClearQuotaV2Response>(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}

View File

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

View File

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