de.sonallux.spotify.api.apis.player.SetVolumeForUsersPlaybackRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotify-web-api-java Show documentation
Show all versions of spotify-web-api-java Show documentation
A Java wrapper for Spotify's Web API
The newest version!
package de.sonallux.spotify.api.apis.player;
import com.fasterxml.jackson.core.type.TypeReference;
import de.sonallux.spotify.api.http.ApiCall;
import de.sonallux.spotify.api.http.ApiClient;
import de.sonallux.spotify.api.http.Request;
import de.sonallux.spotify.api.models.*;
/**
* Set Playback Volume request
*
* Required OAuth scopes
* user-modify-playback-state
*
* Response
* Command sent
*/
public class SetVolumeForUsersPlaybackRequest {
private static final TypeReference RESPONSE_TYPE = new TypeReference<>() {};
private final ApiClient apiClient;
private final Request request;
/**
* Set Playback Volume request
* @param apiClient The API client
* @param volumePercent The volume to set. Must be a value from 0 to 100 inclusive.
*/
public SetVolumeForUsersPlaybackRequest(ApiClient apiClient, int volumePercent) {
this.apiClient = apiClient;
this.request = new Request("PUT", "/me/player/volume")
.addQueryParameter("volume_percent", String.valueOf(volumePercent))
;
}
/**
* @param deviceId The id of the device this command is targeting. If not supplied, the user's currently active device is the target.
* @return this request
*/
public SetVolumeForUsersPlaybackRequest deviceId(String deviceId) {
this.request.addQueryParameter("device_id", String.valueOf(deviceId));
return this;
}
/**
* Build the request into an executable api call
* @return an executable api call
*/
public ApiCall build() {
return apiClient.createApiCall(request, RESPONSE_TYPE);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy