Search in sources :

Example 1 with User

use of se.michaelthelin.spotify.model_objects.specification.User in project spotify-web-api-java by spotify-web-api-java.

the class GetCurrentUsersProfileExample method getCurrentUsersProfile_Sync.

public static void getCurrentUsersProfile_Sync() {
    try {
        final User user = getCurrentUsersProfileRequest.execute();
        System.out.println("Display name: " + user.getDisplayName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : User(se.michaelthelin.spotify.model_objects.specification.User) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 2 with User

use of se.michaelthelin.spotify.model_objects.specification.User in project spotify-web-api-java by spotify-web-api-java.

the class GetCurrentUsersProfileExample method getCurrentUsersProfile_Async.

public static void getCurrentUsersProfile_Async() {
    try {
        final CompletableFuture<User> userFuture = getCurrentUsersProfileRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final User user = userFuture.join();
        System.out.println("Display name: " + user.getDisplayName());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : User(se.michaelthelin.spotify.model_objects.specification.User) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Example 3 with User

use of se.michaelthelin.spotify.model_objects.specification.User in project spotify-web-api-java by spotify-web-api-java.

the class GetUsersProfileExample method getUsersProfile_Async.

public static void getUsersProfile_Async() {
    try {
        final CompletableFuture<User> userFuture = getUsersProfileRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final User user = userFuture.join();
        System.out.println("Display name: " + user.getDisplayName());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : User(se.michaelthelin.spotify.model_objects.specification.User) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Example 4 with User

use of se.michaelthelin.spotify.model_objects.specification.User in project spotify-web-api-java by spotify-web-api-java.

the class GetUsersProfileExample method getUsersProfile_Sync.

public static void getUsersProfile_Sync() {
    try {
        final User user = getUsersProfileRequest.execute();
        System.out.println("Display name: " + user.getDisplayName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : User(se.michaelthelin.spotify.model_objects.specification.User) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Aggregations

User (se.michaelthelin.spotify.model_objects.specification.User)4 IOException (java.io.IOException)2 CancellationException (java.util.concurrent.CancellationException)2 CompletionException (java.util.concurrent.CompletionException)2 ParseException (org.apache.hc.core5.http.ParseException)2 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)2