2015-10-16 23:44:35 +01:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
2014-07-20 21:42:46 +01:00
|
|
|
|
|
2015-07-07 17:11:11 +01:00
|
|
|
|
namespace SpotifyAPI.Web.Models
|
2014-07-20 21:42:46 +01:00
|
|
|
|
{
|
|
|
|
|
public class Token
|
|
|
|
|
{
|
2015-07-26 13:02:22 +01:00
|
|
|
|
public Token()
|
|
|
|
|
{
|
|
|
|
|
CreateDate = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("access_token")]
|
|
|
|
|
public String AccessToken { get; set; }
|
2015-07-26 13:02:22 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("token_type")]
|
|
|
|
|
public String TokenType { get; set; }
|
2015-07-26 13:02:22 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("expires_in")]
|
|
|
|
|
public int ExpiresIn { get; set; }
|
2015-07-26 13:02:22 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("refresh_token")]
|
|
|
|
|
public String RefreshToken { get; set; }
|
2015-07-26 13:02:22 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("error")]
|
|
|
|
|
public String Error { get; set; }
|
2015-07-26 13:02:22 +01:00
|
|
|
|
|
2014-07-20 21:42:46 +01:00
|
|
|
|
[JsonProperty("error_description")]
|
|
|
|
|
public String ErrorDescription { get; set; }
|
|
|
|
|
|
|
|
|
|
public DateTime CreateDate { get; set; }
|
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
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-26 13:02:22 +01:00
|
|
|
|
}
|