package cc.fascinated.bat.controller; import cc.fascinated.bat.service.SpotifyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** * @author Fascinated (fascinated7) */ @RestController @RequestMapping(value = "/spotify") public class SpotifyController { private final SpotifyService spotifyService; @Autowired public SpotifyController(SpotifyService spotifyService) { this.spotifyService = spotifyService; } /** * A GET request to authorize the user with Spotify. * * @return the response entity */ @GetMapping(value = "/callback") public ResponseEntity authorizationCallback(@RequestParam(required = false) String code) { return ResponseEntity.ok(spotifyService.authorize(code)); } }