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

This commit is contained in:
Fu Diwei 2021-08-06 23:01:48 +08:00
parent 01651593c9
commit 9be140a9fd
7 changed files with 298 additions and 0 deletions

View File

@ -546,6 +546,66 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
return await client.SendRequestWithJsonAsync<Models.TcbWxpayOpenAuthResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /tcb/batchdeletefile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/common/batchdeletefile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.TcbBatchDeleteFileResponse> ExecuteTcbBatchDeleteFileAsync(this WechatApiClient client, Models.TcbBatchDeleteFileRequest 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, "tcb", "batchdeletefile")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.TcbBatchDeleteFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /tcb/batchdownloadfile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/common/batchdownloadfile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.TcbBatchDownloadFileResponse> ExecuteTcbBatchDownloadFileAsync(this WechatApiClient client, Models.TcbBatchDownloadFileRequest 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, "tcb", "batchdownloadfile")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.TcbBatchDownloadFileResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [POST] /tcb/uploadfile 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/cloudbase/common/uploadfile.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.TcbUploadFileResponse> ExecuteTcbUploadFileAsync(this WechatApiClient client, Models.TcbUploadFileRequest 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, "tcb", "uploadfile")
.SetQueryParam("access_token", request.AccessToken);
return await client.SendRequestWithJsonAsync<Models.TcbUploadFileResponse>(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] /tcb/batchdeletefile 接口的请求。</para>
/// </summary>
public class TcbBatchDeleteFileRequest : WechatApiRequest
{
/// <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] /tcb/batchdeletefile 接口的响应。</para>
/// </summary>
public class TcbBatchDeleteFileResponse : 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,45 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /tcb/batchdownloadfile 接口的请求。</para>
/// </summary>
public class TcbBatchDownloadFileRequest : 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>
/// 获取或设置环境 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] /tcb/batchdownloadfile 接口的响应。</para>
/// </summary>
public class TcbBatchDownloadFileResponse : 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,25 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
{
/// <summary>
/// <para>表示 [POST] /tcb/uploadfile 接口的请求。</para>
/// </summary>
public class TcbUploadFileRequest : WechatApiRequest
{
/// <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] /tcb/uploadfile 接口的响应。</para>
/// </summary>
public class TcbUploadFileResponse : 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!;
}
}