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

42 lines
1.0 KiB
C#
Raw Normal View History

using Newtonsoft.Json;
using System;
namespace SpotifyAPI.Web.Models
{
public class Token
{
2015-07-26 13:02:22 +01:00
public Token()
{
CreateDate = DateTime.Now;
}
[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 int 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 Boolean IsExpired()
{
return CreateDate.Add(TimeSpan.FromSeconds(ExpiresIn)) <= DateTime.Now;
}
}
2015-07-26 13:02:22 +01:00
}