feat(wxapi): 新增批量代云开发环境管理相关接口

This commit is contained in:
Fu Diwei
2021-08-05 21:37:57 +08:00
parent 5a6f445c61
commit ae6c6aa7f4
21 changed files with 488 additions and 12 deletions

View File

@@ -0,0 +1,116 @@
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.Api
{
public static class WechatApiClientExecuteComponentTcbExtensions
{
#region Environment
/// <summary>
/// <para>异步调用 [POST] /componenttcb/createenv 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/createenv.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbCreateEnvironmentResponse> ExecuteComponentTcbCreateEnvironmentAsync(this WechatApiClient client, Models.ComponentTcbCreateEnvironmentRequest 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, "componenttcb", "createenv")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbCreateEnvironmentResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/modifyenv 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/modifyenv.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbModifyEnvironmentResponse> ExecuteComponentTcbModifyEnvironmentAsync(this WechatApiClient client, Models.ComponentTcbModifyEnvironmentRequest 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, "componenttcb", "modifyenv")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbModifyEnvironmentResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/describeenvs 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/describeenvs.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbDescribeEnvironmentsResponse> ExecuteComponentTcbDescribeEnvironmentsAsync(this WechatApiClient client, Models.ComponentTcbDescribeEnvironmentsRequest 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, "componenttcb", "describeenvs")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbDescribeEnvironmentsResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/batchshareenv 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/batchshareenv.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbBatchShareEnvironmentResponse> ExecuteComponentTcbBatchShareEnvironmentAsync(this WechatApiClient client, Models.ComponentTcbBatchShareEnvironmentRequest 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, "componenttcb", "batchshareenv")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchShareEnvironmentResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/batchgetenvid 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/batchgetenvid.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbBatchGetEnvironmentIdResponse> ExecuteComponentTcbBatchGetEnvironmentIdAsync(this WechatApiClient client, Models.ComponentTcbBatchGetEnvironmentIdRequest 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, "componenttcb", "batchgetenvid")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchGetEnvironmentIdResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchgetenvid 接口的请求。</para>
/// </summary>
public class ComponentTcbBatchGetEnvironmentIdRequest : WechatApiRequest
{
/// <summary>
/// 获取或设置第三方平台 AccessToken。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string ComponentAccessToken { get; set; } = string.Empty;
/// <summary>
/// 获取或设置 AppId 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("appids")]
[System.Text.Json.Serialization.JsonPropertyName("appids")]
public IList<string> AppIdList { get; set; } = new List<string>();
}
}

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchgetenvid 接口的响应。</para>
/// </summary>
public class ComponentTcbBatchGetEnvironmentIdResponse : WechatApiResponse
{
public static class Types
{
public class Relation
{
/// <summary>
/// 获取或设置 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置环境 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("env_list")]
[System.Text.Json.Serialization.JsonPropertyName("env_list")]
public string[] EnvironmentIdList { get; set; } = default!;
}
public class Error : ComponentTcbBatchShareEnvironmentResponse.Types.Error
{
}
}
/// <summary>
/// 获取或设置关系列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("relation_data")]
[System.Text.Json.Serialization.JsonPropertyName("relation_data")]
public Types.Relation[] RelationList { get; set; } = default!;
/// <summary>
/// 获取或设置错误列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("err_list")]
[System.Text.Json.Serialization.JsonPropertyName("err_list")]
public Types.Error[]? ErrorList { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchshareenv 接口的请求。</para>
/// </summary>
public class ComponentTcbBatchShareEnvironmentRequest : WechatApiRequest
{
public static class Types
{
public class Data
{
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置 AppId 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("appids")]
[System.Text.Json.Serialization.JsonPropertyName("appids")]
public IList<string> AppIdList { get; set; } = new List<string>();
}
}
/// <summary>
/// 获取或设置第三方平台 AccessToken。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string ComponentAccessToken { get; set; } = string.Empty;
/// <summary>
/// 获取或设置数据列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("data")]
[System.Text.Json.Serialization.JsonPropertyName("data")]
public IList<Types.Data> DataList { get; set; } = new List<Types.Data>();
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchshareenv 接口的响应。</para>
/// </summary>
public class ComponentTcbBatchShareEnvironmentResponse : WechatApiResponse
{
public static class Types
{
public class Error
{
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = default!;
/// <summary>
/// 获取或设置 AppId。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
public string AppId { get; set; } = default!;
/// <summary>
/// 获取或设置错误信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("errmsg")]
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
public string ErrorMessage { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置错误列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("err_list")]
[System.Text.Json.Serialization.JsonPropertyName("err_list")]
public Types.Error[]? ErrorList { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/createenv 接口的请求。</para>
/// </summary>
public class ComponentTcbCreateEnvironmentRequest : WechatApiRequest
{
/// <summary>
/// 获取或设置第三方平台 AccessToken。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string ComponentAccessToken { get; set; } = string.Empty;
/// <summary>
/// 获取或设置环境别名。
/// </summary>
[Newtonsoft.Json.JsonProperty("alias")]
[System.Text.Json.Serialization.JsonPropertyName("alias")]
public string Alias { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/createenv 接口的响应。</para>
/// </summary>
public class ComponentTcbCreateEnvironmentResponse : WechatApiResponse
{
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = default!;
/// <summary>
/// 获取或设置后付费订单号。
/// </summary>
[Newtonsoft.Json.JsonProperty("tranid")]
[System.Text.Json.Serialization.JsonPropertyName("tranid")]
public string TransactionId { get; set; } = default!;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/describeenvs 接口的请求。</para>
/// </summary>
public class ComponentTcbDescribeEnvironmentsRequest : WechatApiRequest
{
/// <summary>
/// 获取或设置第三方平台 AccessToken。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string ComponentAccessToken { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/describeenvs 接口的响应。</para>
/// </summary>
public class ComponentTcbDescribeEnvironmentsResponse : WechatApiResponse
{
public static class Types
{
public class Environment
{
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = default!;
/// <summary>
/// 获取或设置环境别名。
/// </summary>
[Newtonsoft.Json.JsonProperty("alias")]
[System.Text.Json.Serialization.JsonPropertyName("alias")]
public string Alias { get; set; } = default!;
/// <summary>
/// 获取或设置环境状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public string Status { get; set; } = default!;
/// <summary>
/// 获取或设置产品套餐 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("package_id")]
[System.Text.Json.Serialization.JsonPropertyName("package_id")]
public string? PackageId { get; set; }
/// <summary>
/// 获取或设置产品套餐名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("package_name")]
[System.Text.Json.Serialization.JsonPropertyName("package_name")]
public string? PackageName { get; set; }
/// <summary>
/// 获取或设置数据库实例 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("dbinstance_id")]
[System.Text.Json.Serialization.JsonPropertyName("dbinstance_id")]
public string? DbInstanceId { get; set; }
/// <summary>
/// 获取或设置静态存储桶 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("bucket_id")]
[System.Text.Json.Serialization.JsonPropertyName("bucket_id")]
public string? BucketId { get; set; }
/// <summary>
/// 获取或设置修改时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("update_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("update_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset UpdateTime { get; set; } = default!;
/// <summary>
/// 获取或设置创建时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("create_time")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("create_time")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset CreateTime { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置环境列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("info_list")]
[System.Text.Json.Serialization.JsonPropertyName("info_list")]
public Types.Environment[] EnvironmentList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/modifyenv 接口的请求。</para>
/// </summary>
public class ComponentTcbModifyEnvironmentRequest : WechatApiRequest
{
/// <summary>
/// 获取或设置第三方平台 AccessToken。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string ComponentAccessToken { get; set; } = string.Empty;
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/modifyenv 接口的响应。</para>
/// </summary>
public class ComponentTcbModifyEnvironmentResponse : WechatApiResponse
{
}
}

View File

@@ -13,7 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置函数名称。

View File

@@ -20,7 +20,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env_id")]
[System.Text.Json.Serialization.JsonPropertyName("env_id")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置活动 ID。

View File

@@ -13,7 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置短信 CSV 文件地址。

View File

@@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("EnvId")]
[System.Text.Json.Serialization.JsonPropertyName("EnvId")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置开始日期格式yyyy-MM-dd

View File

@@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env_id")]
[System.Text.Json.Serialization.JsonPropertyName("env_id")]
public string? EnvId { get; set; }
public string? EnvironmentId { get; set; }
/// <summary>
/// 获取或设置活动 ID。

View File

@@ -13,7 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置手机号列表。

View File

@@ -13,7 +13,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置 URL Link。

View File

@@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvId { get; set; } = string.Empty;
public string EnvironmentId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置静态网站自定义域名。

View File

@@ -42,7 +42,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("pre_env")]
[System.Text.Json.Serialization.JsonPropertyName("pre_env")]
public string? PreFetchEnvId { get; set; }
public string? PreFetchEnvironmentId { get; set; }
/// <summary>
/// 获取或设置数据预拉取云函数名。
@@ -77,7 +77,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("period_env")]
[System.Text.Json.Serialization.JsonPropertyName("period_env")]
public string? PeriodFetchEnvId { get; set; }
public string? PeriodFetchEnvironmentId { get; set; }
/// <summary>
/// 获取或设置数据周期性拉取云函数名。

View File

@@ -34,7 +34,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("pre_env")]
[System.Text.Json.Serialization.JsonPropertyName("pre_env")]
public string? PreFetchEnvId { get; set; }
public string? PreFetchEnvironmentId { get; set; }
/// <summary>
/// 获取或设置数据预拉取云函数名。
@@ -69,7 +69,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("period_env")]
[System.Text.Json.Serialization.JsonPropertyName("period_env")]
public string? PeriodFetchEnvId { get; set; }
public string? PeriodFetchEnvironmentId { get; set; }
/// <summary>
/// 获取或设置数据周期性拉取云函数名。