mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 23:16:28 +00:00
Removed code duplicity.
This commit is contained in:
parent
0250131345
commit
cf2d2f632b
@ -715,21 +715,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||||
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.IsFollowing(followType, ids));
|
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.IsFollowing(followType, ids));
|
||||||
ListResponse<bool> ret;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -744,21 +730,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowing");
|
throw new InvalidOperationException("Auth is required for IsFollowing");
|
||||||
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.IsFollowing(followType, ids));
|
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.IsFollowing(followType, ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -868,21 +840,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
||||||
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
|
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -898,21 +856,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
throw new InvalidOperationException("Auth is required for IsFollowingPlaylist");
|
||||||
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
|
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.IsFollowingPlaylist(ownerId, playlistId, ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1056,21 +1000,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.CheckSavedTracks(ids));
|
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.CheckSavedTracks(ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1084,21 +1014,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.CheckSavedTracks(ids));
|
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.CheckSavedTracks(ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1212,21 +1128,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
throw new InvalidOperationException("Auth is required for CheckSavedTracks");
|
||||||
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.CheckSavedAlbums(ids));
|
Tuple<ResponseInfo, JToken> res = DownloadDataAlt<JToken>(_builder.CheckSavedAlbums(ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1240,21 +1142,7 @@ namespace SpotifyAPI.Web
|
|||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync");
|
throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync");
|
||||||
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.CheckSavedAlbums(ids));
|
Tuple<ResponseInfo, JToken> res = await DownloadDataAltAsync<JToken>(_builder.CheckSavedAlbums(ids));
|
||||||
ListResponse<bool> ret = null;
|
return ExtractDataFromAltDownload(res);
|
||||||
if (res.Item2 is JArray)
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = res.Item2.ToObject<List<bool>>(),
|
|
||||||
Error = null
|
|
||||||
};
|
|
||||||
else
|
|
||||||
ret = new ListResponse<bool>
|
|
||||||
{
|
|
||||||
List = null,
|
|
||||||
Error = res.Item2["error"].ToObject<Error>()
|
|
||||||
};
|
|
||||||
ret.AddResponseInfo(res.Item1);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Library
|
#endregion Library
|
||||||
@ -1928,6 +1816,25 @@ namespace SpotifyAPI.Web
|
|||||||
return await GetPreviousPageAsync<Paging<T>, T>(paging);
|
return await GetPreviousPageAsync<Paging<T>, T>(paging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ListResponse<bool> ExtractDataFromAltDownload(Tuple<ResponseInfo, JToken> res)
|
||||||
|
{
|
||||||
|
ListResponse<bool> ret = null;
|
||||||
|
if (res.Item2 is JArray)
|
||||||
|
ret = new ListResponse<bool>
|
||||||
|
{
|
||||||
|
List = res.Item2.ToObject<List<bool>>(),
|
||||||
|
Error = null
|
||||||
|
};
|
||||||
|
else
|
||||||
|
ret = new ListResponse<bool>
|
||||||
|
{
|
||||||
|
List = null,
|
||||||
|
Error = res.Item2["error"].ToObject<Error>()
|
||||||
|
};
|
||||||
|
ret.AddResponseInfo(res.Item1);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public T UploadData<T>(string url, string uploadData, string method = "POST") where T : BasicModel
|
public T UploadData<T>(string url, string uploadData, string method = "POST") where T : BasicModel
|
||||||
{
|
{
|
||||||
if (!UseAuth)
|
if (!UseAuth)
|
||||||
|
Loading…
Reference in New Issue
Block a user