/// <summary> /// Get Spotify catalog information for a single album. /// </summary> /// <param name="albumId">The Spotify ID for the album.</param> /// <param name="market">Optional. An ISO 3166-1 alpha-2 country code or the string `from_token` /// (See <see cref="SpotifyCountryCodes"/>). Provide this parameter if you want to apply Track Relinking.</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service.</param> /// <typeparam name="T">Optionally provide your own type to deserialise Spotify's response to.</typeparam> /// <returns>A Task that, once successfully completed, returns a Model of T.</returns> /// <remarks>https://developer.spotify.com/documentation/web-api/reference/albums/get-album/</remarks> public async Task <T> GetAlbum <T>(string albumId, string market = null, string accessToken = null) { string url = $"{BaseUrl}/albums/{SpotifyUriHelper.AlbumId(albumId)}"; if (!string.IsNullOrEmpty(market)) { url += $"?market={market}"; } return(await GetModel <T>(url, accessToken)); }
public async Task <T> NewGetAlbumTracks <T>( string albumId, int?limit = null, int offset = 0, string market = null, string accessToken = null) { var url = "https://api.spotify.com/v1/albums/" + SpotifyUriHelper.AlbumId(albumId) + "/tracks"; if (limit.HasValue || !string.IsNullOrEmpty(market)) { url += "?"; } if (limit.HasValue) { url += $"limit={limit.Value}&offset={offset}&"; } if (!string.IsNullOrEmpty(market)) { url = url + "market=" + market; } return(await GetModelFromProperty <T>(url, "items", accessToken)); }
/// <summary> /// Get Spotify catalog information about an album’s tracks. Optional parameters can be used to limit the number of tracks returned. /// </summary> /// <param name="albumId">The Spotify ID for the album.</param> /// <param name="limit">Optional. The maximum number of tracks to return. Default: 20. Minimum: 1. Maximum: 50.</param> /// <param name="offset">Optional. The index of the first track to return. Default: 0 (the first /// object). Use with limit to get the next set of tracks.</param> /// <param name="market">Optional. An ISO 3166-1 alpha-2 country code or the string `from_token` /// (See <see cref="SpotifyCountryCodes"/>). Provide this parameter if you want to apply Track Relinking.</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service.</param> /// <typeparam name="T">Optionally provide your own type to deserialise Spotify's response to.</typeparam> /// <returns>A Task that, once successfully completed, returns a Model of T.</returns> /// <remarks>https://developer.spotify.com/documentation/web-api/reference/albums/get-albums-tracks/</remarks> public async Task <T> GetAlbumTracks <T>( string albumId, int?limit = null, int offset = 0, string market = null, string accessToken = null) { string url = $"{BaseUrl}/albums/{SpotifyUriHelper.AlbumId(albumId)}/tracks"; if (limit.HasValue || !string.IsNullOrEmpty(market)) { url += "?"; } if (limit.HasValue) { url += $"limit={limit.Value}&offset={offset}&"; } if (!string.IsNullOrEmpty(market)) { url += $"market={market}"; } return(await GetModel <T>(url, accessToken)); }