Skip to content

Commit

Permalink
merge: api 스펙 변경
Browse files Browse the repository at this point in the history
Feature/#24 api스펙 변경
  • Loading branch information
hong-sile authored Jul 22, 2024
2 parents 623d3f3 + 877cdf0 commit 96b0b39
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public class SpotifyConnector implements PlayListConnector, MusicExplorer {
private final SpotifyConfigProperty spotifyConfigProperty;

@Override
public List<PlayList> getPlayList(final String authCode) {
final String accessToken = getAccessToken(authCode);
public List<PlayList> getPlayList(final String accessToken) {
final SpotifyPlayListResponses response = spotifyApiClient.getPlayList(
CREATE_AUTH_HEADER.apply(accessToken)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface PlayListConnector {

List<PlayList> getPlayList(final String authCode);
List<PlayList> getPlayList(final String accessToken);

MusicStreaming supportedType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PlayListService {

private final PlayListConnector playListConnector;

public List<PlayList> getPlayLists(final String authCode, final String source) {
return playListConnector.getPlayList(authCode);
public List<PlayList> getPlayLists(final String accessToken, final String source) {
return playListConnector.getPlayList(accessToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package play.pluv.playlist.application.dto;

public record PlayListReadRequest(
String authCode
String accessToken
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.RestController;
import play.pluv.playlist.application.PlayListService;
import play.pluv.playlist.application.dto.PlayListOverViewResponse;
import play.pluv.playlist.application.dto.PlayListReadRequest;

@RestController
public class PlayListController {
Expand All @@ -20,9 +21,9 @@ public PlayListController(final PlayListService playListService) {

@PostMapping("/{source}/playLists/read")
public ResponseEntity<List<PlayListOverViewResponse>> readPlayLists(
@PathVariable final String source, @RequestBody final String authCode
@PathVariable final String source, @RequestBody final PlayListReadRequest request
) {
final var playLists = playListService.getPlayLists(authCode, source);
final var playLists = playListService.getPlayLists(request.accessToken(), source);
final List<PlayListOverViewResponse> response = PlayListOverViewResponse.createList(playLists);
return ResponseEntity.ok(response);
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/play/pluv/api/PlayListApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class PlayListApiTest extends ApiTest {
)
);

final PlayListReadRequest request = new PlayListReadRequest("autCode");
final PlayListReadRequest request = new PlayListReadRequest("accessToken");
final String requestBody = objectMapper.writeValueAsString(request);

when(playListService.getPlayLists(any(), any())).thenReturn(playLists);
Expand All @@ -55,7 +55,8 @@ public class PlayListApiTest extends ApiTest {
parameterWithName("source").description("플레이리스트 제공자(spotify, apple, youtube)")
),
requestFields(
fieldWithPath("authCode").type(STRING).description("플레이리스트 제공자의 oauth authCode")
fieldWithPath("accessToken").type(STRING)
.description("플레이리스트 제공자의 oauth accessToken")
),
responseFields(
fieldWithPath("[]").type(ARRAY).description("플레이리스트 전체"),
Expand Down

0 comments on commit 96b0b39

Please sign in to comment.