public async Task <IEnumerable <ISpotifyQueryResult> > QuerySpotifyAsync(PartyGoer user, string searchQuery, SpotifyQueryType queryType, int limit)
        {
            try
            {
                switch (queryType)
                {
                case SpotifyQueryType.Track:
                    return(await QuerySpotifyForTrackAsync(user, searchQuery, limit));

                case SpotifyQueryType.Artist:
                    return(await QuerySpotifyForArtistAsync(user, searchQuery, limit));

                case SpotifyQueryType.Album:
                    return(await QuerySpotifyForAlbumAsync(user, searchQuery, limit));

                case SpotifyQueryType.Playlist:
                //return await QuerySpotifyForPlaylistAsync(user, searchQuery, limit);
                case SpotifyQueryType.All:
                //return await QuerySpotifyAsync<T>(user, searchQuery);
                default:
                    throw new ArgumentException($"Argument SpotifyQuertyType of {queryType} not handled");
                }
            }
            catch (Exception ex)
            {
                // TODO: Add custom exception to catch in clients to know that there was a problem with Spotifys API
                throw new Exception($"Error occurred while trying to query Spotify with query {searchQuery}", ex);
            }
        }
Beispiel #2
0
 public async Task <IEnumerable <ISpotifyQueryResult> > SearchSpotifyAsync(string query, SpotifyQueryType queryType, int limit = 10)
 {
     return(await _spotifyHttpClient.QuerySpotifyAsync(await GetCurrentPartyGoerAsync(), query, queryType, limit));
 }