Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#24 api스펙 변경 #25

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading