Spotify.NET/SpotifyAPI.Web/Models/BasicModel.cs
Justin Swanson 67cb3e42f1 TooManyRequests Handling (#282)
* SpotifyHttpStatusCode

A small supplementary enum for Spotify specific codes.  Only contains TooManyRequests currently, but more can be added.

* TooManyRequests Retry Handling

Will now parse and wait the Spotify recommended wait time.  Also has the option to not consume a retry attempt on this type of error

* TryGetTooManyRequests refactored to GetTooManyRequests

To keep the library consistent

* Removed SpotifyHttpStatusCode
2018-09-21 14:42:52 +02:00

25 lines
605 B
C#

using Newtonsoft.Json;
using SpotifyAPI.Web.Enums;
using System;
using System.Net;
namespace SpotifyAPI.Web.Models
{
public abstract class BasicModel
{
[JsonProperty("error")]
public Error Error { get; set; }
private ResponseInfo _info;
public bool HasError() => Error != null;
internal void AddResponseInfo(ResponseInfo info) => _info = info;
public string Header(string key) => _info.Headers?.Get(key);
public WebHeaderCollection Headers() => _info.Headers;
public HttpStatusCode StatusCode() => _info.StatusCode;
}
}