|
19 | 19 | import Controller.PlayerController.CurrentTrack.baseCurrentTrack; |
20 | 20 | import Controller.PlayerController.Devices.basePlayerDevice; |
21 | 21 | import Controller.PlayerController.baseUserPlayback; |
| 22 | +import Controller.PlaylistController.CoverImage; |
22 | 23 | import Controller.PlaylistController.Playlist; |
23 | 24 | import Controller.PlaylistController.PlaylistItems.BasePlaylistItems; |
24 | 25 | import Controller.PlaylistController.SnapshotId; |
@@ -63,23 +64,6 @@ public String getTokenString(String token){ |
63 | 64 | } |
64 | 65 |
|
65 | 66 |
|
66 | | - public void makeRequest(String requestType){ |
67 | | - |
68 | | - if(requestType.toLowerCase(Locale.ENGLISH).equals("get")){ |
69 | | - // make get request |
70 | | - } |
71 | | - else if(requestType.toLowerCase(Locale.ENGLISH).equals("post")){ |
72 | | - // make post request |
73 | | - } |
74 | | - else if(requestType.toLowerCase(Locale.ENGLISH).equals("put")){ |
75 | | - // make put request |
76 | | - } |
77 | | - else{ |
78 | | - // make delete request |
79 | | - } |
80 | | - |
81 | | - } |
82 | | - |
83 | 67 | /* |
84 | 68 |
|
85 | 69 | Authorization Method <--- generates token that expires |
@@ -1448,6 +1432,65 @@ public SnapshotId reorderOrReplacePlaylistItems(SpotifyClient client) throws IOE |
1448 | 1432 |
|
1449 | 1433 | } |
1450 | 1434 |
|
| 1435 | + public SnapshotId removePlaylistItems(SpotifyClient client) throws IOException { |
| 1436 | + |
| 1437 | + String url = baseUrl + String.format("/v1/playlists/%s/tracks/",client.getPlaylist().getPlaylistId()); |
| 1438 | + |
| 1439 | + Retrofit retrofit = new Retrofit.Builder() |
| 1440 | + .baseUrl(url) |
| 1441 | + .addConverterFactory(GsonConverterFactory.create()) |
| 1442 | + .build(); |
| 1443 | + |
| 1444 | + playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class); |
| 1445 | + |
| 1446 | + Call<SnapshotId> call = playlistInterface.removeItemsFromPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId(),client.getTrackIds().convertTrackIds()); |
| 1447 | + |
| 1448 | + Response<SnapshotId> response = call.execute(); |
| 1449 | + |
| 1450 | + return response.body(); |
| 1451 | + |
| 1452 | + } |
| 1453 | + |
| 1454 | + public CoverImage getPlaylistCoverImage(SpotifyClient client) throws IOException { |
| 1455 | + |
| 1456 | + String url = baseUrl + String.format("/v1/playlists/%s/images/",client.getPlaylist().getPlaylistId()); |
| 1457 | + |
| 1458 | + Retrofit retrofit = new Retrofit.Builder() |
| 1459 | + .baseUrl(url) |
| 1460 | + .addConverterFactory(GsonConverterFactory.create()) |
| 1461 | + .build(); |
| 1462 | + |
| 1463 | + playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class); |
| 1464 | + |
| 1465 | + Call<CoverImage> call = playlistInterface.getPlaylistCoverImage(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId()); |
| 1466 | + |
| 1467 | + Response<CoverImage> response = call.execute(); |
| 1468 | + |
| 1469 | + return response.body(); |
| 1470 | + |
| 1471 | + } |
| 1472 | + |
| 1473 | + public boolean uploadCustomPlaylistImage(SpotifyClient client) throws IOException { |
| 1474 | + |
| 1475 | + String url = baseUrl + String.format("/v1/playlists/%s/images/",client.getPlaylist().getPlaylistId()); |
| 1476 | + |
| 1477 | + Retrofit retrofit = new Retrofit.Builder() |
| 1478 | + .baseUrl(url) |
| 1479 | + .addConverterFactory(GsonConverterFactory.create()) |
| 1480 | + .build(); |
| 1481 | + |
| 1482 | + playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class); |
| 1483 | + |
| 1484 | + Call<Object> call = playlistInterface.uploadPlaylistCoverImage(getTokenString(client.getToken()),client.getContentType(),client.getPlaylist().getPlaylistId()); |
| 1485 | + |
| 1486 | + Response<Object> response = call.execute(); |
| 1487 | + |
| 1488 | + return response.isSuccessful(); |
| 1489 | + |
| 1490 | + |
| 1491 | + |
| 1492 | + } |
| 1493 | + |
1451 | 1494 |
|
1452 | 1495 |
|
1453 | 1496 |
|
|
0 commit comments