Ejemplo n.º 1
0
        public SpotifyHttpClient(ISpotifyAuthentication spotifyAuthentication, IHttpClient httpClient, ILogService logService)
        {
            _httpClient            = httpClient;
            _spotifyAuthentication = spotifyAuthentication;
            _logService            = logService;

            _mapper = new SpotifyToSpotibroModelMapper();

            // Once this class gets refactored this should move out of here
            _apiEndpoints = new Dictionary <ApiEndpointType, SpotifyEndpoint>
            {
                { ApiEndpointType.CurrentSong, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/player/currently-playing", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.PlaySong, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/player/play", HttpMethod = HttpMethod.Put
                  } },
                { ApiEndpointType.Token, new SpotifyEndpoint {
                      EndpointUrl = "https://accounts.spotify.com/api/token", HttpMethod = HttpMethod.Post
                  } },
                { ApiEndpointType.UserInformation, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.GetTopTracks, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/top/tracks", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.GetRecommendedTracks, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/recommendations", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.GetUserDevices, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/player/devices", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.SearchSpotify, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/search", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.PausePlayback, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/player/pause", HttpMethod = HttpMethod.Put
                  } },
                { ApiEndpointType.GetUserPlaylists, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/me/playlists", HttpMethod = HttpMethod.Get
                  } },
                { ApiEndpointType.GetPlaylistItems, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/playlists/{playlist_id}/tracks", HttpMethod = HttpMethod.Get,
                      Keys        = new List <string> {
                          "{playlist_id}"
                      }
                  } },
                { ApiEndpointType.ArtistInformation, new SpotifyEndpoint {
                      EndpointUrl = "https://api.spotify.com/v1/artists/{id}", HttpMethod = HttpMethod.Get,
                      Keys        = new List <string> {
                          "{id}"
                      }
                  } }, { ApiEndpointType.ArtistTopTracks, new SpotifyEndpoint {
                             EndpointUrl = "https://api.spotify.com/v1/artists/{id}/top-tracks", HttpMethod = HttpMethod.Get,
                             Keys        = new List <string> {
                                 "{id}"
                             }
                         } }
            };
        }
Ejemplo n.º 2
0
 public Spotify(
     ISpotifyAuthentication authentication,
     IHttpRequester httpRequester)
 {
     _authentication = authentication;
     _httpRequester  = httpRequester;
 }
Ejemplo n.º 3
0
 public SpotifyHttpClient(ISpotifyAuthentication spotifyAuthentication, IHttpClient httpClient, ILogService logService)
 {
     _httpClient            = httpClient;
     _spotifyAuthentication = spotifyAuthentication;
     _logService            = logService;
     _apiEndpoints          = new Dictionary <ApiEndpointType, SpotifyEndpoint>
     {
         { ApiEndpointType.CurrentSong, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/me/player/currently-playing", HttpMethod = HttpMethod.Get
           } },
         { ApiEndpointType.PlaySong, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/me/player/play", HttpMethod = HttpMethod.Put
           } },
         { ApiEndpointType.Token, new SpotifyEndpoint {
               EndpointUrl = "https://accounts.spotify.com/api/token", HttpMethod = HttpMethod.Post
           } },
         { ApiEndpointType.UserInformation, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/me", HttpMethod = HttpMethod.Get
           } },
         { ApiEndpointType.GetTopTracks, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/me/top/tracks", HttpMethod = HttpMethod.Get
           } },
         { ApiEndpointType.GetRecommendedTracks, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/recommendations", HttpMethod = HttpMethod.Get
           } },
         { ApiEndpointType.GetUserDevices, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/me/player/devices", HttpMethod = HttpMethod.Get
           } },
         { ApiEndpointType.SearchSpotify, new SpotifyEndpoint {
               EndpointUrl = "https://api.spotify.com/v1/search", HttpMethod = HttpMethod.Get
           } }
     };
 }
Ejemplo n.º 4
0
 public ApiController(
     ISpotifyAuthentication spotifyAuthentication,
     ISpotify spotify)
 {
     _spotifyAuthentication = spotifyAuthentication;
     _spotify = spotify;
 }
Ejemplo n.º 5
0
 public PartyGoerService(ISpotifyHttpClient spotifyHttpClient, IHttpContextAccessor httpContextAccessor, ISpotifyAuthentication spotifyAuthentication)
 {
     _spotifyHttpClient     = spotifyHttpClient;
     _httpContextAccessor   = httpContextAccessor;
     _spotifyAuthentication = spotifyAuthentication;
     _partyGoerCache        = new Dictionary <string, PartyGoer>();
 }
Ejemplo n.º 6
0
 public PartyGoerService(ISpotifyHttpClient spotifyHttpClient, IHttpContextAccessor httpContextAccessor,
                         ISpotifyAuthentication spotifyAuthentication, ILogService logService, ISpotifyApi spotifyApi, IUserRepository userRepository)
 {
     _spotifyHttpClient     = spotifyHttpClient;
     _httpContextAccessor   = httpContextAccessor;
     _spotifyAuthentication = spotifyAuthentication;
     _partyGoerCache        = new ConcurrentDictionary <string, PartyGoer>();
     _logService            = logService;
     _spotifyApi            = spotifyApi;
     _userRepository        = userRepository;
     _userIds    = new Dictionary <string, int>();
     _randomLock = new object();
     _random     = new Random();
 }
Ejemplo n.º 7
0
 public AuthenticationService(ISpotifyHttpClient spotifyHttpClient, ISpotifyAuthentication spotifyAuthentication)
 {
     _spotifyHttpClient     = spotifyHttpClient;
     _spotifyAuthentication = spotifyAuthentication;
 }
Ejemplo n.º 8
0
 public UserController(IPartyGoerService partyGoerService, ILogService logService, ISpotifyAuthentication spotifyAuthentication)
 {
     _partyGoerService      = partyGoerService;
     _logService            = logService;
     _spotifyAuthentication = spotifyAuthentication;
 }
Ejemplo n.º 9
0
 public AuthenticationService(ISpotifyHttpClient spotifyHttpClient, ISpotifyAuthentication spotifyAuthentication, IPartyGoerService partyGoerService)
 {
     _spotifyHttpClient     = spotifyHttpClient;
     _spotifyAuthentication = spotifyAuthentication;
     _partyGoerService      = partyGoerService;
 }