mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat(openai): 新增技能商店相关接口
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
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 WechatOpenAIClientExecuteSkillStoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/skill_store/get_list 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/skill_store/get_store_skill_list.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.SkillStoreGetListResponse> ExecuteSkillStoreGetListAsync(this WechatOpenAIClient client, Models.SkillStoreGetListRequest 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, "v2", "skill_store", "get_list");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.SkillStoreGetListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/skill_store/bot_acquire_state/update 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/skill_store/update_bot_acquire_state.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.SkillStoreBotAcquireStateUpdateResponse> ExecuteSkillStoreBotAcquireStateUpdateAsync(this WechatOpenAIClient client, Models.SkillStoreBotAcquireStateUpdateRequest 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, "v2", "skill_store", "bot_acquire_state", "update");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.SkillStoreBotAcquireStateUpdateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/skill_store/bot_switch_state/update 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/skill_store/batch_update_state.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.SkillStoreBotSwitchStateUpdateResponse> ExecuteSkillStoreBotSwitchStateUpdateAsync(this WechatOpenAIClient client, Models.SkillStoreBotSwitchStateUpdateRequest 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, "v2", "skill_store", "bot_switch_state", "update");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.SkillStoreBotSwitchStateUpdateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/skill_store/builtin_skill_switch/update 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/skill_store/update_builtin_skill_switch.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.SkillStoreBuiltinSkillSwitchUpdateResponse> ExecuteSkillStoreBuiltinSkillSwitchUpdateAsync(this WechatOpenAIClient client, Models.SkillStoreBuiltinSkillSwitchUpdateRequest 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, "v2", "skill_store", "builtin_skill_switch", "update");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.SkillStoreBuiltinSkillSwitchUpdateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/bot_acquire_state/update 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBotAcquireStateUpdateRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置技能 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skill_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skill_id")]
|
||||
public string SkillId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/bot_acquire_state/update 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBotAcquireStateUpdateResponse : WechatOpenAIResponse
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/bot_switch_state/update 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBotSwitchStateUpdateRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置技能 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skill_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skill_id")]
|
||||
public string SkillId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置要开启技能开关的机器人 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("on_bot_id_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("on_bot_id_list")]
|
||||
public IList<string> OnBotIdList { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置要关闭技能开关的机器人 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("off_bot_id_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("off_bot_id_list")]
|
||||
public IList<string> OffBotIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/bot_switch_state/update 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBotSwitchStateUpdateResponse : WechatOpenAIResponse
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/builtin_skill_switch/update 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBuiltinSkillSwitchUpdateRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置技能名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skill_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skill_name")]
|
||||
public string SkillName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置要开启技能开关的机器人 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("on_bot_id_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("on_bot_id_list")]
|
||||
public IList<string> OnBotIdList { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置要关闭技能开关的机器人 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("off_bot_id_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("off_bot_id_list")]
|
||||
public IList<string> OffBotIdList { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/builtin_skill_switch/update 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreBuiltinSkillSwitchUpdateResponse : WechatOpenAIResponse
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/get_list 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreGetListRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置关键字。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("keyword")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("keyword")]
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能类别。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("category")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("category")]
|
||||
public string? Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分类字段。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("order")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页页数。
|
||||
/// <para>默认值:1</para>
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("page")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("page")]
|
||||
public int Page { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分页每页数量。
|
||||
/// <para>默认值:10</para>
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("size")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("size")]
|
||||
public int Limit { get; set; } = 10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/skill_store/get_list 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SkillStoreGetListResponse : WechatOpenAIResponse<SkillStoreGetListResponse.Types.Data>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Skill
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Bot
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置机器人总数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("count")]
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置开启的机器人数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("on_num")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("on_num")]
|
||||
public int OnCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skill_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skill_id")]
|
||||
public string SkillId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("skill_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("skill_name")]
|
||||
public string SkillName { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置机器人名称。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("bot_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("bot_name")]
|
||||
public string BotName { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否已获取。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("acquired")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("acquired")]
|
||||
public bool IsAcquired { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置获取时间。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("acquired_time")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RegularNullableDateTimeOffsetConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("acquired_time")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RegularNullableDateTimeOffsetConverter))]
|
||||
public DateTimeOffset? AcquireTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置机器人信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("bot_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("bot_info")]
|
||||
public Types.Bot Bot { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置分类。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("category")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("category")]
|
||||
public string Category { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置描述。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("desc")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("desc")]
|
||||
public string Description { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置热度。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("hot")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("hot")]
|
||||
public int Hot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置话术举例列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("statement_case_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("statement_case_list")]
|
||||
public string[] StatementCaseList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("state")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("state")]
|
||||
public int State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能开关。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("switch")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("switch")]
|
||||
public bool Switch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置修改时间。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("update_time")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RegularDateTimeOffsetConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("update_time")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RegularDateTimeOffsetConverter))]
|
||||
public DateTimeOffset UpdateTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("list")]
|
||||
public Types.Skill[] SkillList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置技能总数量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("count")]
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user