Skip to content

Commit ee271b6

Browse files
committed
Added: Playlists API: change playlist details
1 parent 48b41a1 commit ee271b6

File tree

14 files changed

+943
-3
lines changed

14 files changed

+943
-3
lines changed

src/main/java/Client/SpotifyRestAPI.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import Controller.PlayerController.CurrentTrack.baseCurrentTrack;
2020
import Controller.PlayerController.Devices.basePlayerDevice;
2121
import Controller.PlayerController.baseUserPlayback;
22+
import Controller.PlaylistController.Playlist;
2223
import Model.*;
2324
import getRequests.AlbumInterface;
2425

@@ -28,9 +29,7 @@
2829
import retrofit2.converter.gson.GsonConverterFactory;
2930

3031
import java.io.IOException;
31-
import java.util.ArrayList;
32-
import java.util.List;
33-
import java.util.Locale;
32+
import java.util.*;
3433

3534
import getRequests.Album;
3635

@@ -1351,6 +1350,44 @@ public Controller.PlaylistController.UserPlaylists.CreatePlaylist.BasePlaylist c
13511350

13521351
}
13531352

1353+
public Playlist getAPlaylist(SpotifyClient client) throws IOException {
1354+
1355+
String url = baseUrl + String.format("/v1/playlists/%s/",client.getPlaylist().getPlaylistId());
1356+
1357+
Retrofit retrofit = new Retrofit.Builder()
1358+
.baseUrl(url)
1359+
.addConverterFactory(GsonConverterFactory.create())
1360+
.build();
1361+
1362+
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
1363+
1364+
Call<Playlist> call = playlistInterface.getPlaylist(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1365+
1366+
Response<Playlist> response = call.execute();
1367+
1368+
return response.body();
1369+
1370+
1371+
}
1372+
1373+
public boolean changePlaylistDetails(SpotifyClient client) throws IOException {
1374+
1375+
String url = baseUrl + String.format("/v1/playlists/%s/",client.getPlaylist().getPlaylistId());
1376+
1377+
Retrofit retrofit = new Retrofit.Builder()
1378+
.baseUrl(url)
1379+
.addConverterFactory(GsonConverterFactory.create())
1380+
.build();
1381+
1382+
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
1383+
1384+
Call<Object> call = playlistInterface.changePlaylistDetails(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1385+
1386+
Response<Object> response = call.execute();
1387+
1388+
return response.isSuccessful();
1389+
}
1390+
13541391

13551392

13561393

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class AddedBy {
7+
8+
@SerializedName("external_urls")
9+
@Expose
10+
private ExternalUrls externalUrls;
11+
@SerializedName("href")
12+
@Expose
13+
private String href;
14+
@SerializedName("id")
15+
@Expose
16+
private String id;
17+
@SerializedName("type")
18+
@Expose
19+
private String type;
20+
@SerializedName("uri")
21+
@Expose
22+
private String uri;
23+
24+
public ExternalUrls getExternalUrls() {
25+
return externalUrls;
26+
}
27+
28+
public void setExternalUrls(ExternalUrls externalUrls) {
29+
this.externalUrls = externalUrls;
30+
}
31+
32+
public String getHref() {
33+
return href;
34+
}
35+
36+
public void setHref(String href) {
37+
this.href = href;
38+
}
39+
40+
public String getId() {
41+
return id;
42+
}
43+
44+
public void setId(String id) {
45+
this.id = id;
46+
}
47+
48+
public String getType() {
49+
return type;
50+
}
51+
52+
public void setType(String type) {
53+
this.type = type;
54+
}
55+
56+
public String getUri() {
57+
return uri;
58+
}
59+
60+
public void setUri(String uri) {
61+
this.uri = uri;
62+
}
63+
64+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
import java.util.List;
7+
8+
public class Album {
9+
10+
@SerializedName("album_type")
11+
@Expose
12+
private String albumType;
13+
@SerializedName("available_markets")
14+
@Expose
15+
private List<String> availableMarkets = null;
16+
@SerializedName("external_urls")
17+
@Expose
18+
private ExternalUrls externalUrls;
19+
@SerializedName("href")
20+
@Expose
21+
private String href;
22+
@SerializedName("id")
23+
@Expose
24+
private String id;
25+
@SerializedName("images")
26+
@Expose
27+
private List<Image> images = null;
28+
@SerializedName("name")
29+
@Expose
30+
private String name;
31+
@SerializedName("type")
32+
@Expose
33+
private String type;
34+
@SerializedName("uri")
35+
@Expose
36+
private String uri;
37+
38+
public String getAlbumType() {
39+
return albumType;
40+
}
41+
42+
public void setAlbumType(String albumType) {
43+
this.albumType = albumType;
44+
}
45+
46+
public List<String> getAvailableMarkets() {
47+
return availableMarkets;
48+
}
49+
50+
public void setAvailableMarkets(List<String> availableMarkets) {
51+
this.availableMarkets = availableMarkets;
52+
}
53+
54+
public ExternalUrls getExternalUrls() {
55+
return externalUrls;
56+
}
57+
58+
public void setExternalUrls(ExternalUrls externalUrls) {
59+
this.externalUrls = externalUrls;
60+
}
61+
62+
public String getHref() {
63+
return href;
64+
}
65+
66+
public void setHref(String href) {
67+
this.href = href;
68+
}
69+
70+
public String getId() {
71+
return id;
72+
}
73+
74+
public void setId(String id) {
75+
this.id = id;
76+
}
77+
78+
public List<Image> getImages() {
79+
return images;
80+
}
81+
82+
public void setImages(List<Image> images) {
83+
this.images = images;
84+
}
85+
86+
public String getName() {
87+
return name;
88+
}
89+
90+
public void setName(String name) {
91+
this.name = name;
92+
}
93+
94+
public String getType() {
95+
return type;
96+
}
97+
98+
public void setType(String type) {
99+
this.type = type;
100+
}
101+
102+
public String getUri() {
103+
return uri;
104+
}
105+
106+
public void setUri(String uri) {
107+
this.uri = uri;
108+
}
109+
110+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class Artist {
7+
8+
@SerializedName("external_urls")
9+
@Expose
10+
private ExternalUrls externalUrls;
11+
@SerializedName("href")
12+
@Expose
13+
private String href;
14+
@SerializedName("id")
15+
@Expose
16+
private String id;
17+
@SerializedName("name")
18+
@Expose
19+
private String name;
20+
@SerializedName("type")
21+
@Expose
22+
private String type;
23+
@SerializedName("uri")
24+
@Expose
25+
private String uri;
26+
27+
public ExternalUrls getExternalUrls() {
28+
return externalUrls;
29+
}
30+
31+
public void setExternalUrls(ExternalUrls externalUrls) {
32+
this.externalUrls = externalUrls;
33+
}
34+
35+
public String getHref() {
36+
return href;
37+
}
38+
39+
public void setHref(String href) {
40+
this.href = href;
41+
}
42+
43+
public String getId() {
44+
return id;
45+
}
46+
47+
public void setId(String id) {
48+
this.id = id;
49+
}
50+
51+
public String getName() {
52+
return name;
53+
}
54+
55+
public void setName(String name) {
56+
this.name = name;
57+
}
58+
59+
public String getType() {
60+
return type;
61+
}
62+
63+
public void setType(String type) {
64+
this.type = type;
65+
}
66+
67+
public String getUri() {
68+
return uri;
69+
}
70+
71+
public void setUri(String uri) {
72+
this.uri = uri;
73+
}
74+
75+
76+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class ExternalIds {
7+
8+
@SerializedName("isrc")
9+
@Expose
10+
private String isrc;
11+
12+
public String getIsrc() {
13+
return isrc;
14+
}
15+
16+
public void setIsrc(String isrc) {
17+
this.isrc = isrc;
18+
}
19+
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class ExternalUrls {
7+
8+
@SerializedName("spotify")
9+
@Expose
10+
private String spotify;
11+
12+
public String getSpotify() {
13+
return spotify;
14+
}
15+
16+
public void setSpotify(String spotify) {
17+
this.spotify = spotify;
18+
}
19+
20+
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package Controller.PlaylistController;
2+
3+
import com.google.gson.annotations.Expose;
4+
import com.google.gson.annotations.SerializedName;
5+
6+
public class Followers {
7+
8+
@SerializedName("href")
9+
@Expose
10+
private Object href;
11+
@SerializedName("total")
12+
@Expose
13+
private Integer total;
14+
15+
public Object getHref() {
16+
return href;
17+
}
18+
19+
public void setHref(Object href) {
20+
this.href = href;
21+
}
22+
23+
public Integer getTotal() {
24+
return total;
25+
}
26+
27+
public void setTotal(Integer total) {
28+
this.total = total;
29+
}
30+
31+
}

0 commit comments

Comments
 (0)