2014-07-20 21:42:46 +01:00
|
|
|
|
using System;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
2015-07-07 17:11:11 +01:00
|
|
|
|
namespace SpotifyAPI.Web.Models
|
2014-07-20 21:42:46 +01:00
|
|
|
|
{
|
|
|
|
|
public class Token
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("access_token")]
|
|
|
|
|
public String AccessToken { get; set; }
|
|
|
|
|
[JsonProperty("token_type")]
|
|
|
|
|
public String TokenType { get; set; }
|
|
|
|
|
[JsonProperty("expires_in")]
|
|
|
|
|
public int ExpiresIn { get; set; }
|
|
|
|
|
[JsonProperty("refresh_token")]
|
|
|
|
|
public String RefreshToken { get; set; }
|
|
|
|
|
[JsonProperty("error")]
|
|
|
|
|
public String Error { get; set; }
|
|
|
|
|
[JsonProperty("error_description")]
|
|
|
|
|
public String ErrorDescription { get; set; }
|
|
|
|
|
|
|
|
|
|
public DateTime CreateDate { get; set; }
|
2015-07-07 17:11:11 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
public Token()
|
|
|
|
|
{
|
|
|
|
|
CreateDate = DateTime.Now;
|
|
|
|
|
}
|
2015-07-07 17:11:11 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the token has expired
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2014-07-20 21:42:46 +01:00
|
|
|
|
public Boolean IsExpired()
|
|
|
|
|
{
|
2015-07-07 17:11:11 +01:00
|
|
|
|
return CreateDate.Add(TimeSpan.FromSeconds(ExpiresIn)) <= DateTime.Now;
|
2014-07-20 21:42:46 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|