mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-22 03:19:55 +08:00
feat(openai): 新增注册用户相关接口
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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.OpenAI
|
||||
{
|
||||
public static class WechatOpenAIClientExecuteUserExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v1/user/register 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/user_register.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.UserRegisterResponse> ExecuteUserRegisterAsync(this WechatOpenAIClient client, Models.UserRegisterRequest 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, "v1", "user", "register")
|
||||
.WithHeader("Client-Id", client.Credentials.ClientId)
|
||||
.WithHeader("Client-Key", client.Credentials.ClientKey);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.UserRegisterResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user