com.lajospolya.spotifyapiwrapper.request.PutPlaylists 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;
/**
* @author Lajos Polya
*
* Represents the endpoint at PUT https://api.spotify.com/v1/playlists/{playlist_id} as descrbibed at
* https://developer.spotify.com/documentation/web-api/reference-beta/
*/
public class PutPlaylists extends AbstractSpotifyRequest
{
private static final String REQUEST_URI_STRING = SPOTIFY_V1_API_URI + "playlists/{playlist_id}";
private PutPlaylists(SpotifyRequestBuilder requestBuilder)
{
super(requestBuilder);
}
public static class Builder extends AbstractBuilder
{
private String playlistsId;
private String name;
private Boolean isPublic;
private Boolean collaborative;
private String description;
public Builder(String playlistsId) throws IllegalArgumentException
{
spotifyRequestParamValidationService.validateParametersNotNull(playlistsId);
this.playlistsId = playlistsId;
}
@Override
public PutPlaylists build()
{
SpotifyRequestBuilder spotifyRequestBuilder = new SpotifyRequestBuilder(REQUEST_URI_STRING, playlistsId);
return createRequest(spotifyRequestBuilder);
}
private PutPlaylists createRequest(SpotifyRequestBuilder spotifyRequestBuilder)
{
if(name != null || this.isPublic != null || collaborative != null || description != null)
{
return new PutPlaylists(
spotifyRequestBuilder.PUTWithJsonBody(
new PlaylistDetails(name, isPublic, collaborative, description)));
}
return new PutPlaylists(spotifyRequestBuilder.PUT());
}
public Builder isPublic(Boolean isPublic)
{
this.isPublic = isPublic;
return this;
}
public Builder name(String name)
{
this.name = name;
return this;
}
public Builder collaborative(Boolean collaborative)
{
this.collaborative = collaborative;
return this;
}
public Builder description(String description)
{
this.description = description;
return this;
}
}
}