mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
feat(openai): 新增对话开放相关接口
This commit is contained in:
parent
667f5f2618
commit
03d49a0012
@ -0,0 +1,71 @@
|
||||
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 WechatOpenAIClientExecuteOpenApiExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v1/openapi/create 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/openapi/create.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.OpenApiCreateResponse> ExecuteOpenApiCreateAsync(this WechatOpenAIClient client, Models.OpenApiCreateRequest 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", "openapi", "create");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.OpenApiCreateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v1/openapi/reset 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/openapi/reset.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.OpenApiResetResponse> ExecuteOpenApiResetAsync(this WechatOpenAIClient client, Models.OpenApiResetRequest 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", "openapi", "reset");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.OpenApiResetResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /v1/openapi/get_detail 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/openapi/get_detail.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.OpenApiGetDetailResponse> ExecuteOpenApiGetDetailAsync(this WechatOpenAIClient client, Models.OpenApiGetDetailRequest 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.Get, "v1", "openapi", "get_detail");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.OpenApiGetDetailResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v1/openapi/create 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class OpenApiCreateRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置联系人名字。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置联系电话。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("phone")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("phone")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置微信号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("wechat")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("wechat")]
|
||||
public string Wechat { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置邮箱。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("email")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("email")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置地址。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("address")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("address")]
|
||||
public string? Address { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v1/openapi/create 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class OpenApiCreateResponse : WechatOpenAIResponse<OpenApiCreateResponse.Types.Data>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 AppId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("appid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("appid")]
|
||||
public string AppId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 Token。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("token")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("token")]
|
||||
public string Token { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 EncodingAESKey。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("aes_key")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("aes_key")]
|
||||
public string EncodingAESKey { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /v1/openapi/get_detail 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class OpenApiGetDetailRequest : WechatOpenAIRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /v1/openapi/get_detail 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class OpenApiGetDetailResponse : WechatOpenAIResponse<OpenApiGetDetailResponse.Types.Data>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data : OpenApiCreateResponse.Types.Data
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v1/openapi/reset 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class OpenApiResetRequest : WechatOpenAIRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v1/openapi/reset 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class OpenApiResetResponse : WechatOpenAIResponse<OpenApiResetResponse.Types.Data>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data : OpenApiCreateResponse.Types.Data
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("id")]
|
||||
public long SkillId { get; set; } = default!;
|
||||
public long SkillId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "张三",
|
||||
"phone": "18833008888",
|
||||
"wechat": "aaaa",
|
||||
"email": "123@qq.com",
|
||||
"address": "北京市海淀区中国技术交易大厦F7"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "请求成功",
|
||||
"request_id": "255i0ug8-l9q4-3801-44ft-w7csjn9e5142",
|
||||
"data": {
|
||||
"appid": "5i2YaWnq56844yh",
|
||||
"token": "d9tvK4Z3jHp0SW3758x89550oj789k",
|
||||
"aes_key": "lKq5xB3W675330C6ftaLm3n3gb450Iz4ee880K2Hz16"
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "请求成功",
|
||||
"request_id": "255i0ug8-l9q4-3801-44ft-w7csjn9e5142",
|
||||
"data": {
|
||||
"appid": "5i2YaWnq56844yh",
|
||||
"token": "d9tvK4Z3jHp0SW3758x89550oj789k",
|
||||
"aes_key": "lKq5xB3W675330C6ftaLm3n3gb450Iz4ee880K2Hz16"
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "请求成功",
|
||||
"request_id": "255i0ug8-l9q4-3801-44ft-w7csjn9e5142",
|
||||
"data": {
|
||||
"appid": "5i2YaWnq56844yh",
|
||||
"token": "d9tvK4Z3jHp0SW3758x89550oj789k",
|
||||
"aes_key": "lKq5xB3W675330C6ftaLm3n3gb450Iz4ee880K2Hz16"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user