2021-10-08 11:36:35 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Flurl;
|
|
|
|
|
using Flurl.Http;
|
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|
|
|
|
{
|
2021-10-11 22:53:34 +08:00
|
|
|
|
public static class WechatOpenAIThirdPartyClientExecuteAsyncExtensions
|
2021-10-08 11:36:35 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>异步调用 [GET] /v1/async/fetch 接口。</para>
|
|
|
|
|
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/task_fetch.html </para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="client"></param>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-10-11 22:53:34 +08:00
|
|
|
|
public static async Task<Models.ThirdParty.AsyncFetchResponse> ExecuteAsyncFetchAsync(this WechatOpenAIThirdPartyClient client, Models.ThirdParty.AsyncFetchRequest request, CancellationToken cancellationToken = default)
|
2021-10-08 11:36:35 +08:00
|
|
|
|
{
|
|
|
|
|
if (client is null) throw new ArgumentNullException(nameof(client));
|
|
|
|
|
if (request is null) throw new ArgumentNullException(nameof(request));
|
|
|
|
|
|
|
|
|
|
IFlurlRequest flurlReq = client
|
|
|
|
|
.CreateRequest(request, HttpMethod.Get, "v1", "async", "fetch")
|
|
|
|
|
.SetQueryParam("task_id", request.TaskId);
|
|
|
|
|
|
2021-10-11 22:53:34 +08:00
|
|
|
|
return await client.SendRequestWithJsonAsync<Models.ThirdParty.AsyncFetchResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
2021-10-08 11:36:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|