/// <summary> /// Get the albums in the user's collection by a particular artist. /// </summary> /// <param name="artist">The artist's key.</param> /// <param name="user">The user's key or null to use the current authenticated user.</param> /// <param name="sort">The sorting direction of the results. Only Name and ReleaseDate are supported.</param> /// <param name="extras">The extra fields to be included in the object.</param> /// <returns>Returns a list of <seealso cref="RdioCollectionAlbum"/> objects.</returns> public Task<IList<RdioCollectionAlbum>> GetAlbumsForArtistInCollectionAsync(string artist, string user = null, RdioSortingFields sort = RdioSortingFields.ReleaseDate, params string[] extras) { if (string.IsNullOrEmpty(artist)) throw new ArgumentNullException("artist"); if (sort != RdioSortingFields.Name && sort != RdioSortingFields.ReleaseDate) throw new ArgumentOutOfRangeException("sort", string.Format("The {0} sorting option is not supported.", sort)); return PostAsync<IList<RdioCollectionAlbum>>("addToCollection", new Dictionary<string, string> { { "artist", artist }, { "user", user }, { "sort", sort.ToPascalCase() }, { "extras", extras.ToCommaSeparatedList() } }); }
/// <summary> /// Gets all the tracks in the user's collection.. /// </summary> /// <param name="user">The user's key or null to use the current authenticated user.</param> /// <param name="query">Filter collection's albums by the query.</param> /// <param name="start">The offset of the first result to return.</param> /// <param name="count">The maximum number of results to return.</param> /// <param name="sort">The sorting direction of the results. Only DateAdded, PlayCount, Artist, Album and Name supported.</param> /// <param name="extras">The extra fields to be included in the object.</param> /// <returns>Returns a list of <seealso cref="RdioCollectionAlbum"/> objects.</returns> public Task<IList<RdioTrack>> GetTracksInCollectionAsync(string user = null, string query = null, int start = 0, int count = 0, RdioSortingFields sort = RdioSortingFields.Name, params string[] extras) { if (sort != RdioSortingFields.DateAdded && sort != RdioSortingFields.PlayCount && sort != RdioSortingFields.Artist && sort != RdioSortingFields.Name && sort != RdioSortingFields.Album) throw new ArgumentOutOfRangeException("sort", string.Format("The {0} sorting option is not supported.", sort)); var parameters = new Dictionary<string, string> { { "user", user }, { "query", query }, { "sort", sort.ToPascalCase() }, { "extras", extras.ToCommaSeparatedList() } }; if (start > 0) parameters["start"] = start.ToString(); if (count > 0) parameters["count"] = count.ToString(); return PostAsync<IList<RdioTrack>>("getTracksInCollection", parameters); }
/// <summary> /// Gets a user's playlist. /// </summary> /// <param name="user">The user's key.</param> /// <param name="kind">The kind of playlists to be returned.</param> /// <param name="sort">The sorting direction of the results. Only Name and LastUpdated are supported.</param> /// <param name="start">The offset of the first result to return.</param> /// <param name="count">The maximum number of results to return.</param> /// <param name="extras">The extra fields to be included in the returned <seealso cref="RdioPlaylist"/>.</param> /// <returns>A list of <seealso cref="RdioPlaylist"/> objects matching the filter.</returns> public Task<IList<RdioPlaylist>> GetUserPlaylistsAsync(string user, RdioPlaylistKind kind = RdioPlaylistKind.Unknown, RdioSortingFields sort = RdioSortingFields.LastUpdated, int start = 0, int count = 0, params string[] extras) { if (string.IsNullOrEmpty(user)) throw new ArgumentNullException("user"); if (sort != RdioSortingFields.Name && sort != RdioSortingFields.LastUpdated) throw new ArgumentOutOfRangeException("sort", string.Format("The {0} sorting option is not supported.", sort)); var parameters = new Dictionary<string, string> { { "user", user }, { "sort", sort.ToPascalCase() }, { "extras", extras.ToCommaSeparatedList() } }; if (kind != RdioPlaylistKind.Unknown) parameters["kind"] = kind.ToPascalCase(); if (start > 0) parameters["start"] = start.ToString(); if (count > 0) parameters["count"] = count.ToString(); return PostAsync<IList<RdioPlaylist>>("getUserPlaylists", parameters); }