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

24 lines
577 B
C#
Raw Permalink Normal View History

using Newtonsoft.Json;
using System;
2016-07-07 20:23:36 +01:00
using System.Net;
namespace SpotifyAPI.Web.Models
{
public abstract class BasicModel
{
[JsonProperty("error")]
public Error Error { get; set; }
2017-05-31 17:17:07 +01:00
private ResponseInfo _info;
2016-07-07 20:23:36 +01:00
public bool HasError() => Error != null;
2017-05-31 17:17:07 +01:00
internal void AddResponseInfo(ResponseInfo info) => _info = info;
2016-07-07 20:23:36 +01:00
2017-05-31 17:17:07 +01:00
public string Header(string key) => _info.Headers?.Get(key);
2016-07-07 20:23:36 +01:00
2017-05-31 17:17:07 +01:00
public WebHeaderCollection Headers() => _info.Headers;
public HttpStatusCode StatusCode() => _info.StatusCode;
}
}