Пример #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}"
                             }
                         } }
            };
        }
Пример #2
0
 public PlaylistEndpoint(ISpotifyHttpClient spotifyHttpClient, ILogService logService, Dictionary <ApiEndpointType, SpotifyEndpoint> apiEndpoints)
 {
     _spotifyHttpClient = spotifyHttpClient;
     _logService        = logService;
     _mapper            = new SpotifyToSpotibroModelMapper();
     _apiEndpoints      = apiEndpoints;
 }