Skip to content

Commit 5f80db7

Browse files
authored
Update to spotify-web-api-core 2021.8.23 (#75)
1 parent 82b52a9 commit 5f80db7

File tree

23 files changed

+82
-57
lines changed

23 files changed

+82
-57
lines changed

spotify-web-api-java-generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<url>https://github.com/sonallux/spotify-web-api-java</url>
2121

2222
<properties>
23-
<spotify-web-api-core.version>2021.7.20</spotify-web-api-core.version>
23+
<spotify-web-api-core.version>2021.8.23</spotify-web-api-core.version>
2424
<guava.version>30.1.1-jre</guava.version>
2525
<picocli.version>4.6.1</picocli.version>
2626
<flexmark.version>0.62.2</flexmark.version>

spotify-web-api-java-generator/src/main/java/de/sonallux/spotify/generator/java/templates/ApiTemplate.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ private List<Parameter> generateEndpointRequest(SpotifyWebApiEndpoint endpoint,
123123
var optionalPathParameters = new ArrayList<Parameter>();
124124
var optionalQueryParameters = new ArrayList<Parameter>();
125125
var optionalBodyParameters = new ArrayList<Parameter>();
126+
Parameter rawBodyParameter = null;
126127

127128
for (var parameter : endpoint.getParameters()) {
128129
switch (parameter.getLocation()) {
@@ -134,10 +135,16 @@ private List<Parameter> generateEndpointRequest(SpotifyWebApiEndpoint endpoint,
134135
addParameter(parameter, requiredQueryParameters, optionalQueryParameters);
135136
break;
136137
}
137-
case BODY: {
138-
addParameter(parameter, requiredBodyParameters, optionalBodyParameters);
139-
break;
140-
}
138+
}
139+
}
140+
141+
if (endpoint.getRequestBody() != null) {
142+
if (endpoint.getRequestBody() instanceof SpotifyWebApiEndpoint.JsonRequestBody) {
143+
var requestBody = ((SpotifyWebApiEndpoint.JsonRequestBody) endpoint.getRequestBody());
144+
requestBody.getParameters().forEach(p -> addParameter(p, requiredBodyParameters, optionalBodyParameters));
145+
} else if (endpoint.getRequestBody() instanceof SpotifyWebApiEndpoint.Base64ImageRequestBody) {
146+
var requestBody = ((SpotifyWebApiEndpoint.Base64ImageRequestBody) endpoint.getRequestBody());
147+
rawBodyParameter = new RawBodyParameter("base64Image", "String", requestBody.getDescription(), requestBody.getContentType());
141148
}
142149
}
143150

@@ -147,12 +154,16 @@ private List<Parameter> generateEndpointRequest(SpotifyWebApiEndpoint endpoint,
147154
context.put("optionalPathParameters", optionalPathParameters);
148155
context.put("optionalQueryParameters", optionalQueryParameters);
149156
context.put("optionalBodyParameters", optionalBodyParameters);
157+
context.put("rawBodyParameter", rawBodyParameter);
150158

151159
List<Parameter> requiredParameterList = new ArrayList<>();
152160
requiredParameterList.add(new Parameter("apiClient", "ApiClient", "The API client"));
153161
requiredParameterList.addAll(requiredPathParameters);
154162
requiredParameterList.addAll(requiredQueryParameters);
155163
requiredParameterList.addAll(requiredBodyParameters);
164+
if (rawBodyParameter != null) {
165+
requiredParameterList.add(rawBodyParameter);
166+
}
156167
context.put("requiredParameters", requiredParameterList.stream()
157168
.map(Parameter::asMethodParameter)
158169
.collect(joining(", ")));
@@ -220,4 +231,15 @@ public String asJavaDoc() {
220231
return "@param " + javaName + " " + description;
221232
}
222233
}
234+
235+
@Getter
236+
@Setter
237+
private static class RawBodyParameter extends Parameter {
238+
private String contentType;
239+
240+
public RawBodyParameter(String name, String type, String description, String contentType) {
241+
super(name, type, description);
242+
this.contentType = contentType;
243+
}
244+
}
223245
}

spotify-web-api-java-generator/src/main/resources/templates/request.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class {{className}} {
4949
{{#requiredBodyParameters}}
5050
.addBodyParameter("{{name}}", {{javaName}})
5151
{{/requiredBodyParameters}}
52+
{{#rawBodyParameter}}
53+
.withRawBody(okhttp3.RequestBody.create({{javaName}}, okhttp3.MediaType.get("{{contentType}}")))
54+
{{/rawBodyParameter}}
5255
;
5356
{{#parametersWithDefaultValue}}
5457
this.{{javaName}}({{defaultValue}});

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/FollowApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public CheckIfUserFollowsPlaylistRequest checkIfUserFollowsPlaylist(String playl
3636
/**
3737
* <h3>Follow Artists or Users</h3>
3838
* <p>Add the current user as a follower of one or more artists or other Spotify users.</p>
39-
* @param type <p>The ID type: either <code>artist</code> or <code>user</code>.</p>
39+
* @param type <p>The ID type.</p>
4040
* @param ids <p>A JSON array of the artist or user <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify IDs</a>. For example: <code>{ids:[&quot;74ASZWbe4lXaubB36ztrGX&quot;, &quot;08td7MxkoHQkXnWAYD8d6Q&quot;]}</code>. A maximum of 50 IDs can be sent in one request. <em>Note: if the <code>ids</code> parameter is present in the query string, any IDs listed here in the body will be ignored.</em></p>
4141
* @return a {@link FollowArtistsUsersRequest} object to build and execute the request
4242
*/

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/PlaylistsApi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public GetPlaylistsTracksRequest getPlaylistsTracks(String playlistId) {
9999
* @param tracks <p>An array of objects containing <a href="https://developer.spotify.com/spotify-documentation/web-api/#spotify-uris-and-ids">Spotify URIs</a> of the tracks or episodes to remove. For example: <code>{ &quot;tracks&quot;: [{ &quot;uri&quot;: &quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot; },{ &quot;uri&quot;: &quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot; }] }</code>. A maximum of 100 objects can be sent at once.</p>
100100
* @return a {@link RemoveTracksPlaylistRequest} object to build and execute the request
101101
*/
102-
public RemoveTracksPlaylistRequest removeTracksPlaylist(String playlistId, java.util.List<String> tracks) {
102+
public RemoveTracksPlaylistRequest removeTracksPlaylist(String playlistId, java.util.List<java.util.Map<String, Object>> tracks) {
103103
return new RemoveTracksPlaylistRequest(apiClient, playlistId, tracks);
104104
}
105105

@@ -130,9 +130,10 @@ public ReplacePlaylistsTracksRequest replacePlaylistsTracks(String playlistId, j
130130
* <h3>Upload a Custom Playlist Cover Image</h3>
131131
* <p>Replace the image used to represent a specific playlist.</p>
132132
* @param playlistId <p>The <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify ID</a> for the playlist.</p>
133+
* @param base64Image <p>The new cover image of the playlist as a Base64 encoded JPEG image. Maximum payload size is 256KB.</p>
133134
* @return a {@link UploadCustomPlaylistCoverRequest} object to build and execute the request
134135
*/
135-
public UploadCustomPlaylistCoverRequest uploadCustomPlaylistCover(String playlistId) {
136-
return new UploadCustomPlaylistCoverRequest(apiClient, playlistId);
136+
public UploadCustomPlaylistCoverRequest uploadCustomPlaylistCover(String playlistId, String base64Image) {
137+
return new UploadCustomPlaylistCoverRequest(apiClient, playlistId, base64Image);
137138
}
138139
}

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/follow/FollowArtistsUsersRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class FollowArtistsUsersRequest {
2424
/**
2525
* <h3>Follow Artists or Users request</h3>
2626
* @param apiClient <p>The API client</p>
27-
* @param type <p>The ID type: either <code>artist</code> or <code>user</code>.</p>
27+
* @param type <p>The ID type.</p>
2828
* @param ids <p>A JSON array of the artist or user <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify IDs</a>. For example: <code>{ids:[&quot;74ASZWbe4lXaubB36ztrGX&quot;, &quot;08td7MxkoHQkXnWAYD8d6Q&quot;]}</code>. A maximum of 50 IDs can be sent in one request. <em>Note: if the <code>ids</code> parameter is present in the query string, any IDs listed here in the body will be ignored.</em></p>
2929
*/
3030
public FollowArtistsUsersRequest(ApiClient apiClient, String type, java.util.List<String> ids) {

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/playlists/RemoveTracksPlaylistRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class RemoveTracksPlaylistRequest {
4545
* @param playlistId <p>The <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify ID</a></p>
4646
* @param tracks <p>An array of objects containing <a href="https://developer.spotify.com/spotify-documentation/web-api/#spotify-uris-and-ids">Spotify URIs</a> of the tracks or episodes to remove. For example: <code>{ &quot;tracks&quot;: [{ &quot;uri&quot;: &quot;spotify:track:4iV5W9uYEdYUVa79Axb7Rh&quot; },{ &quot;uri&quot;: &quot;spotify:track:1301WleyT98MSxVHPZCA6M&quot; }] }</code>. A maximum of 100 objects can be sent at once.</p>
4747
*/
48-
public RemoveTracksPlaylistRequest(ApiClient apiClient, String playlistId, java.util.List<String> tracks) {
48+
public RemoveTracksPlaylistRequest(ApiClient apiClient, String playlistId, java.util.List<java.util.Map<String, Object>> tracks) {
4949
this.apiClient = apiClient;
5050
this.request = new Request("DELETE", "/playlists/{playlist_id}/tracks")
5151
.addPathParameter("playlist_id", String.valueOf(playlistId))

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/apis/playlists/UploadCustomPlaylistCoverRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ public class UploadCustomPlaylistCoverRequest {
3131
* <h3>Upload a Custom Playlist Cover Image request</h3>
3232
* @param apiClient <p>The API client</p>
3333
* @param playlistId <p>The <a href="https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids">Spotify ID</a> for the playlist.</p>
34+
* @param base64Image <p>The new cover image of the playlist as a Base64 encoded JPEG image. Maximum payload size is 256KB.</p>
3435
*/
35-
public UploadCustomPlaylistCoverRequest(ApiClient apiClient, String playlistId) {
36+
public UploadCustomPlaylistCoverRequest(ApiClient apiClient, String playlistId, String base64Image) {
3637
this.apiClient = apiClient;
3738
this.request = new Request("PUT", "/playlists/{playlist_id}/images")
3839
.addPathParameter("playlist_id", String.valueOf(playlistId))
40+
.withRawBody(okhttp3.RequestBody.create(base64Image, okhttp3.MediaType.get("image/jpeg")))
3941
;
4042
}
4143

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/models/Album.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
import com.fasterxml.jackson.annotation.JsonTypeInfo;
44
import lombok.*;
55

6-
/**
7-
* <a href="https://developer.spotify.com/documentation/web-api/reference/#object-albumobject">AlbumObject</a>
8-
*/
96
@Getter
107
@Setter
118
@NoArgsConstructor
129
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) // Disable deserialization based on @JsonTypeInfo
1310
public class Album extends BaseObject {
1411
/**
15-
* <p>The type of the album: <code>album</code>, <code>single</code>, or <code>compilation</code>.</p>
12+
* <p>The type of the album.</p>
1613
*/
1714
public String albumType;
1815
/**
1916
* <p>The artists of the album. Each artist object includes a link in <code>href</code> to more detailed information about the artist.</p>
2017
*/
2118
public java.util.List<Artist> artists;
2219
/**
23-
* <p>The markets in which the album is available: <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2 country codes</a>. Note that an album is considered available in a market when at least 1 of its tracks is available in that market.</p>
20+
* <p>The markets in which the album is available: <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2 country codes</a>. Note that an album is considered available in a market when at least one of its tracks is available in that market.</p>
2421
*/
2522
public java.util.List<String> availableMarkets;
2623
/**
@@ -36,7 +33,7 @@ public class Album extends BaseObject {
3633
*/
3734
public ExternalUrl externalUrls;
3835
/**
39-
* <p>A list of the genres used to classify the album. For example: &quot;Prog Rock&quot; , &quot;Post-Grunge&quot;. (If not yet classified, the array is empty.)</p>
36+
* <p>A list of the genres used to classify the album. (If not yet classified, the array is empty.)</p>
4037
*/
4138
public java.util.List<String> genres;
4239
/**
@@ -52,15 +49,15 @@ public class Album extends BaseObject {
5249
*/
5350
public String name;
5451
/**
55-
* <p>The popularity of the album. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated from the popularity of the album's individual tracks.</p>
52+
* <p>The popularity of the album, with 100 being the most popular. The popularity is calculated from the popularity of the album's individual tracks.</p>
5653
*/
5754
public int popularity;
5855
/**
59-
* <p>The date the album was first released, for example &quot;1981-12-15&quot;. Depending on the precision, it might be shown as &quot;1981&quot; or &quot;1981-12&quot;.</p>
56+
* <p>The date the album was first released. Depending on the precision, it might be shown as &quot;1981&quot; or &quot;1981-12&quot;.</p>
6057
*/
6158
public String releaseDate;
6259
/**
63-
* <p>The precision with which release_date value is known: &quot;year&quot; , &quot;month&quot; , or &quot;day&quot;.</p>
60+
* <p>The precision with which release_date value is known.</p>
6461
*/
6562
public String releaseDatePrecision;
6663
/**

spotify-web-api-java/src/main/generated/de/sonallux/spotify/api/models/AlbumRestriction.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@
1010
@NoArgsConstructor
1111
public class AlbumRestriction {
1212
/**
13-
* <p>The reason for the restriction. Supported values:</p>
14-
* <ul>
15-
* <li><code>market</code> - The content item is not available in the given market.</li>
16-
* <li><code>product</code> - The content item is not available for the user's subscription type.</li>
17-
* <li><code>explicit</code> - The content item is explicit and the user's account is set to not play explicit content.<br>
18-
* Additional reasons may be added in the future. <strong>Note</strong>: If you use this field, make sure that your application safely handles unknown values.</li>
19-
* </ul>
13+
* <p>The reason for the restriction. Albums may be restricted if the content is not available in a given market, to the user's subscription type, or when the user's account is set to not play explicit content. Additional reasons may be added in the future.</p>
2014
*/
2115
public String reason;
2216
}

0 commit comments

Comments
 (0)