using System.Text.Json.Serialization;
namespace Myshipping.Core;
///
/// AccessToken参数
///
public class TokenModel
{
///
/// 用户标识
///
[JsonPropertyName("openid")]
public string OpenId { get; set; }
///
/// Token 类型
///
[JsonPropertyName("token_type")]
public string TokenType { get; set; }
///
/// AccessToken
///
[JsonPropertyName("access_token")]
public string AccessToken { get; set; }
///
/// 用于刷新 AccessToken 的 Token
///
[JsonPropertyName("refresh_token")]
public string RefreshToken { get; set; }
///
/// 此 AccessToken 对应的权限
///
[JsonPropertyName("scope")]
public string Scope { get; set; }
///
/// AccessToken 过期时间
///
[JsonPropertyName("expires_in")]
public dynamic ExpiresIn { get; set; }
///
/// 错误的详细描述
///
[JsonPropertyName("error_description")]
public string ErrorDescription { get; set; }
}
public static class AccessTokenModelModelExtensions
{
///
/// 获取的Token是否包含错误
///
///
///
public static bool HasError(this TokenModel accessTokenModel)
{
return accessTokenModel == null ||
string.IsNullOrEmpty(accessTokenModel.AccessToken) ||
!string.IsNullOrEmpty(accessTokenModel.ErrorDescription);
}
}