|
21 | 21 | import Controller.PlayerController.baseUserPlayback; |
22 | 22 | import Controller.PlaylistController.Playlist; |
23 | 23 | import Controller.PlaylistController.PlaylistItems.BasePlaylistItems; |
| 24 | +import Controller.PlaylistController.SnapshotId; |
24 | 25 | import Model.*; |
| 26 | +import com.google.gson.internal.GsonBuildConfig; |
25 | 27 | import getRequests.AlbumInterface; |
26 | 28 |
|
27 | 29 | import retrofit2.Call; |
@@ -1408,6 +1410,44 @@ public BasePlaylistItems getPlaylistItems(SpotifyClient client) throws IOExcepti |
1408 | 1410 |
|
1409 | 1411 | } |
1410 | 1412 |
|
| 1413 | + public SnapshotId addItemsToPlaylist(SpotifyClient client) throws IOException { |
| 1414 | + |
| 1415 | + String url = baseUrl + String.format("/v1/playlists/%s/tracks/",client.getPlaylist().getPlaylistId()); |
| 1416 | + |
| 1417 | + Retrofit retrofit = new Retrofit.Builder() |
| 1418 | + .baseUrl(url) |
| 1419 | + .addConverterFactory(GsonConverterFactory.create()) |
| 1420 | + .build(); |
| 1421 | + |
| 1422 | + playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class); |
| 1423 | + |
| 1424 | + Call<SnapshotId> call = playlistInterface.addItemsToPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId()); |
| 1425 | + |
| 1426 | + Response<SnapshotId> response = call.execute(); |
| 1427 | + |
| 1428 | + return response.body(); |
| 1429 | + |
| 1430 | + } |
| 1431 | + |
| 1432 | + public SnapshotId reorderOrReplacePlaylistItems(SpotifyClient client) throws IOException { |
| 1433 | + |
| 1434 | + String url = baseUrl + String.format("/v1/playlists/%s/tracks/",client.getPlaylist().getPlaylistId()); |
| 1435 | + |
| 1436 | + Retrofit retrofit = new Retrofit.Builder() |
| 1437 | + .baseUrl(url) |
| 1438 | + .addConverterFactory(GsonConverterFactory.create()) |
| 1439 | + .build(); |
| 1440 | + |
| 1441 | + playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class); |
| 1442 | + |
| 1443 | + Call<SnapshotId> call = playlistInterface.reorderOrReplacePlaylistsItems(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId()); |
| 1444 | + |
| 1445 | + Response<SnapshotId> response = call.execute(); |
| 1446 | + |
| 1447 | + return response.body(); |
| 1448 | + |
| 1449 | + } |
| 1450 | + |
1411 | 1451 |
|
1412 | 1452 |
|
1413 | 1453 |
|
|
0 commit comments