Пример #1
0
        public Task <bool> AddArtistToFavourite(ulong artistId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("artist_id", artistId),
            };

            return(Client.Post("user/me/artists", parms, DeezerPermissions.ManageLibrary));
        }
Пример #2
0
        public Task <bool> RemoveAlbumFromFavourite(ulong albumId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("album_id", albumId),
            };

            return(Client.Delete("user/me/albums", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
Пример #3
0
        public Task <bool> AddTrackToFavourite(ulong trackId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("track_id", trackId),
            };

            return(Client.Post("user/me/tracks", parms, DeezerPermissions.ManageLibrary));
        }
Пример #4
0
        public Task <bool> RemovePlaylistFromFavourite(ulong playlistId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("playlist_id", playlistId),
            };

            return(Client.Delete("user/me/playlists", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
Пример #5
0
        public Task <bool> AddRadioToFavourite(ulong radioId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("radio_id", radioId),
            };

            return(Client.Post("user/me/radios", parms, DeezerPermissions.ManageLibrary));
        }
Пример #6
0
        public void GetNewQueryStringParameter()
        {
            var actual = RequestParameter.GetNewQueryStringParameter("address", new { number = 2 });

            Assert.IsNotNull(actual);
            Assert.AreEqual("address", actual.Id, "Id");
            Assert.AreEqual(new { number = 2 }, actual.Value, "Value");
            Assert.AreEqual(ParameterType.QueryString, actual.Type, "Type");
        }
Пример #7
0
        public Task <bool> AddToPlaylist(uint playlistId, string songids)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("playlist_id", playlistId),
                RequestParameter.GetNewQueryStringParameter("songs", songids)
            };

            return(Client.Post("playlist/{playlist_id}/tracks", parms, DeezerPermissions.ManageLibrary));
        }
Пример #8
0
        public Task <uint> CreatePlaylist(string title)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", Id),
                RequestParameter.GetNewQueryStringParameter("title", title)
            };

            return(Client.PostForCreate("user/{id}/playlists", parms, DeezerPermissions.ManageLibrary).ContinueWith(t => t.Result.Id));
        }
Пример #9
0
        public Task <bool> RemoveTracks(string aTrackIds)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("playlist_id", Id),
                RequestParameter.GetNewQueryStringParameter("songs", aTrackIds)
            };

            return(Client.Delete("playlist/{playlist_id}/tracks", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
Пример #10
0
        public void TestParamsFilledQueryString()
        {
            string url = "test.com/charts";
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("id", "something"),
            };

            string trueurl = executor.BuildUrl(url, parms);

            Assert.NotNull(trueurl);
            Assert.AreEqual("test.com/charts?id=something&output=json", trueurl);
        }
Пример #11
0
        private Task <IEnumerable <TDest> > Get <TSource, TDest>(string aSearchEndpoint, string aQuery, uint aStart, uint aCount) where TSource : TDest, IDeserializable <DeezerClient>
        {
            string method = string.Format("{0}{1}", SEARCH_BASE, aSearchEndpoint);

            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("q", aQuery)
            };

            return(iClient.Get <TSource>(method, parms, aStart, aCount).ContinueWith <IEnumerable <TDest> >((aTask) =>
            {
                return iClient.Transform <TSource, TDest>(aTask.Result);
            }, iClient.CancellationToken, TaskContinuationOptions.NotOnCanceled, TaskScheduler.Default));
        }
Пример #12
0
        public Task <bool> Rate(int aRating)
        {
            if (aRating < 1 || aRating > 5)
            {
                throw new ArgumentOutOfRangeException("aRating", "Rating value should be between 1 and 5 (inclusive)");
            }

            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", Id),
                RequestParameter.GetNewQueryStringParameter("note", aRating)
            };

            return(Client.Post("playlist/{id}", parms, DeezerPermissions.BasicAccess));
        }
Пример #13
0
        public Task <bool> AddComment(string commentText)
        {
            if (string.IsNullOrEmpty(commentText))
            {
                throw new ArgumentException("A comment is required.");
            }

            List <IRequestParameter> p = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", this.Id),
                RequestParameter.GetNewQueryStringParameter("comment", commentText),
            };

            return(Client.Post("artist/{id}/comments", p, DeezerPermissions.BasicAccess));
        }