com.lajospolya.spotifyapiwrapper.request.PostUsersPlaylists Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotify-api-wrapper Show documentation
Show all versions of spotify-api-wrapper Show documentation
This project wraps the Spotify public API in order to allow users to intuitively use it
package com.lajospolya.spotifyapiwrapper.request;
import com.lajospolya.spotifyapiwrapper.body.PlaylistDetails;
import com.lajospolya.spotifyapiwrapper.response.Playlist;
/**
* @author Lajos Polya
*
* Represents the endpoint at POST https://api.spotify.com/v1/users/{user_id}/playlists as descrbibed at
* https://developer.spotify.com/documentation/web-api/reference-beta/
*/
public class PostUsersPlaylists extends AbstractSpotifyRequest
{
private static final String REQUEST_URI_STRING = SPOTIFY_V1_API_URI + "users/{user_id}/playlists";
private PostUsersPlaylists(SpotifyRequestBuilder requestBuilder)
{
super(requestBuilder);
}
public static class Builder extends AbstractBuilder
{
private String userId;
private String name;
private Boolean isPublic;
private Boolean collaborative;
private String description;
public Builder(String userId, String name) throws IllegalArgumentException
{
spotifyRequestParamValidationService.validateParametersNotNull(userId, name);
this.userId = userId;
this.name = name;
}
@Override
public PostUsersPlaylists build()
{
SpotifyRequestBuilder spotifyRequestBuilder = new SpotifyRequestBuilder(REQUEST_URI_STRING, userId);
spotifyRequestBuilder.contentType(APPLICATION_JSON_CONTENT_TYPE_HEADER_VALUE);
return new PostUsersPlaylists(
spotifyRequestBuilder.POSTWithJsonBody(
new PlaylistDetails(name, isPublic, collaborative, description)));
}
public Builder isPublic(Boolean isPublic)
{
this.isPublic = isPublic;
return this;
}
public Builder collaborative(Boolean collaborative)
{
this.collaborative = collaborative;
return this;
}
public Builder description(String description)
{
this.description = description;
return this;
}
}
}