public void ArtistId_UserCollectionArtistUri_ReturnsArtistId() { // arrange const string artistId = "65XA3lk0aG9XejO8y37jjD"; string collectionUri = $"spotify:user:daniellarsennz:collection:artist:{artistId}"; // act string id = SpotifyUriHelper.ArtistId(collectionUri); // assert Assert.AreEqual(artistId, id); }
/// <summary> /// Get Spotify catalog information about an artist’s top tracks by country. /// </summary> /// <param name="artistId">The Spotify ID for the artist.</param> /// <param name="market">Required. An ISO 3166-1 alpha-2 country code (<see cref="SpotifyCountryCodes"/>) /// or the string `from_token`.</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service, /// used for this call only. See constructors for more ways to provide access tokens.</param> /// <typeparam name="T">Optionally provide your own type to deserialise Spotify's response to.</typeparam> /// <returns>Task of T. The Spotify response is deserialised as T.</returns> public async Task <T> GetArtistsTopTracks <T>(string artistId, string market, string accessToken = null) { if (string.IsNullOrWhiteSpace(artistId)) { throw new ArgumentNullException("artistId"); } if (string.IsNullOrWhiteSpace(market)) { throw new ArgumentNullException("market"); } return(await GetModelFromProperty <T>($"{BaseUrl}/artists/{SpotifyUriHelper.ArtistId(artistId)}/top-tracks?country={market}", "tracks", accessToken)); }
/// <summary> /// Get Spotify catalog information about artists similar to a given artist. Similarity is /// based on analysis of the Spotify community’s listening history. /// </summary> /// <param name="artistId">The Spotify ID for the artist.</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service, /// used for this call only. See constructors for more ways to provide access tokens.</param> /// <typeparam name="T">Optionally provide your own type to deserialise Spotify's response to.</typeparam> /// <returns>Task of T. The Spotify response is deserialised as T.</returns> public async Task <T> GetRelatedArtists <T>(string artistId, string accessToken = null) => await GetModel <T>($"{BaseUrl}/artists/{SpotifyUriHelper.ArtistId(artistId)}/related-artists", accessToken);
/// <summary> /// Get Spotify catalog information for a single artist identified by their unique Spotify ID. /// </summary> /// <param name="artistId">The Spotify ID for the artist.</param> /// <param name="accessToken">Optional. A valid access token from the Spotify Accounts service, /// used for this call only. See constructors for more ways to provide access tokens.</param> /// <typeparam name="T">Optionally provide your own type to deserialise Spotify's response to.</typeparam> /// <returns>Task of T. The Spotify response is deserialised as T.</returns> public async Task <T> GetArtist <T>(string artistId, string accessToken = null) => await GetModel <T>(new Uri($"{BaseUrl}/artists/{SpotifyUriHelper.ArtistId(artistId)}"), accessToken);