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

se.michaelthelin.spotify.requests.data.player.AddItemToUsersPlaybackQueueRequest Maven / Gradle / Ivy

There is a newer version: 9.0.0-RC1
Show newest version
package se.michaelthelin.spotify.requests.data.player;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.ParseException;
import se.michaelthelin.spotify.exceptions.SpotifyWebApiException;
import se.michaelthelin.spotify.requests.data.AbstractDataRequest;

import java.io.IOException;

/**
 * Add a track or an episode to the end of the user's current playback queue.
 */
@JsonDeserialize(builder = AddItemToUsersPlaybackQueueRequest.Builder.class)
public class AddItemToUsersPlaybackQueueRequest extends AbstractDataRequest {

  /**
   * The private {@link AddItemToUsersPlaybackQueueRequest} constructor.
   *
   * @param builder A {@link AddItemToUsersPlaybackQueueRequest.Builder}.
   */
  private AddItemToUsersPlaybackQueueRequest(final Builder builder) {
    super(builder);
  }

  /**
   * Add an item to the user's playback queue.
   *
   * @return A string. Note: This endpoint doesn't return something in its response body.
   * @throws IOException            In case of networking issues.
   * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause.
   */
  @Override
  public String execute() throws
    IOException,
    SpotifyWebApiException,
    ParseException {
    return postJson();
  }

  /**
   * Builder class for building a {@link AddItemToUsersPlaybackQueueRequest}.
   */
  public static final class Builder extends AbstractDataRequest.Builder {

    /**
     * Create a new {@link AddItemToUsersPlaybackQueueRequest.Builder}.
     * 

* Your access token must have the {@code user-modify-playback-state} scope authorized in order to control playback. * * @param accessToken Required. A valid access token from the Spotify Accounts service. * @see Spotify: Using Scopes */ public Builder(final String accessToken) { super(accessToken); } /** * The device ID setter. * * @param device_id Optional. The ID of the device this command is targeting. If not supplied, the * user's currently active device is the target. * @return A {@link AddItemToUsersPlaybackQueueRequest.Builder}. * @see Spotify: URIs & IDs */ public Builder device_id(final String device_id) { assert (device_id != null); assert (!device_id.equals("")); return setQueryParameter("device_id", device_id); } /** * The uri setter. * * @param uri Required. The uri of the item to add to the queue. * Must be a track or an episode uri. * @return A {@link AddItemToUsersPlaybackQueueRequest.Builder}. * @see Spotify: URIs & IDs */ public Builder uri(final String uri) { assert (uri != null); assert (!uri.equals("")); return setQueryParameter("uri", uri); } /** * The request build method. * * @return A custom {@link AddItemToUsersPlaybackQueueRequest}. */ @Override public AddItemToUsersPlaybackQueueRequest build() { setContentType(ContentType.APPLICATION_JSON); setPath("/v1/me/player/queue"); return new AddItemToUsersPlaybackQueueRequest(this); } @Override protected Builder self() { return this; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy