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

This commit is contained in:
Fu Diwei
2021-08-06 14:00:49 +08:00
parent e9bf5f4375
commit 419eba1715
9 changed files with 449 additions and 0 deletions

View File

@@ -559,5 +559,87 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchSetContainerServicePropotionResponse>(flurlReq, data: request, cancellationToken: cancellationToken); return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchSetContainerServicePropotionResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
} }
#endregion #endregion
#region COS
/// <summary>
/// <para>异步调用 [POST] /componenttcb/uploadfile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/uploadfile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbUploadFileResponse> ExecuteComponentTcbUploadFileAsync(this WechatApiClient client, Models.ComponentTcbUploadFileRequest 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", "uploadfile")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbUploadFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/batchdownloadfile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/batchdownloadfile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbBatchDownloadFileResponse> ExecuteComponentTcbBatchDownloadFileAsync(this WechatApiClient client, Models.ComponentTcbBatchDownloadFileRequest 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", "batchdownloadfile")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchDownloadFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/batchdeletefile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/batchdeletefile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbBatchDeleteFileResponse> ExecuteComponentTcbBatchDeleteFileAsync(this WechatApiClient client, Models.ComponentTcbBatchDeleteFileRequest 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", "batchdeletefile")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbBatchDeleteFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /componenttcb/getbucket 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/batch/getbucket.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.ComponentTcbGetBucketResponse> ExecuteComponentTcbGetBucketAsync(this WechatApiClient client, Models.ComponentTcbGetBucketRequest 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", "getbucket")
.SetQueryParam("access_token", request.ComponentAccessToken);
return await client.SendRequestWithJsonAsync<Models.ComponentTcbGetBucketResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
#endregion
} }
} }

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchdeletefile 接口的请求。</para>
/// </summary>
public class ComponentTcbBatchDeleteFileRequest : 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>
/// 获取或设置文件 ID 列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("fileid_list")]
[System.Text.Json.Serialization.JsonPropertyName("fileid_list")]
public IList<string> FileIdList { get; set; } = new List<string>();
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchdeletefile 接口的响应。</para>
/// </summary>
public class ComponentTcbBatchDeleteFileResponse : WechatApiResponse
{
public static class Types
{
public class File
{
/// <summary>
/// 获取或设置文件 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("fileid")]
[System.Text.Json.Serialization.JsonPropertyName("fileid")]
public string FileId { get; set; } = default!;
/// <summary>
/// 获取或设置错误码。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public int ErrorCode { get; set; }
/// <summary>
/// 获取或设置错误描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("errmsg")]
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
public string? ErrorMessage { get; set; }
}
}
/// <summary>
/// 获取或设置文件列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("delete_list")]
[System.Text.Json.Serialization.JsonPropertyName("delete_list")]
public Types.File[] FileList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchdownloadfile 接口的请求。</para>
/// </summary>
public class ComponentTcbBatchDownloadFileRequest : WechatApiRequest
{
public static class Types
{
public class File
{
/// <summary>
/// 获取或设置文件 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("fileid")]
[System.Text.Json.Serialization.JsonPropertyName("fileid")]
public string FileId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置下载链接有效期(单位:秒)。
/// </summary>
[Newtonsoft.Json.JsonProperty("max_age")]
[System.Text.Json.Serialization.JsonPropertyName("max_age")]
public int MaxAge { get; set; }
}
}
/// <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("file_list")]
[System.Text.Json.Serialization.JsonPropertyName("file_list")]
public IList<Types.File> FileList { get; set; } = new List<Types.File>();
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/batchdownloadfile 接口的响应。</para>
/// </summary>
public class ComponentTcbBatchDownloadFileResponse : WechatApiResponse
{
public static class Types
{
public class File
{
/// <summary>
/// 获取或设置文件 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("fileid")]
[System.Text.Json.Serialization.JsonPropertyName("fileid")]
public string FileId { get; set; } = default!;
/// <summary>
/// 获取或设置下载链接。
/// </summary>
[Newtonsoft.Json.JsonProperty("download_url")]
[System.Text.Json.Serialization.JsonPropertyName("download_url")]
public string? DownloadUrl { get; set; }
/// <summary>
/// 获取或设置错误码。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public int ErrorCode { get; set; }
/// <summary>
/// 获取或设置错误描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("errmsg")]
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
public string? ErrorMessage { get; set; }
}
}
/// <summary>
/// 获取或设置文件列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("file_list")]
[System.Text.Json.Serialization.JsonPropertyName("file_list")]
public Types.File[] FileList { 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/getbucket 接口的请求。</para>
/// </summary>
public class ComponentTcbGetBucketRequest : 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,62 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/getbucket 接口的响应。</para>
/// </summary>
public class ComponentTcbGetBucketResponse : WechatApiResponse
{
public static class Types
{
public class File
{
/// <summary>
/// 获取或设置文件名称。
/// </summary>
[Newtonsoft.Json.JsonProperty("key")]
[System.Text.Json.Serialization.JsonPropertyName("key")]
public string FileKey { get; set; } = default!;
/// <summary>
/// 获取或设置文件的 MD5 值。
/// </summary>
[Newtonsoft.Json.JsonProperty("md5")]
[System.Text.Json.Serialization.JsonPropertyName("md5")]
public string FileMd5 { get; set; } = default!;
/// <summary>
/// 获取或设置文件大小(单位:字节)。
/// </summary>
[Newtonsoft.Json.JsonProperty("size")]
[System.Text.Json.Serialization.JsonPropertyName("size")]
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
public int FileSize { get; set; }
/// <summary>
/// 获取或设置最近修改时间。
/// </summary>
[Newtonsoft.Json.JsonProperty("last_modified")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.RFC3339DateTimeOffsetConverter))]
[System.Text.Json.Serialization.JsonPropertyName("last_modified")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.RFC3339DateTimeOffsetConverter))]
public DateTimeOffset LastModifiedTime { get; set; } = default!;
}
}
/// <summary>
/// 获取或设置文件列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("contents")]
[System.Text.Json.Serialization.JsonPropertyName("contents")]
public Types.File[] FileList6 { 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/uploadfile 接口的请求。</para>
/// </summary>
public class ComponentTcbUploadFileRequest : 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("path")]
[System.Text.Json.Serialization.JsonPropertyName("path")]
public string Path { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /componenttcb/uploadfile 接口的响应。</para>
/// </summary>
public class ComponentTcbUploadFileResponse : WechatApiResponse
{
/// <summary>
/// 获取或设置上传 URL。
/// </summary>
[Newtonsoft.Json.JsonProperty("url")]
[System.Text.Json.Serialization.JsonPropertyName("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!;
/// <summary>
/// 获取或设置授权信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("authorization")]
[System.Text.Json.Serialization.JsonPropertyName("authorization")]
public string Authorization { get; set; } = default!;
/// <summary>
/// 获取或设置文件 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("file_id")]
[System.Text.Json.Serialization.JsonPropertyName("file_id")]
public string FileId { get; set; } = default!;
/// <summary>
/// 获取或设置 COS 文件 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("cos_file_id")]
[System.Text.Json.Serialization.JsonPropertyName("cos_file_id")]
public string COSFileId { get; set; } = default!;
}
}