public void PrepareEnvironment()
        {
            // Inicializa tabela de cashback
            _cashbackService.InitializeCashbackDatabase();

            // incializa classe de serviços
            spotifyService = _factory.GetSpotifyService();

            // recupera valores do arquivo appsettings.json para requisitar token
            tokenRequest = _factory.GetSpotifyTokenRequest();

            // recupera o token através da API do Spotify
            string access_token = spotifyService.GetToken(tokenRequest).Result;

            // obtém lista de álbuns da API do Spotify
            List <Album> list = spotifyService.GetAlbums(access_token);

            // insere dados no BD
            _albumService.AddAlbumsToDatabase(list);
        }
Example #2
0
        private async Task <CityTracks> tracksFromTemp(double temperature)
        {
            var token = await Spotify.GetToken(Config.Value.spotify_id, Config.Value.spotify_secret);

            var ret = new CityTracks
            {
                Temperature = temperature
            };

            if (temperature > 30)
            {
                ret.Tracks = await Spotify.GetPartyTracks(token.AccessToken);

                ret.Type = "Party";
            }
            else if (temperature >= 15 && temperature <= 30)
            {
                ret.Tracks = await Spotify.GetPopTracks(token.AccessToken);

                ret.Type = "Pop";
            }
            else if (temperature >= 10 && temperature <= 14)
            {
                ret.Tracks = await Spotify.GetRockTracks(token.AccessToken);

                ret.Type = "Rock";
            }
            else
            {
                ret.Tracks = await Spotify.GetClassicalTracks(token.AccessToken);

                ret.Type = "Clasical";
            }

            return(ret);
        }