Esempio n. 1
0
        public Task <SoundCloudList <Track> > GetAllAsync(TrackQueryBuilder builder)
        {
            builder.Path  = TrackPath;
            builder.Paged = true;

            return(GetPage <Track>(builder.BuildUri()));
        }
Esempio n. 2
0
        public async Task <Track> GetAsync(long trackId)
        {
            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackByIdPath, trackId)
            };

            return(await Gateway.SendGetRequestAsync <Track>(builder.BuildUri()));
        }
        public void Test_Default()
        {
            var builder = new TrackQueryBuilder();

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?"));
        }
Esempio n. 4
0
        public async Task <SecretToken> GetSecretTokenAsync(Track track)
        {
            track.ValidateGet();

            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackSecretTokenPath, track.Id)
            };

            return(await Gateway.SendGetRequestAsync <SecretToken>(builder.BuildUri()));
        }
Esempio n. 5
0
        public Task <SoundCloudList <User> > GetFavoritersAsync(Track track, int limit = SoundCloudQueryBuilder.MaxLimit)
        {
            track.ValidateGet();

            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackFavoritersPath, track.Id), Paged = true, Limit = limit
            };

            return(GetPage <User>(builder.BuildUri()));
        }
Esempio n. 6
0
        public Track Get(int trackId)
        {
            EnsureClientId();

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackByIdPath, trackId);

            return(GetById <Track>(builder.BuildUri()));
        }
Esempio n. 7
0
        public async Task <StatusResponse> DeleteAsync(Track track)
        {
            track.ValidateDelete();

            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackByIdPath, track.Id)
            };

            return(await Gateway.SendDeleteRequestAsync <StatusResponse>(builder.BuildUri()));
        }
        public void Test_SearchString()
        {
            var builder = new TrackQueryBuilder();

            builder.SearchString = "major lazer";

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?q=major lazer"));
        }
Esempio n. 9
0
        public async Task <Track> UpdateAsync(Track track)
        {
            track.ValidateUpdate();

            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackByIdPath, track.Id)
            };

            return(await Gateway.SendPutRequestAsync <Track>(builder.BuildUri(), track));
        }
        public void Test_Sharing()
        {
            var builder = new TrackQueryBuilder();

            builder.Sharing = Sharing.Private;

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?filter=private"));
        }
Esempio n. 11
0
        public async Task <Track> GetAsync(int trackId)
        {
            EnsureClientId();

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackByIdPath, trackId);

            return(await GetByIdAsync <Track>(builder.BuildUri()));
        }
        public void Test_License()
        {
            var builder = new TrackQueryBuilder();

            builder.License = License.CcBy;

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?license=cc-by"));
        }
        public void Test_Duration()
        {
            var builder = new TrackQueryBuilder();

            builder.DurationFrom = 100;
            builder.DurationTo   = 200;

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?duration[from]=100&duration[to]=200"));
        }
Esempio n. 14
0
        public SecretToken GetSecretToken(Track track)
        {
            EnsureToken();
            Validate(track.ValidateGet);

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackSecretTokenPath, track.id);

            return(GetById <SecretToken>(builder.BuildUri()));
        }
Esempio n. 15
0
        public async Task <SecretToken> GetSecretTokenAsync(Track track)
        {
            EnsureToken();
            Validate(track.ValidateGet);

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackSecretTokenPath, track.id);

            return(await GetByIdAsync <SecretToken>(builder.BuildUri()));
        }
        public void Test_Bpm()
        {
            var builder = new TrackQueryBuilder();

            builder.BpmFrom = 100;
            builder.BpmTo   = 120;

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?bpm[from]=100&bpm[to]=120"));
        }
Esempio n. 17
0
        public async Task <IWebResult> DeleteAsync(Track track)
        {
            EnsureToken();
            Validate(track.ValidateDelete);

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackByIdPath, track.id);

            return(await DeleteAsync(builder.BuildUri()));
        }
Esempio n. 18
0
        public IWebResult <Track> Update(Track track)
        {
            EnsureToken();
            Validate(track.ValidateUpdate);

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackByIdPath, track.id);

            return(Update <Track>(builder.BuildUri(), track));
        }
Esempio n. 19
0
        public void Test_CreatedFromTo()
        {
            var builder = new TrackQueryBuilder();

            builder.CreatedAtFrom = new DateTime(2015, 01, 02, 03, 04, 05);
            builder.CreatedAtTo   = new DateTime(2015, 06, 07, 08, 09, 10);

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?created_at[from]=2015-01-02 03:04:05&created_at[to]=2015-06-07 08:09:10"));
        }
Esempio n. 20
0
        public IEnumerable <User> GetFavoriters(Track track)
        {
            EnsureClientId();
            Validate(track.ValidateGet);

            var builder = new TrackQueryBuilder();

            builder.Path  = string.Format(TrackFavoritersPath, track.id);
            builder.Paged = true;

            return(GetList <User>(builder.BuildUri()));
        }
        public void Test_TrackTypes()
        {
            var builder = new TrackQueryBuilder();

            builder.TrackTypes.Add(TrackType.Demo);
            builder.TrackTypes.Add(TrackType.InProgress);
            builder.TrackTypes.Add(TrackType.Live);

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?types=demo%2Cin progress%2Clive"));
        }
Esempio n. 22
0
        public async Task <IEnumerable <Comment> > GetCommentsAsync(Track track)
        {
            EnsureClientId();
            Validate(track.ValidateGet);

            var builder = new TrackQueryBuilder();

            builder.Path  = string.Format(TrackCommentsPath, track.id);
            builder.Paged = true;

            return(await GetListAsync <Comment>(builder.BuildUri()));
        }
        public void Test_Genres()
        {
            var builder = new TrackQueryBuilder();

            builder.Genres.Add("pop");
            builder.Genres.Add("rap");
            builder.Genres.Add("house");

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?genres=pop%2Crap%2Chouse"));
        }
        public void Test_Ids()
        {
            var builder = new TrackQueryBuilder();

            builder.Ids.Add(1);
            builder.Ids.Add(2);
            builder.Ids.Add(3);

            var query = builder.BuildUri();

            Assert.That(query.ToString(), Is.EqualTo("https://api.soundcloud.com/?ids=1%2C2%2C3"));
        }
Esempio n. 25
0
        public async Task <Track> UploadArtworkAsync(Track track, Stream file)
        {
            track.ValidateUploadArtwork();

            var parameters = new Dictionary <string, object> {
                { TrackArtworkDataKey, file }
            };
            var builder = new TrackQueryBuilder {
                Path = string.Format(TrackByIdPath, track.Id)
            };

            return(await Gateway.SendPutRequestAsync <Track>(builder.BuildUri(), parameters));
        }
Esempio n. 26
0
        public async Task <IWebResult <Track> > UploadArtworkAsync(Track track, Stream file)
        {
            EnsureToken();
            Validate(track.ValidateUploadArtwork);

            var parameters = new Dictionary <string, object>();

            parameters.Add(TrackArtworkDataKey, file);

            var builder = new TrackQueryBuilder();

            builder.Path = string.Format(TrackByIdPath, track.id);

            return(await UpdateAsync <Track>(builder.BuildUri(), parameters));
        }
Esempio n. 27
0
        public async Task <Track> UploadTrackAsync(string title, Stream file)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new SoundCloudValidationException("Title must not be empty.");
            }

            var parameters = new Dictionary <string, object> {
                { "track[title]", title }, { "track[asset_data]", file }
            };

            var builder = new TrackQueryBuilder {
                Path = TrackPath
            };

            return(await Gateway.SendPostRequestAsync <Track>(builder.BuildUri(), parameters));
        }
Esempio n. 28
0
        public async Task <IWebResult <Track> > UploadTrackAsync(string title, Stream file)
        {
            EnsureToken();

            if (string.IsNullOrEmpty(title))
            {
                throw new SoundCloudValidationException("Title must not be empty.");
            }

            var parameters = new Dictionary <string, object>();

            parameters.Add("oauth_token", Credentials.AccessToken);
            parameters.Add("track[title]", title);
            parameters.Add("track[asset_data]", file);

            var builder = new TrackQueryBuilder();

            builder.Path = TrackPath;

            return(await CreateAsync <Track>(builder.BuildUri(), parameters));
        }