diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/miscellaneous/CurrentlyPlayingContext.java b/src/main/java/se/michaelthelin/spotify/model_objects/miscellaneous/CurrentlyPlayingContext.java index a146fae98..5b7c39723 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/miscellaneous/CurrentlyPlayingContext.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/miscellaneous/CurrentlyPlayingContext.java @@ -38,6 +38,8 @@ public class CurrentlyPlayingContext extends AbstractModelObject { private final CurrentlyPlayingType currentlyPlayingType; /** Allows to update the user interface based on which playback actions are available. */ private final Actions actions; + /** If smart shuffle is on or off. */ + private final Boolean smart_shuffle; private CurrentlyPlayingContext(final Builder builder) { super(builder); @@ -52,6 +54,7 @@ private CurrentlyPlayingContext(final Builder builder) { this.item = builder.item; this.currentlyPlayingType = builder.currentlyPlayingType; this.actions = builder.actions; + this.smart_shuffle = builder.smart_shuffle; } /** @@ -81,6 +84,15 @@ public Boolean getShuffle_state() { return shuffle_state; } + /** + * Get smart shuffle state of the device. + * + * @return If smart shuffle is on or off. + */ + public Boolean getSmart_shuffle() { + return smart_shuffle; + } + /** * Get the context from where the currently playing item is played from. * @@ -149,7 +161,7 @@ public String toString() { return "CurrentlyPlayingContext(device=" + device + ", repeat_state=" + repeat_state + ", shuffle_state=" + shuffle_state + ", context=" + context + ", timestamp=" + timestamp + ", progress_ms=" + progress_ms + ", is_playing=" + is_playing + ", item=" + item + ", currentlyPlayingType=" + currentlyPlayingType - + ", actions=" + actions + ")"; + + ", actions=" + actions + ", smart_shuffle=" + smart_shuffle + ")"; } @Override @@ -171,6 +183,7 @@ public static final class Builder extends AbstractModelObject.Builder { private IPlaylistItem item; private CurrentlyPlayingType currentlyPlayingType; private Actions actions; + private Boolean smart_shuffle; /** * Default constructor. @@ -289,6 +302,17 @@ public Builder setActions(Actions actions) { return this; } + /** + * The smart shuffle setter. + * + * @param smart_shuffle If smart shuffle is on or off. + * @return A {@link CurrentlyPlayingContext.Builder}. + */ + public Builder setSmart_shuffle(Boolean smart_shuffle) { + this.smart_shuffle = smart_shuffle; + return this; + } + @Override public CurrentlyPlayingContext build() { return new CurrentlyPlayingContext(this); @@ -361,6 +385,10 @@ public CurrentlyPlayingContext createModelObject(JsonObject jsonObject) { ? new Actions.JsonUtil().createModelObject( jsonObject.getAsJsonObject("actions")) : null) + .setSmart_shuffle( + hasAndNotNull(jsonObject, "smart_shuffle") + ? jsonObject.get("smart_shuffle").getAsBoolean() + : null) .build(); } } diff --git a/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest.json b/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest.json index 2899152a7..27c790c12 100644 --- a/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest.json +++ b/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest.json @@ -92,5 +92,6 @@ } }, "repeat_state": "off", - "shuffle_state": false + "shuffle_state": false, + "smart_shuffle": false } diff --git a/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest_Episode.json b/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest_Episode.json index 0c0e12243..f2abd9f27 100644 --- a/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest_Episode.json +++ b/src/test/fixtures/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequest_Episode.json @@ -183,5 +183,6 @@ "toggling_shuffle": true } }, - "is_playing": true + "is_playing": true, + "smart_shuffle": false } diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequestTest.java index 2e225d5cf..05e7d4883 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/player/GetInformationAboutUsersCurrentPlaybackRequestTest.java @@ -95,6 +95,8 @@ public void shouldReturnDefault(final CurrentlyPlayingContext currentlyPlayingCo assertEquals( 2, currentlyPlayingContext.getActions().getDisallows().getDisallowedActions().size()); + assertFalse( + currentlyPlayingContext.getSmart_shuffle()); } @Test @@ -140,6 +142,8 @@ public void shouldReturnDefaultEpisode(final CurrentlyPlayingContext currentlyPl assertEquals( 4, currentlyPlayingContext.getActions().getDisallows().getDisallowedActions().size()); + assertFalse( + currentlyPlayingContext.getSmart_shuffle()); } @Test