diff --git a/SpotifyAPI/Web/SpotifyWebAPI.cs b/SpotifyAPI/Web/SpotifyWebAPI.cs
index 1d7f1eaa..5892641a 100644
--- a/SpotifyAPI/Web/SpotifyWebAPI.cs
+++ b/SpotifyAPI/Web/SpotifyWebAPI.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Threading;
using System.Threading.Tasks;
namespace SpotifyAPI.Web
@@ -33,11 +34,6 @@ namespace SpotifyAPI.Web
};
}
- public string TokenType { get; set; }
- public string AccessToken { get; set; }
- public bool UseAuth { get; set; }
- public IClient WebClient { get; set; }
-
public void Dispose()
{
WebClient.Dispose();
@@ -45,25 +41,48 @@ namespace SpotifyAPI.Web
}
#region Configuration
+
///
- /// Specifies after how many miliseconds should a failed request be retried.
+ /// The type of the
+ ///
+ public string TokenType { get; set; }
+
+ ///
+ /// A valid token issued by spotify. Used only when is true
+ ///
+ public string AccessToken { get; set; }
+
+ ///
+ /// If true, an authorization header based on and will be used
+ ///
+ public bool UseAuth { get; set; }
+
+ ///
+ /// A custom WebClient, used for Unit-Testing
+ ///
+ public IClient WebClient { get; set; }
+
+
+ ///
+ /// Specifies after how many miliseconds should a failed request be retried.
///
public int RetryAfter { get; set; } = 50;
///
- /// Should a failed request (specified by be automatically retried or not.
+ /// Should a failed request (specified by be automatically retried or not.
///
public bool UseAutoRetry { get; set; } = false;
///
- /// Maximum number of tries for one failed request.
+ /// Maximum number of tries for one failed request.
///
public int RetryTimes { get; set; } = 10;
///
- /// Error codes that will trigger auto-retry if is enabled.
+ /// Error codes that will trigger auto-retry if is enabled.
///
- public IEnumerable RetryErrorCodes { get; private set; } = new int[] { 500, 502, 503 };
+ public IEnumerable RetryErrorCodes { get; set; } = new[] { 500, 502, 503 };
+
#endregion Configuration
#region Search
@@ -1832,12 +1851,12 @@ namespace SpotifyAPI.Web
private ListResponse DownloadList(string url)
{
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
ListResponse data = null;
do
{
- if (data != null) { System.Threading.Thread.Sleep(RetryAfter); }
+ if (data != null) { Thread.Sleep(RetryAfter); }
Tuple res = DownloadDataAlt(url);
data = ExtractDataToListResponse(res);
@@ -1853,7 +1872,7 @@ namespace SpotifyAPI.Web
private async Task> DownloadListAsync(string url)
{
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
ListResponse data = null;
do
@@ -1873,7 +1892,7 @@ namespace SpotifyAPI.Web
private static ListResponse ExtractDataToListResponse(Tuple res)
{
- ListResponse ret = null;
+ ListResponse ret;
if (res.Item2 is JArray)
{
ret = new ListResponse
@@ -1899,7 +1918,7 @@ namespace SpotifyAPI.Web
if (!UseAuth)
throw new InvalidOperationException("Auth is required for all Upload-Actions");
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
Tuple response = null;
do
@@ -1907,7 +1926,7 @@ namespace SpotifyAPI.Web
WebClient.SetHeader("Authorization", TokenType + " " + AccessToken);
WebClient.SetHeader("Content-Type", "application/json");
- if (response != null) { System.Threading.Thread.Sleep(RetryAfter); }
+ if (response != null) { Thread.Sleep(RetryAfter); }
response = WebClient.UploadJson(url, uploadData, method);
response.Item2.AddResponseInfo(response.Item1);
@@ -1926,7 +1945,7 @@ namespace SpotifyAPI.Web
throw new InvalidOperationException("Auth is required for all Upload-Actions");
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
Tuple response = null;
do
@@ -1950,12 +1969,12 @@ namespace SpotifyAPI.Web
public T DownloadData(string url) where T : BasicModel
{
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
Tuple response = null;
do
{
- if(response != null) { System.Threading.Thread.Sleep(RetryAfter); }
+ if(response != null) { Thread.Sleep(RetryAfter); }
response = DownloadDataAlt(url);
response.Item2.AddResponseInfo(response.Item1);
@@ -1972,7 +1991,7 @@ namespace SpotifyAPI.Web
public async Task DownloadDataAsync(string url) where T : BasicModel
{
int triesLeft = RetryTimes + 1;
- Error lastError = null;
+ Error lastError;
Tuple response = null;
do