Skip to content

Commit c848a14

Browse files
committed
Added: Playlists API: get playlist items
1 parent ee271b6 commit c848a14

File tree

11 files changed

+694
-0
lines changed

11 files changed

+694
-0
lines changed

src/main/java/Client/SpotifyRestAPI.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import Controller.PlayerController.Devices.basePlayerDevice;
2121
import Controller.PlayerController.baseUserPlayback;
2222
import Controller.PlaylistController.Playlist;
23+
import Controller.PlaylistController.PlaylistItems.BasePlaylistItems;
2324
import Model.*;
2425
import getRequests.AlbumInterface;
2526

@@ -1388,6 +1389,25 @@ public boolean changePlaylistDetails(SpotifyClient client) throws IOException {
13881389
return response.isSuccessful();
13891390
}
13901391

1392+
public BasePlaylistItems getPlaylistItems(SpotifyClient client) throws IOException {
1393+
1394+
String url = baseUrl + String.format("/v1/playlists/%s/tracks/",client.getPlaylist().getPlaylistId());
1395+
1396+
Retrofit retrofit = new Retrofit.Builder()
1397+
.baseUrl(url)
1398+
.addConverterFactory(GsonConverterFactory.create())
1399+
.build();
1400+
1401+
playlistInterface playlistInterface = retrofit.create(Model.playlistInterface.class);
1402+
1403+
Call<BasePlaylistItems> call = playlistInterface.getPlaylistItems(getTokenString(client.getToken()),client.getPlaylist().getPlaylistId());
1404+
1405+
Response<BasePlaylistItems> response = call.execute();
1406+
1407+
return response.body();
1408+
1409+
}
1410+
13911411

13921412

13931413

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package Controller.PlaylistController.PlaylistItems;
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: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package Controller.PlaylistController.PlaylistItems;
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("artists")
14+
@Expose
15+
private List<Artist> artists = null;
16+
@SerializedName("available_markets")
17+
@Expose
18+
private List<String> availableMarkets = null;
19+
@SerializedName("external_urls")
20+
@Expose
21+
private ExternalUrls externalUrls;
22+
@SerializedName("href")
23+
@Expose
24+
private String href;
25+
@SerializedName("id")
26+
@Expose
27+
private String id;
28+
@SerializedName("images")
29+
@Expose
30+
private List<Image> images = null;
31+
@SerializedName("name")
32+
@Expose
33+
private String name;
34+
@SerializedName("type")
35+
@Expose
36+
private String type;
37+
@SerializedName("uri")
38+
@Expose
39+
private String uri;
40+
41+
public String getAlbumType() {
42+
return albumType;
43+
}
44+
45+
public void setAlbumType(String albumType) {
46+
this.albumType = albumType;
47+
}
48+
49+
public List<Artist> getArtists() {
50+
return artists;
51+
}
52+
53+
public void setArtists(List<Artist> artists) {
54+
this.artists = artists;
55+
}
56+
57+
public List<String> getAvailableMarkets() {
58+
return availableMarkets;
59+
}
60+
61+
public void setAvailableMarkets(List<String> availableMarkets) {
62+
this.availableMarkets = availableMarkets;
63+
}
64+
65+
public ExternalUrls getExternalUrls() {
66+
return externalUrls;
67+
}
68+
69+
public void setExternalUrls(ExternalUrls externalUrls) {
70+
this.externalUrls = externalUrls;
71+
}
72+
73+
public String getHref() {
74+
return href;
75+
}
76+
77+
public void setHref(String href) {
78+
this.href = href;
79+
}
80+
81+
public String getId() {
82+
return id;
83+
}
84+
85+
public void setId(String id) {
86+
this.id = id;
87+
}
88+
89+
public List<Image> getImages() {
90+
return images;
91+
}
92+
93+
public void setImages(List<Image> images) {
94+
this.images = images;
95+
}
96+
97+
public String getName() {
98+
return name;
99+
}
100+
101+
public void setName(String name) {
102+
this.name = name;
103+
}
104+
105+
public String getType() {
106+
return type;
107+
}
108+
109+
public void setType(String type) {
110+
this.type = type;
111+
}
112+
113+
public String getUri() {
114+
return uri;
115+
}
116+
117+
public void setUri(String uri) {
118+
this.uri = uri;
119+
}
120+
121+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package Controller.PlaylistController.PlaylistItems;
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+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package Controller.PlaylistController.PlaylistItems;
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 BasePlaylistItems {
9+
10+
@SerializedName("href")
11+
@Expose
12+
private String href;
13+
@SerializedName("items")
14+
@Expose
15+
private List<Item> items = null;
16+
@SerializedName("limit")
17+
@Expose
18+
private Integer limit;
19+
@SerializedName("next")
20+
@Expose
21+
private Object next;
22+
@SerializedName("offset")
23+
@Expose
24+
private Integer offset;
25+
@SerializedName("previous")
26+
@Expose
27+
private Object previous;
28+
@SerializedName("total")
29+
@Expose
30+
private Integer total;
31+
32+
public String getHref() {
33+
return href;
34+
}
35+
36+
public void setHref(String href) {
37+
this.href = href;
38+
}
39+
40+
public List<Item> getItems() {
41+
return items;
42+
}
43+
44+
public void setItems(List<Item> items) {
45+
this.items = items;
46+
}
47+
48+
public Integer getLimit() {
49+
return limit;
50+
}
51+
52+
public void setLimit(Integer limit) {
53+
this.limit = limit;
54+
}
55+
56+
public Object getNext() {
57+
return next;
58+
}
59+
60+
public void setNext(Object next) {
61+
this.next = next;
62+
}
63+
64+
public Integer getOffset() {
65+
return offset;
66+
}
67+
68+
public void setOffset(Integer offset) {
69+
this.offset = offset;
70+
}
71+
72+
public Object getPrevious() {
73+
return previous;
74+
}
75+
76+
public void setPrevious(Object previous) {
77+
this.previous = previous;
78+
}
79+
80+
public Integer getTotal() {
81+
return total;
82+
}
83+
84+
public void setTotal(Integer total) {
85+
this.total = total;
86+
}
87+
88+
}

0 commit comments

Comments
 (0)