All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lajospolya.spotifyapiwrapper.request.PostUsersPlaylists Maven / Gradle / Ivy

Go to download

This project wraps the Spotify public API in order to allow users to intuitively use it

There is a newer version: 3.0.RELEASE
Show newest version
package com.lajospolya.spotifyapiwrapper.request;

import com.lajospolya.spotifyapiwrapper.body.PlaylistDetails;
import com.lajospolya.spotifyapiwrapper.response.Playlist;

import java.net.http.HttpRequest;

/**
 * @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(HttpRequest.Builder 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.createPostRequestWithObjectJsonBody(
                            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;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy