public ITracksSearcher BeginSearch(SCFilter filter, bool useNewApi = true) { Func <Dictionary <string, object>, SCTrack[]> search; if (useNewApi) { search = parameters => { var tracks = soundCloudRawClient.Request <TrackCollection>(searchPrefix, searchCommand, HttpMethod.Get, parameters, responseType: string.Empty, domain: Internal.Client.Helpers.Domain.ApiV2); return(tracks.Tracks.Select(trackConverter.Convert).ToArray()); }; } else { search = parameters => { var tracks = soundCloudRawClient.Request <Track[]>(prefix, string.Empty, HttpMethod.Get, parameters); return(tracks.Select(trackConverter.Convert).ToArray()); }; } return(new TracksSearcher(filter, useNewApi, paginationValidator, search)); }
public SCAccessToken AuthorizeByPassword(string userName, string password) { var credentials = soundCloudRawClient.Credentials; var accessToken = soundCloudRawClient.Request <AccessToken>(prefix, "token", HttpMethod.Post, new Dictionary <string, object> { { "client_id", credentials.ClientId }, { "client_secret", credentials.ClientSecret }, { "grant_type", "password" }, { "username", userName }, { "password", password } }, null, string.Empty); return(accessTokenConverter.Convert(accessToken)); }
private T ResolveUrl <T>(string url) where T : class { return(soundCloudRawClient.Request <T>(prefix, string.Empty, HttpMethod.Get, parameters: new Dictionary <string, object> { { "url", url } })); }
internal static TCollection GetCollectionBatch <TCollection, TResponse>( this ISoundCloudRawClient soundCloudRawClient, IPaginationValidator paginationValidator, string prefix, string command, int offset, int limit) where TCollection : class, IEntityCollection <TResponse> { paginationValidator.Validate(offset, limit); return(soundCloudRawClient.Request <TCollection>(prefix, command, HttpMethod.Get, new Dictionary <string, object>().SetPagination(offset, limit))); }
public Func <Dictionary <string, object>, Track[]> BuildGetter(ISoundCloudRawClient soundCloudRawClient) { return(parameters => { var tracks = soundCloudRawClient.Request <TrackCollection>(prefix, command, HttpMethod.Get, parameters, responseType: string.Empty, domain: Domain.ApiV2); return tracks.Collection; }); }
public SCUser UpdateUser(SCUser user) { if (!string.IsNullOrEmpty(userId) && user.Id != userId) { throw new SoundCloudApiException(string.Format("Context set for userId = {0}. Create new context for update another user.", userId)); } var currentUser = GetInternalUser(); var diff = currentUser.GetDiff(userConverter.Convert(user)); var parameters = diff.ToDictionary(x => string.Format("user[{0}]", x.Key), x => x.Value); var updatedUser = soundCloudRawClient.Request <User>(prefix, string.Empty, HttpMethod.Put, parameters); return(userConverter.Convert(updatedUser)); }
public ITracksSearcher BeginSearch(SCFilter filter) { return(new TracksSearcher(filter, paginationValidator, parameters => { var tracks = soundCloudRawClient.Request <Track[]>(prefix, string.Empty, HttpMethod.Get, parameters); return tracks.Select(trackConverter.Convert).ToArray(); })); }
public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10) { paginationValidator.Validate(offset, limit); var parameters = new Dictionary <string, object>(); var tracks = soundCloudRawClient.Request <ExploreTrackCollection>(prefix, category.GetName(), HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty); return(tracks.Collection.Select(trackConverter.Convert).ToArray()); }
public void UpdateTrack(SCTrack track) { if (track.Id != trackId) { throw new SoundCloudApiException(string.Format("Context set for trackId = {0}. Create new context for update another track.", trackId)); } var currentTrack = GetInternalTrack(); var diff = currentTrack.GetDiff(trackConverter.Convert(track)); soundCloudRawClient.Request(prefix, string.Empty, HttpMethod.Put, diff.ToDictionary(x => string.Format("track[{0}]", x.Key), x => x.Value)); }
public SCGroup[] Search(string query, int offset = 0, int limit = 50) { paginationValidator.Validate(offset, limit); var parameters = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(query)) { parameters.Add("q", query); } var groups = soundCloudRawClient.Request <Group[]>(prefix, string.Empty, HttpMethod.Get, parameters.SetPagination(offset, limit)); return(groups.Select(groupConverter.Convert).ToArray()); }
public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10) { paginationValidator.Validate(offset, limit); var parameters = new Dictionary <string, object>(); parameters.Add("kind", "top"); //Build genre paramter var processed = (category == null || category.Name == "Popular+Music") ? "all-music" : new String(System.Uri.UnescapeDataString(category.Name).Where(ch => Char.IsLetterOrDigit(ch)).ToArray()).ToLower(); var g = string.Format("soundcloud%3Agenres%3A{0}", processed); parameters.Add("genre", g); parameters.Add("linked_partitioning", 1); var tracks = soundCloudRawClient.Request <ChartTrackList>(prefix, command, HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty); return(tracks.Tracks.Select(ct => trackConverter.Convert(ct.Track)).ToArray()); }
public SCTrack[] GetTracks(SCExploreCategory category, int offset = 0, int limit = 10) { paginationValidator.Validate(offset, limit); var parameters = new Dictionary <string, object> { { "kind", "top" } }; var categoryName = category.GetName(); var processed = categoryName == null || categoryName == "Popular+Music" ? "all-music" : new string(Uri.UnescapeDataString(categoryName).Where(char.IsLetterOrDigit).ToArray()).ToLower(); var genreFormatQuery = $"soundcloud%3Agenres%3A{processed}"; parameters.Add("genre", genreFormatQuery); parameters.Add("linked_partitioning", 1); var tracks = soundCloudRawClient.Request <ChartTrackCollection>(prefix, command, HttpMethod.Get, parameters: parameters.SetPagination(offset, limit), domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty); return(tracks.Collection.Select(ct => trackConverter.Convert(ct.Track)).ToArray()); }
public SCExploreCategory[] GetExploreCategories() { var categories = soundCloudRawClient.Request <ExploreCategoryList>(prefix, categoryCommand, HttpMethod.Get, domain: Internal.Client.Helpers.Domain.ApiV2, responseType: string.Empty); return(exploreCategoryConverter.Convert(categories)); }
public SCApplication GetApplication() { var application = soundCloudRawClient.Request <Application>(prefix, string.Empty, HttpMethod.Get); return(applicationConverter.Convert(application)); }
public SCGroup GetGroup() { var @group = soundCloudRawClient.Request <Group>(prefix, string.Empty, HttpMethod.Get); return(groupConverter.Convert(@group)); }
public SCComment GetComment() { var comment = soundCloudRawClient.Request <Comment>(prefix, string.Empty, HttpMethod.Get); return(commentConverter.Convert(comment)); }
public Func <Dictionary <string, object>, Track[]> BuildGetter(ISoundCloudRawClient soundCloudRawClient) { return(parameters => soundCloudRawClient.Request <Track[]>(prefix, string.Empty, HttpMethod.Get, parameters)); }
public SCPlaylist GetPlaylist() { var playlist = soundCloudRawClient.Request <Playlist>(prefix, string.Empty, HttpMethod.Get); return(playlistConverter.Convert(playlist)); }
public IOEmbedQuery BeginQuery(string url) { return(new OEmbedQuery(url, p => soundCloudRawClient.Request <SCOEmbed>(prefix, string.Empty, HttpMethod.Get, parameters: p, responseType: null, domain: Domain.Direct), p => soundCloudRawClient.Request <string>(prefix, string.Empty, HttpMethod.Get, parameters: p, responseType: null, domain: Domain.Direct))); }