Spotify.NET/SpotifyAPI.Web/Models/Token.cs

47 lines
979 B
C#
Raw Normal View History

using System;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{
public class Token
{
public Token()
{
CreateDate = DateTime.Now;
}
2015-07-26 13:02:22 +01:00
[JsonProperty("access_token")]
public string AccessToken { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("token_type")]
public string TokenType { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("expires_in")]
public double ExpiresIn { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("error")]
public string Error { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("error_description")]
public string ErrorDescription { get; set; }
public DateTime CreateDate { get; set; }
/// <summary>
/// Checks if the token has expired
/// </summary>
/// <returns></returns>
public bool IsExpired()
{
return CreateDate.Add(TimeSpan.FromSeconds(ExpiresIn)) <= DateTime.Now;
}
public bool HasError()
{
return Error != null;
}
}
2015-07-26 13:02:22 +01:00
}