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")]
2016-03-31 11:08:23 +01:00
public string AccessToken { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("token_type")]
2016-03-31 11:08:23 +01:00
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")]
2016-03-31 11:08:23 +01:00
public string RefreshToken { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("error")]
2016-03-31 11:08:23 +01:00
public string Error { get; set; }
2015-07-26 13:02:22 +01:00
[JsonProperty("error_description")]
2016-03-31 11:08:23 +01:00
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
}