Search in sources :

Example 1 with SnapshotResult

use of se.michaelthelin.spotify.model_objects.special.SnapshotResult in project spotify-web-api-java by spotify-web-api-java.

the class RemoveItemsFromPlaylistExample method removeItemsFromPlaylist_Sync.

public static void removeItemsFromPlaylist_Sync() {
    try {
        final SnapshotResult snapshotResult = removeItemsFromPlaylistRequest.execute();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 2 with SnapshotResult

use of se.michaelthelin.spotify.model_objects.special.SnapshotResult in project spotify-web-api-java by spotify-web-api-java.

the class AddItemsToPlaylistExample method addItemsToPlaylist_Sync.

public static void addItemsToPlaylist_Sync() {
    try {
        final SnapshotResult snapshotResult = addItemsToPlaylistRequest.execute();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 3 with SnapshotResult

use of se.michaelthelin.spotify.model_objects.special.SnapshotResult in project spotify-web-api-java by spotify-web-api-java.

the class AddItemsToPlaylistExample method addItemsToPlaylist_Async.

public static void addItemsToPlaylist_Async() {
    try {
        final CompletableFuture<SnapshotResult> snapshotResultFuture = addItemsToPlaylistRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final SnapshotResult snapshotResult = snapshotResultFuture.join();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Example 4 with SnapshotResult

use of se.michaelthelin.spotify.model_objects.special.SnapshotResult in project spotify-web-api-java by spotify-web-api-java.

the class RemoveItemsFromPlaylistExample method removeItemsFromPlaylist_Async.

public static void removeItemsFromPlaylist_Async() {
    try {
        final CompletableFuture<SnapshotResult> snapshotResultFuture = removeItemsFromPlaylistRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final SnapshotResult snapshotResult = snapshotResultFuture.join();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Example 5 with SnapshotResult

use of se.michaelthelin.spotify.model_objects.special.SnapshotResult in project spotify-web-api-java by spotify-web-api-java.

the class ReorderPlaylistsItemsExample method reorderPlaylistsItems_Async.

public static void reorderPlaylistsItems_Async() {
    try {
        final CompletableFuture<SnapshotResult> snapshotResultFuture = reorderPlaylistsItemsRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final SnapshotResult snapshotResult = snapshotResultFuture.join();
        System.out.println("Snapshot ID: " + snapshotResult.getSnapshotId());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : SnapshotResult(se.michaelthelin.spotify.model_objects.special.SnapshotResult) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Aggregations

SnapshotResult (se.michaelthelin.spotify.model_objects.special.SnapshotResult)6 IOException (java.io.IOException)3 CancellationException (java.util.concurrent.CancellationException)3 CompletionException (java.util.concurrent.CompletionException)3 ParseException (org.apache.hc.core5.http.ParseException)3 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)3