feat(wxapi): 新增批量代云开发静态网站管理相关接口

This commit is contained in:
Fu Diwei 2021-08-06 15:55:10 +08:00
parent a0200005f9
commit 41a20bbab4
10 changed files with 341 additions and 1 deletions

View File

@ -641,5 +641,87 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
return await client.SendRequestWithJsonAsync<Models.ComponentTcbGetBucketResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
#region StaticStore
/// <summary>
/// <para>异步调用 [POST] /componenttcb/createstaticstore 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/CreateStaticStore.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbCreateStaticStoreResponse> ExecuteComponentTcbCreateStaticStoreAsync(this WechatApiClient client, Models.ComponentTcbCreateStaticStoreRequest 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", "createstaticstore")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbCreateStaticStoreResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/describestaticstore 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/DescribeStaticStore.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbDescribeStaticStoreResponse> ExecuteComponentTcbDescribeStaticStoreAsync(this WechatApiClient client, Models.ComponentTcbDescribeStaticStoreRequest 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", "describestaticstore")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbDescribeStaticStoreResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/staticfilelist 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/staticFileList.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbStaticFileListResponse> ExecuteComponentTcbStaticFileListAsync(this WechatApiClient client, Models.ComponentTcbStaticFileListRequest 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", "staticfilelist")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbStaticFileListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/staticuploadfile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/staticUploadFile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbStaticUploadFileResponse> ExecuteComponentTcbStaticUploadFileAsync(this WechatApiClient client, Models.ComponentTcbStaticUploadFileRequest 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", "staticuploadfile")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbStaticUploadFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
}
}

View File

@ -50,7 +50,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
/// </summary>
[Newtonsoft.Json.JsonProperty("contents")]
[System.Text.Json.Serialization.JsonPropertyName("contents")]
public Types.File[] FileList6 { get; set; } = default!;
public Types.File[] FileList { get; set; } = default!;
/// <summary>
/// 获取或设置内容是否被截断。

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/createstaticstore 接口的请求。</para>
/// </summary>
public class ComponentTcbCreateStaticStoreRequest : 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/createstaticstore 接口的响应。</para>
/// </summary>
public class ComponentTcbCreateStaticStoreResponse : WechatApiResponse
{
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/describestaticstore 接口的请求。</para>
/// </summary>
public class ComponentTcbDescribeStaticStoreRequest : 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,60 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/describestaticstore 接口的响应。</para>
/// </summary>
public class ComponentTcbDescribeStaticStoreResponse : WechatApiResponse
{
public static class Types
{
public class Website
{
/// <summary>
/// 获取或设置环境 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("env")]
[System.Text.Json.Serialization.JsonPropertyName("env")]
public string EnvironmentId { get; set; } = default!;
/// <summary>
/// 获取或设置域名。
/// </summary>
[Newtonsoft.Json.JsonProperty("domain")]
[System.Text.Json.Serialization.JsonPropertyName("domain")]
public string Domain { get; set; } = default!;
/// <summary>
/// 获取或设置存储桶。
/// </summary>
[Newtonsoft.Json.JsonProperty("bucket")]
[System.Text.Json.Serialization.JsonPropertyName("bucket")]
public string Bucket { get; set; } = default!;
/// <summary>
/// 获取或设置区域。
/// </summary>
[Newtonsoft.Json.JsonProperty("regoin")]
[System.Text.Json.Serialization.JsonPropertyName("regoin")]
public string Region { get; set; } = default!;
/// <summary>
/// 获取或设置状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public string Status { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置网站列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("data")]
[System.Text.Json.Serialization.JsonPropertyName("data")]
public Types.Website[] WebsiteList { get; set; } = default!;
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/staticfilelist 接口的请求。</para>
/// </summary>
public class ComponentTcbStaticFileListRequest : 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;
/// <summary>
/// 获取或设置前缀匹配。
/// </summary>
[Newtonsoft.Json.JsonProperty("prefix")]
[System.Text.Json.Serialization.JsonPropertyName("prefix")]
public string? Prefix { get; set; }
/// <summary>
/// 获取或设置定界符。
/// </summary>
[Newtonsoft.Json.JsonProperty("delimiter")]
[System.Text.Json.Serialization.JsonPropertyName("delimiter")]
public string? Delimiter { get; set; }
/// <summary>
/// 获取或设置标志位。
/// </summary>
[Newtonsoft.Json.JsonProperty("marker")]
[System.Text.Json.Serialization.JsonPropertyName("marker")]
public string? Marker { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/staticfilelist 接口的响应。</para>
/// </summary>
public class ComponentTcbStaticFileListResponse : WechatApiResponse
{
public static class Types
{
public class File : ComponentTcbGetBucketResponse.Types.File
{
}
}
/// <summary>
/// 获取或设置网站列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("contents")]
[System.Text.Json.Serialization.JsonPropertyName("contents")]
public Types.File[] FileList { get; set; } = default!;
/// <summary>
/// 获取或设置内容是否被截断。
/// </summary>
[Newtonsoft.Json.JsonProperty("is_truncated")]
[System.Text.Json.Serialization.JsonPropertyName("is_truncated")]
public bool IsTruncated { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/staticuploadfile 接口的请求。</para>
/// </summary>
public class ComponentTcbStaticUploadFileRequest : 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;
/// <summary>
/// 获取或设置上传文件名。
/// </summary>
[Newtonsoft.Json.JsonProperty("filename")]
[System.Text.Json.Serialization.JsonPropertyName("filename")]
public string FileName { 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/staticuploadfile 接口的响应。</para>
/// </summary>
public class ComponentTcbStaticUploadFileResponse : WechatApiResponse
{
/// <summary>
/// 获取或设置上传 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("signed_url")]
[System.Text.Json.Serialization.JsonPropertyName("signed_url")]
public string Url { get; set; } = default!;
/// <summary>
/// 获取或设置上传凭证。
/// </summary>
[Newtonsoft.Json.JsonProperty("token")]
[System.Text.Json.Serialization.JsonPropertyName("token")]
public string Token { get; set; } = default!;
}
}