Skip to content

Commit

Permalink
feat(microapp): 变更部分因新旧版接口入口点不同而变化的接口模型
Browse files Browse the repository at this point in the history
  • Loading branch information
fudiwei committed Mar 7, 2024
1 parent 0f65d6f commit c913e98
Show file tree
Hide file tree
Showing 317 changed files with 2,311 additions and 2,833 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
public abstract class DouyinMicroAppRequest : CommonRequestBase, ICommonRequest
{
/// <summary>
/// 获取或设置抖音小程序的 AccessToken。
/// 获取或设置抖音小程序的 AccessToken/ClientToken/BusinessToken
/// <para>
/// 注意:部分第三方平台的接口中该字段表示授权方的 AuthorizerAccessToken。
/// </para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
public abstract class DouyinMicroAppResponse : CommonResponseBase, ICommonResponse
{
/// <summary>
/// 获取抖音小程序 API 返回的详细错误号
/// 获取抖音小程序 API 返回的错误号
/// </summary>
[Newtonsoft.Json.JsonProperty("errcode")]
[System.Text.Json.Serialization.JsonPropertyName("errcode")]
public virtual long ErrorCode { get; set; }
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public virtual int ErrorNumber { get; set; }

/// <summary>
/// 获取抖音小程序 API 返回的错误信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("err_tips")]
[System.Text.Json.Serialization.JsonPropertyName("err_tips")]
public virtual string? ErrorTips { get; set; }

/// <summary>
/// 获取抖音小程序 API 返回的错误描述。
/// </summary>
[Newtonsoft.Json.JsonProperty("errmsg")]
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public virtual string? ErrorMessage { get; set; }

/// <summary>
Expand All @@ -30,13 +37,13 @@ public abstract class DouyinMicroAppResponse : CommonResponseBase, ICommonRespon
/// <summary>
/// 获取一个值,该值指示调用抖音小程序 API 是否成功。
/// <para>
///(即 HTTP 状态码为 200,且 <see cref="ErrorCode"/> 值为 0)
///(即 HTTP 状态码为 200,且 <see cref="ErrorNumber"/> 值为 0)
/// </para>
/// </summary>
/// <returns></returns>
public override bool IsSuccessful()
{
return GetRawStatus() == 200 && ErrorCode == 0;
return GetRawStatus() == 200 && ErrorNumber == 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.ExtendedSDK.ProductApi
{
public static class ByteDanceMicroAppProductApiClientExecuteProductExtensions
public static class DouyinMicroAppProductApiClientExecuteProductExtensions
{
/// <summary>
/// <para>异步调用 [POST] /add 接口。</para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public class VideoAnchorInfo
}

/// <summary>
/// 获取或设置小程序的 AppId。如果不指定将使用构造 <see cref="DouyinMicroAppClient"/> 时的 <see cref="DouyinMicroAppClientOptions.AppId"/> 参数。
/// 获取或设置小程序 AppId。如果不指定将使用构造 <see cref="DouyinMicroAppClient"/> 时的 <see cref="DouyinMicroAppClientOptions.AppId"/> 参数。
/// </summary>
[Newtonsoft.Json.JsonProperty("appid")]
[System.Text.Json.Serialization.JsonPropertyName("appid")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static ErroredResult VerifyResponseSignature<TResponse>(this DouyinMicroA

bool valid = Utilities.RSAUtility.Verify(
publicKeyPem: client.Credentials.PlatformPublicKey,
messageData: new EncodedString(stringBuilder.ToString(), EncodingKinds.Literal),
messageData: stringBuilder.ToString(),
encodingSignature: new EncodedString(response.ByteSignature, EncodingKinds.Base64),
Utilities.RSAUtility.DIGEST_ALGORITHM_SHA256
);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteAppsGameExtensions
public static class DouyinMicroAppClientExecuteLegacyAppsGameExtensions
{
private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient client, TRequest request, string httpMethod, string httpLocation)
where TRequest : Models.AppsGameWalletRequestBase
Expand Down Expand Up @@ -65,7 +65,8 @@ private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient cl
request.Signature = GenerateRequestSignature(client, request, HttpMethod.Post.Method, "/api/apps/game/wallet/get_balance");

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "get_balance");
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "get_balance")
.WithUrl($"{client._BASEURL_LEGACY}/apps/game/wallet/get_balance");

return await client.SendFlurlRequestAsJsonAsync<Models.AppsGameWalletGetBalanceResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -96,7 +97,8 @@ private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient cl
request.Signature = GenerateRequestSignature(client, request, HttpMethod.Post.Method, "/api/apps/game/wallet/game_pay");

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "game_pay");
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "game_pay")
.WithUrl($"{client._BASEURL_LEGACY}/apps/game/wallet/game_pay");

return await client.SendFlurlRequestAsJsonAsync<Models.AppsGameWalletGamePayResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -127,7 +129,8 @@ private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient cl
request.Signature = GenerateRequestSignature(client, request, HttpMethod.Post.Method, "/api/apps/game/wallet/add_coin");

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "add_coin");
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "game", "wallet", "add_coin")
.WithUrl($"{client._BASEURL_LEGACY}/apps/game/wallet/add_coin");

return await client.SendFlurlRequestAsJsonAsync<Models.AppsGameWalletAddCoinResponse>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SKIT.FlurlHttpClient.ByteDance.MicroApp
{
public static class DouyinMicroAppClientExecuteAppsStorageExtensions
public static class DouyinMicroAppClientExecuteLegacyAppsStorageExtensions
{
private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient client, TRequest request, string signMethod, string sessionKey)
where TRequest : DouyinMicroAppRequest
Expand Down Expand Up @@ -55,6 +55,7 @@ private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient cl

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "set_user_storage")
.WithUrl($"{client._BASEURL_LEGACY}/apps/set_user_storage")
.SetQueryParam("access_token", request.AccessToken)
.SetQueryParam("openid", request.OpenId)
.SetQueryParam("signature", request.Signature)
Expand Down Expand Up @@ -85,6 +86,7 @@ private static string GenerateRequestSignature<TRequest>(DouyinMicroAppClient cl

IFlurlRequest flurlReq = client
.CreateFlurlRequest(request, HttpMethod.Post, "apps", "remove_user_storage")
.WithUrl($"{client._BASEURL_LEGACY}/apps/remove_user_storage")
.SetQueryParam("access_token", request.AccessToken)
.SetQueryParam("openid", request.OpenId)
.SetQueryParam("signature", request.Signature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacityAddAwemeVideoKeywordV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacityDeleteAwemeVideoKeywordV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class AppsCapacityQueryAwemeVideoKeywordListV1Request : DouyinMicroAppReq
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int Page { get; set; } = 1;
public int PageNumber { get; set; } = 1;

/// <summary>
/// 获取或设置分页每页数量。
/// <para>默认值:10</para>
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public int Limit { get; set; } = 10;
public int PageSize { get; set; } = 10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ public class Keyword
}
}

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }

/// <summary>
/// 获取或设置返回数据。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacityAddAliasV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacityDeleteAliasV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacityModifyAliasV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ public class AliasItem
}
}

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }

/// <summary>
/// 获取或设置返回数据。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ public class TagItem
}
}

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }

/// <summary>
/// 获取或设置返回数据。
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ namespace SKIT.FlurlHttpClient.ByteDance.MicroApp.Models
/// </summary>
public class AppsCapacitySetSearchTagV1Response : DouyinMicroAppResponse
{
/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_no")]
[System.Text.Json.Serialization.JsonPropertyName("err_no")]
public override long ErrorCode { get; set; }

/// <inheritdoc/>
[Newtonsoft.Json.JsonProperty("err_msg")]
[System.Text.Json.Serialization.JsonPropertyName("err_msg")]
public override string? ErrorMessage { get; set; }
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c913e98

Please sign in to comment.