/// <summary>
        ///     You can retrieve a user's playlist subscriptions.
        /// </summary>
        /// <param name="userId">The unique ID for the user.</param>
        /// <param name="offset">A zero-based integer offset into the results. Default 0.</param>
        /// <param name="orderBy">Indicates how the results set should be ordered. The default value is Name Ascending</param>
        /// <returns></returns>
        public async Task<MultipleRootObject<PlaylistData>> GetAllUserPlaylistsSubscriptions(string userId,
            int offset = 0,
            PlaylistsOrderBy orderBy =
                PlaylistsOrderBy
                    .NameAscending)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(userId), "userId field is null");
            Contract.Requires<ArgumentOutOfRangeException>(offset >= 0, "offset is set to less then zero");

            var methodParams = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("offset", offset.ToString()),
            };
            methodParams = AddOrderByParam<PlaylistsOrderBy>(orderBy, methodParams);

            return
                await
                    BeatsMusicManager.GetMultipleParsedResult<PlaylistData>(
                        string.Format("users/{0}/playlist_subscriptions", userId), methodParams, true);
        }
        /// <summary>
        ///     You can retrieve a user's playlist collection. If the playlists are not public, they must be owned by the user
        ///     identified by the access token.
        /// </summary>
        /// <param name="userId">The unique ID for the user.</param>
        /// <param name="offset">A zero-based integer offset into the results. Default 0.</param>
        /// <param name="limit">
        ///     Specifies the maximum number of records to retrieve. The number of results returned will be less
        ///     than or equal to this value. No results are returned if it is set to zero or less. The maximum permitted value is
        ///     200. If a value higher than 200 is specified, no more 200 results will be returned. Default 20.
        /// </param>
        /// <param name="orderBy">
        ///     Indicates how the results set should be sorted. The default value is order alphabetically by
        ///     name.
        /// </param>
        /// <returns></returns>
        public async Task<MultipleRootObject<PlaylistData>> GetPlaylistsByUser(string userId, int offset = 0,
            int limit = 20,
            PlaylistsOrderBy orderBy = PlaylistsOrderBy.NameAscending)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(userId), "userId field is null");
            ValidateIdOffsetLimit(offset, limit);
            var methodParams = new List<KeyValuePair<string, string>>();
            methodParams = AddOffsetAndLimitParams(methodParams, offset, limit);
            methodParams = AddOrderByParam<PlaylistsOrderBy>(orderBy, methodParams);

            return
                await
                    BeatsMusicManager.GetMultipleParsedResult<PlaylistData>("users/" + userId + "/playlists/",
                        methodParams, true);
        }
        /// <summary>
        /// You can get a list of playlists associated with an artist.
        /// </summary>
        /// <param name="artistId">The unique ID for the artist.</param>
        /// <param name="offset">A zero-based integer offset into the results. Default 0.</param>
        /// <param name="limit">Specifies the maximum number of records to retrieve. The number of results returned will be less than or equal to this value. No results are returned if it is set to zero or less. The maximum permitted value is 200. If a value higher than 200 is specified, no more 200 results will be returned. Default 20.</param>
        /// <param name="playlistsOrderBy">Indicates how the results set should be sorted. </param>
        /// <returns></returns>
        public async Task<MultipleRootObject<PlaylistData>> GetPlaylistsByArtist(string artistId, int offset = 0,
            int limit = 20, PlaylistsOrderBy playlistsOrderBy = PlaylistsOrderBy.NameAscending)
        {
            var dataParams = new List<KeyValuePair<string, string>>();
            dataParams = AddOffsetAndLimitParams(dataParams, offset, limit);
            dataParams = AddOrderByParam<PlaylistsOrderBy>(playlistsOrderBy, dataParams);

            return
                await
                    BeatsMusicManager.GetMultipleParsedResult<PlaylistData>(
                        string.Format("artists/{0}/playlists", artistId), dataParams);
        }
        /// <summary>
        ///     You can retrieve the specified public playlists in Beats, as well as any private playlists belonging to the user
        ///     represented by the access token.
        /// </summary>
        /// <param name="playlistIds">An array of playlist IDs.</param>
        /// <param name="offset">A zero-based integer offset into the results. Default 0.</param>
        /// <param name="limit">
        ///     Specifies the maximum number of records to retrieve. The number of results returned will be less
        ///     than or equal to this value. No results are returned if it is set to zero or less. The maximum permitted value is
        ///     200. If a value higher than 200 is specified, no more 200 results will be returned. Default 20.
        /// </param>
        /// <param name="playlistsOrderBy">
        ///     Indicates how the results set should be ordered. Default is order alphabetically by
        ///     name.
        /// </param>
        /// <returns></returns>
        public async Task<MultipleRootObject<PlaylistData>> GetMultiplePlaylists(string[] playlistIds, int offset = 0,
            int limit = 20,
            PlaylistsOrderBy playlistsOrderBy =
                PlaylistsOrderBy.NameAscending)
        {
            Contract.Requires<ArgumentNullException>(playlistIds != null, "playlistIds array is null");

            ValidateIdOffsetLimit(offset, limit);
            var methodParams = new List<KeyValuePair<string, string>>();
            methodParams.AddRange(playlistIds.Select(playlistId => new KeyValuePair<string, string>("ids", playlistId)));
            methodParams = AddOffsetAndLimitParams(methodParams, offset, limit);
            methodParams = AddOrderByParam<PlaylistsOrderBy>(playlistsOrderBy, methodParams);

            return await BeatsMusicManager.GetMultipleParsedResult<PlaylistData>("playlists", methodParams, true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a list of playlists associated to the genre. 
        /// </summary>
        /// <param name="genreId">Unique ID for Genre</param>
        /// <param name="limit">Specifies the maximum number of records to retrieve. The number of results returned will be less than or equal to this value. No results are returned if it is set to zero or less. The maximum permitted value is 200. If a value higher than 200 is specified, no more 200 results will be returned. Default 20.</param>
        /// <param name="offset">A zero-based integer offset into the results. Default 0.</param>
        /// <param name="orderBy">A zero-based integer offset into the results. Default 0.</param>
        /// <returns></returns>
        public async Task<MultipleRootObject<PlaylistData>> GetAllPlaylistsInGenre(string genreId, int limit = 20,
            int offset = 0, PlaylistsOrderBy orderBy = PlaylistsOrderBy.NameAscending)
        {
            var methodParams = ValidateAndCreateLimitOffsetParams(limit, offset);
            methodParams = base.AddOrderByParam<PlaylistsOrderBy>(orderBy, methodParams);

            return
                await
                    BeatsMusicManager.GetMultipleParsedResult<PlaylistData>(string.Format("genres/{0}/playlists", genreId),
                        methodParams);
        }