mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-19 07:44:46 +08:00
69 lines
3.5 KiB
C#
69 lines
3.5 KiB
C#
![]() |
using System;
|
|||
|
using System.Net.Http;
|
|||
|
using System.Threading;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Flurl.Http;
|
|||
|
|
|||
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||
|
{
|
|||
|
public static class WechatOpenAIClientExecuteOpenApiQueryExtensions
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// <para>异步调用 [POST] /openapi/sign/{TOKEN} 接口。</para>
|
|||
|
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/platform/INTERFACEDOCUMENT.html </para>
|
|||
|
/// </summary>
|
|||
|
/// <param name="client"></param>
|
|||
|
/// <param name="request"></param>
|
|||
|
/// <param name="cancellationToken"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static async Task<Models.OpenApiSignResponse> ExecuteOpenApiSignAsync(this WechatOpenAIClient client, Models.OpenApiSignRequest 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, "openapi", "sign", client.Credentials.PushToken!);
|
|||
|
|
|||
|
return await client.SendRequestWithJsonAsync<Models.OpenApiSignResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <para>异步调用 [POST] /openapi/aibot/{TOKEN} 接口。</para>
|
|||
|
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/platform/INTERFACEDOCUMENT.html </para>
|
|||
|
/// </summary>
|
|||
|
/// <param name="client"></param>
|
|||
|
/// <param name="request"></param>
|
|||
|
/// <param name="cancellationToken"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static async Task<Models.OpenApiAIBotResponse> ExecuteOpenApiAIBotAsync(this WechatOpenAIClient client, Models.OpenApiAIBotRequest 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, "openapi", "aibot", client.Credentials.PushToken!);
|
|||
|
|
|||
|
return await client.SendRequestWithJsonAsync<Models.OpenApiAIBotResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <para>异步调用 [POST] /openapi/gethotquerylist/{TOKEN} 接口。</para>
|
|||
|
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/platform/api/gethotquerylist.html </para>
|
|||
|
/// </summary>
|
|||
|
/// <param name="client"></param>
|
|||
|
/// <param name="request"></param>
|
|||
|
/// <param name="cancellationToken"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static async Task<Models.OpenApiGetHotQueryListResponse> ExecuteOpenApiGetHotQueryListAsync(this WechatOpenAIClient client, Models.OpenApiGetHotQueryListRequest 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, "openapi", "gethotquerylist", client.Credentials.PushToken!);
|
|||
|
|
|||
|
return await client.SendRequestWithJsonAsync<Models.OpenApiGetHotQueryListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|