diff --git a/src/main/java/se/michaelthelin/spotify/SpotifyApi.java b/src/main/java/se/michaelthelin/spotify/SpotifyApi.java index 489f3fb1f..eec7e8587 100644 --- a/src/main/java/se/michaelthelin/spotify/SpotifyApi.java +++ b/src/main/java/se/michaelthelin/spotify/SpotifyApi.java @@ -13,16 +13,16 @@ import se.michaelthelin.spotify.requests.authorization.client_credentials.ClientCredentialsRequest; import se.michaelthelin.spotify.requests.data.albums.GetAlbumRequest; import se.michaelthelin.spotify.requests.data.albums.GetAlbumsTracksRequest; -import se.michaelthelin.spotify.requests.data.albums.GetSeveralAlbumsRequest; import se.michaelthelin.spotify.requests.data.artists.*; import se.michaelthelin.spotify.requests.data.browse.*; import se.michaelthelin.spotify.requests.data.browse.miscellaneous.GetAvailableGenreSeedsRequest; import se.michaelthelin.spotify.requests.data.episodes.GetEpisodeRequest; -import se.michaelthelin.spotify.requests.data.episodes.GetSeveralEpisodesRequest; import se.michaelthelin.spotify.requests.data.follow.*; import se.michaelthelin.spotify.requests.data.follow.legacy.FollowPlaylistRequest; import se.michaelthelin.spotify.requests.data.follow.legacy.UnfollowPlaylistRequest; import se.michaelthelin.spotify.requests.data.library.*; +import se.michaelthelin.spotify.requests.data.library.SaveToLibraryRequest; +import se.michaelthelin.spotify.requests.data.library.RemoveFromLibraryRequest; import se.michaelthelin.spotify.requests.data.personalization.GetUsersTopArtistsAndTracksRequest; import se.michaelthelin.spotify.requests.data.personalization.interfaces.IArtistTrackModelObject; import se.michaelthelin.spotify.requests.data.personalization.simplified.GetUsersTopArtistsRequest; @@ -32,12 +32,10 @@ import se.michaelthelin.spotify.requests.data.search.SearchItemRequest; import se.michaelthelin.spotify.requests.data.search.simplified.*; import se.michaelthelin.spotify.requests.data.search.simplified.special.SearchAlbumsSpecialRequest; -import se.michaelthelin.spotify.requests.data.shows.GetSeveralShowsRequest; import se.michaelthelin.spotify.requests.data.shows.GetShowRequest; import se.michaelthelin.spotify.requests.data.shows.GetShowsEpisodesRequest; import se.michaelthelin.spotify.requests.data.tracks.*; import se.michaelthelin.spotify.requests.data.users_profile.GetCurrentUsersProfileRequest; -import se.michaelthelin.spotify.requests.data.users_profile.GetUsersProfileRequest; import java.net.URI; import java.text.ParseException; @@ -576,19 +574,6 @@ public GetAlbumsTracksRequest.Builder getAlbumsTracks(String id) { .id(id); } - /** - * Get multiple albums. - * - * @param ids The Spotify IDs of all albums you're trying to retrieve. Maximum: 20 IDs. - * @return A {@link GetSeveralAlbumsRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetSeveralAlbumsRequest.Builder getSeveralAlbums(String... ids) { - return new GetSeveralAlbumsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - /** * Get an artist. * @@ -615,22 +600,6 @@ public GetArtistsAlbumsRequest.Builder getArtistsAlbums(String id) { .id(id); } - /** - * Get the top tracks of an artist in a specific country. - * - * @param id The Spotify ID of the artist. - * @param country The ISO 3166-1 alpha-2 country code of the specific country. - * @return A {@link GetArtistsTopTracksRequest.Builder}. - * @see Spotify: URLs & IDs - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public GetArtistsTopTracksRequest.Builder getArtistsTopTracks(String id, CountryCode country) { - return new GetArtistsTopTracksRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .id(id) - .country(country); - } - /** * Get artists related/similar to an artist. * @@ -644,32 +613,6 @@ public GetArtistsRelatedArtistsRequest.Builder getArtistsRelatedArtists(String i .id(id); } - /** - * Get multiple artists. - * - * @param ids The Spotify IDs of all artists you're trying to retrieve. Maximum: 50 IDs. - * @return A {@link GetSeveralArtistsRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetSeveralArtistsRequest.Builder getSeveralArtists(String... ids) { - return new GetSeveralArtistsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Get a category. - * - * @param category_id The Spotify category ID for the category. - * @return A {@link GetCategoryRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetCategoryRequest.Builder getCategory(String category_id) { - return new GetCategoryRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .category_id(category_id); - } - /** * Get the playlists from a specific category. * @@ -683,16 +626,6 @@ public GetCategorysPlaylistsRequest.Builder getCategorysPlaylists(String categor .category_id(category_id); } - /** - * Get a list of categories. - * - * @return A {@link GetListOfCategoriesRequest.Builder}. - */ - public GetListOfCategoriesRequest.Builder getListOfCategories() { - return new GetListOfCategoriesRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port); - } - /** * Get "Featured Playlists" of different countries which may match a specific language. * @@ -703,16 +636,6 @@ public GetListOfFeaturedPlaylistsRequest.Builder getListOfFeaturedPlaylists() { .setDefaults(httpManager, scheme, host, port); } - /** - * Get the newest releases from a specific country. - * - * @return A {@link GetListOfNewReleasesRequest.Builder}. - */ - public GetListOfNewReleasesRequest.Builder getListOfNewReleases() { - return new GetListOfNewReleasesRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port); - } - /** * Create a playlist-style listening experience based on seed artists, tracks and genres. * @@ -746,19 +669,6 @@ public GetEpisodeRequest.Builder getEpisode(String id) { .id(id); } - /** - * Get multiple episodes. - * - * @param ids The Spotify IDs of all episodes you're trying to retrieve. Maximum: 50 IDs. - * @return A {@link GetSeveralEpisodesRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetSeveralEpisodesRequest.Builder getSeveralEpisodes(String... ids) { - return new GetSeveralEpisodesRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - /** * Check to see if the current user is following one or more artists or other Spotify users. * @@ -1050,215 +960,27 @@ public GetUsersSavedTracksRequest.Builder getUsersSavedTracks() { } /** - * Remove one or more albums from the current user's "Your Music" library. - * - * @param ids A list of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveAlbumsForCurrentUserRequest.Builder removeAlbumsForCurrentUser(String... ids) { - return new RemoveAlbumsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Remove one or more albums from the current user's "Your Music" library. - * - * @param ids The Spotify IDs for the albums to be deleted. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveAlbumsForCurrentUserRequest.Builder removeAlbumsForCurrentUser(JsonArray ids) { - return new RemoveAlbumsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Remove one or more shows from the current users "Your Music" library. - * - * @param ids The Spotify IDs for the shows to be deleted. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedShowsRequest.Builder removeUsersSavedShows(String... ids) { - return new RemoveUsersSavedShowsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Remove one or more shows from the current users "Your Music" library. - * - * @param ids The Spotify IDs for the shows to be deleted. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedShowsRequest.Builder removeUsersSavedShows(JsonArray ids) { - return new RemoveUsersSavedShowsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Remove one or more episodes from the current user's library. - * This endpoint is in beta and could change without warning. - * - * @param ids The Spotify IDs for the episodes to be removed. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedEpisodesRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedEpisodesRequest.Builder removeUsersSavedEpisodes(String... ids) { - return new RemoveUsersSavedEpisodesRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Remove one or more episodes from the current user's library. - * This endpoint is in beta and could change without warning. - * - * @param ids The Spotify IDs for the episodes to be removed. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedEpisodesRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedEpisodesRequest.Builder removeUsersSavedEpisodes(JsonArray ids) { - return new RemoveUsersSavedEpisodesRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Remove a track if saved to the user's "Your Music" library. + * Save a list of Spotify URIs to the user's library. * - * @param ids The track IDs to remove from the user's Your Music library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedTracksRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedTracksRequest.Builder removeUsersSavedTracks(String... ids) { - return new RemoveUsersSavedTracksRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Remove a track if saved to the user's "Your Music" library. - * - * @param ids The track IDs to remove from the user's Your Music library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedTracksRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public RemoveUsersSavedTracksRequest.Builder removeUsersSavedTracks(JsonArray ids) { - return new RemoveUsersSavedTracksRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Save albums in the user's "Your Music" library. - * - * @param ids The album IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveAlbumsForCurrentUserRequest.Builder saveAlbumsForCurrentUser(String... ids) { - return new SaveAlbumsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Save albums in the user's "Your Music" library. - * - * @param ids The album IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveAlbumsForCurrentUserRequest.Builder saveAlbumsForCurrentUser(JsonArray ids) { - return new SaveAlbumsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Save one or more shows to current Spotify user’s library. - * - * @param ids The show IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveShowsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveShowsForCurrentUserRequest.Builder saveShowsForCurrentUser(String... ids) { - return new SaveShowsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Save one or more shows to current Spotify user’s library. - * - * @param ids The show IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveShowsForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveShowsForCurrentUserRequest.Builder saveShowsForCurrentUser(JsonArray ids) { - return new SaveShowsForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Save one or more episodes to the current user's library. - * This endpoint is in beta and could change without warning. - * - * @param ids The episode IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveEpisodesForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveEpisodesForCurrentUserRequest.Builder saveEpisodesForCurrentUser(String... ids) { - return new SaveEpisodesForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - - /** - * Save one or more episodes to the current user's library. - * This endpoint is in beta and could change without warning. - * - * @param ids The episode IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveEpisodesForCurrentUserRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public SaveEpisodesForCurrentUserRequest.Builder saveEpisodesForCurrentUser(JsonArray ids) { - return new SaveEpisodesForCurrentUserRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(ids); - } - - /** - * Save tracks in the user's "Your Music" library. - * - * @param ids The track IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveTracksForUserRequest.Builder}. - * @see Spotify: URLs & IDs + * @param uris The Spotify URIs to save. Maximum: 50 URIs. + * @return A {@link SaveToLibraryRequest.Builder}. */ - public SaveTracksForUserRequest.Builder saveTracksForUser(String... ids) { - return new SaveTracksForUserRequest.Builder(accessToken) + public SaveToLibraryRequest.Builder saveToLibrary(String... uris) { + return new SaveToLibraryRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); + .uris(uris); } /** - * Save tracks in the user's "Your Music" library. + * Remove a list of Spotify URIs from the user's library. * - * @param ids The track IDs to add to the user's library. Maximum: 50 IDs. - * @return A {@link SaveTracksForUserRequest.Builder}. - * @see Spotify: URLs & IDs + * @param uris The Spotify URIs to remove. Maximum: 50 URIs. + * @return A {@link RemoveFromLibraryRequest.Builder}. */ - public SaveTracksForUserRequest.Builder saveTracksForUser(JsonArray ids) { - return new SaveTracksForUserRequest.Builder(accessToken) + public RemoveFromLibraryRequest.Builder removeFromLibrary(String... uris) { + return new RemoveFromLibraryRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) - .ids(ids); + .uris(uris); } /** @@ -1524,15 +1246,13 @@ public ChangePlaylistsDetailsRequest.Builder changePlaylistsDetails(String playl /** * Create a playlist. * - * @param user_id The playlists owner. * @param name The name of the playlist. * @return A {@link CreatePlaylistRequest.Builder}. * @see Spotify: URLs & IDs */ - public CreatePlaylistRequest.Builder createPlaylist(String user_id, String name) { + public CreatePlaylistRequest.Builder createPlaylist(String name) { return new CreatePlaylistRequest.Builder(accessToken) .setDefaults(httpManager, scheme, host, port) - .user_id(user_id) .name(name); } @@ -1546,19 +1266,6 @@ public GetListOfCurrentUsersPlaylistsRequest.Builder getListOfCurrentUsersPlayli .setDefaults(httpManager, scheme, host, port); } - /** - * Get an user's playlists. - * - * @param user_id A Spotify ID of the user. - * @return A {@link GetListOfUsersPlaylistsRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetListOfUsersPlaylistsRequest.Builder getListOfUsersPlaylists(String user_id) { - return new GetListOfUsersPlaylistsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .user_id(user_id); - } - /** * Get a playlist. * @@ -1794,19 +1501,6 @@ public GetShowRequest.Builder getShow(String id) { .id(id); } - /** - * Get multiple shows. - * - * @param ids The Spotify IDs of all shows you're trying to retrieve. Maximum: 50 IDs. - * @return A {@link GetSeveralShowsRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetSeveralShowsRequest.Builder getSeveralShows(String... ids) { - return new GetSeveralShowsRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - /** * Get Spotify catalog information about an show’s episodes. * @@ -1859,19 +1553,6 @@ public GetAudioFeaturesForSeveralTracksRequest.Builder getAudioFeaturesForSevera .ids(concat(ids, ',')); } - /** - * Get multiple tracks. - * - * @param ids The Spotify IDs of all tracks you're trying to retrieve. Maximum: 50 IDs. - * @return A {@link GetSeveralTracksRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetSeveralTracksRequest.Builder getSeveralTracks(String... ids) { - return new GetSeveralTracksRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .ids(concat(ids, ',')); - } - /** * Get a track. * @@ -1895,19 +1576,6 @@ public GetCurrentUsersProfileRequest.Builder getCurrentUsersProfile() { .setDefaults(httpManager, scheme, host, port); } - /** - * Get public profile information about a Spotify user. - * - * @param user_id The Spotify ID of the user. - * @return A {@link GetUsersProfileRequest.Builder}. - * @see Spotify: URLs & IDs - */ - public GetUsersProfileRequest.Builder getUsersProfile(String user_id) { - return new GetUsersProfileRequest.Builder(accessToken) - .setDefaults(httpManager, scheme, host, port) - .user_id(user_id); - } - /** * Builder class for building {@link SpotifyApi} instances. */ diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Album.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Album.java index a95e0ce4f..2a271d321 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Album.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Album.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.AlbumType; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.enums.ReleaseDatePrecision; @@ -22,12 +21,8 @@ public class Album extends AbstractModelObject { private final AlbumType albumType; /** The artists who performed the album. */ private final ArtistSimplified[] artists; - /** The markets in which the album is available. */ - private final CountryCode[] availableMarkets; /** The copyright statements of the album. */ private final Copyright[] copyrights; - /** Known external IDs for the album. */ - private final ExternalId externalIds; /** Known external URLs for this album. */ private final ExternalUrl externalUrls; /** A list of the genres the album is associated with. */ @@ -38,12 +33,8 @@ public class Album extends AbstractModelObject { private final String id; /** The cover art for the album in various sizes. */ private final Image[] images; - /** The label for the album. */ - private final String label; /** The name of the album. */ private final String name; - /** The popularity of the album (0-100). */ - private final Integer popularity; /** The date the album was first released. */ private final String releaseDate; /** The precision with which release_date value is known. */ @@ -60,17 +51,13 @@ private Album(final Builder builder) { this.albumType = builder.albumType; this.artists = builder.artists; - this.availableMarkets = builder.availableMarkets; this.copyrights = builder.copyrights; - this.externalIds = builder.externalIds; this.externalUrls = builder.externalUrls; this.genres = builder.genres; this.href = builder.href; this.id = builder.id; this.images = builder.images; - this.label = builder.label; this.name = builder.name; - this.popularity = builder.popularity; this.releaseDate = builder.releaseDate; this.releaseDatePrecision = builder.releaseDatePrecision; this.tracks = builder.tracks; @@ -96,16 +83,6 @@ public ArtistSimplified[] getArtists() { return artists; } - /** - * Get the country codes of all countries, in which the album is available. - * - * @return An array of ISO 3166-1 alpha-2 country - * codes. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get all copyright texts of the album. * @@ -115,16 +92,6 @@ public Copyright[] getCopyrights() { return copyrights; } - /** - * Get the external IDs of the album.
- * Example: upc -> "Universal Product Code". - * - * @return An array of {@link ExternalId} objects. - */ - public ExternalId getExternalIds() { - return externalIds; - } - /** * Get the external URLs of the album.
* Example: Spotify-URL @@ -172,15 +139,6 @@ public Image[] getImages() { return images; } - /** - * Get the label for the album. - * - * @return The label for the album. - */ - public String getLabel() { - return label; - } - /** * Get the name of the album. * @@ -190,16 +148,6 @@ public String getName() { return name; } - /** - * Get the popularity of the album in a range between 0 and 100. (higher = more popular)
- * The popularity of the album is based on the popularity of its individual tracks. - * - * @return The popularity of the album. - */ - public Integer getPopularity() { - return popularity; - } - /** * Get the release date of the album with the highest precision available. * @@ -248,10 +196,10 @@ public String getUri() { @Override public String toString() { return "Album(artists=" + Arrays.toString(artists) + ", name=" + name + ", albumType=" + albumType - + ", availableMarkets=" + Arrays.toString(availableMarkets) + ", copyrights=" + Arrays.toString(copyrights) - + ", externalIds=" + externalIds + ", externalUrls=" + externalUrls + ", genres=" + Arrays.toString(genres) - + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", label=" + label + ", popularity=" - + popularity + ", releaseDate=" + releaseDate + ", releaseDatePrecision=" + releaseDatePrecision + ", tracks=" + + ", copyrights=" + Arrays.toString(copyrights) + + ", externalUrls=" + externalUrls + ", genres=" + Arrays.toString(genres) + + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + + ", releaseDate=" + releaseDate + ", releaseDatePrecision=" + releaseDatePrecision + ", tracks=" + tracks + ", type=" + type + ", uri=" + uri + ")"; } @@ -266,17 +214,13 @@ public Builder builder() { public static final class Builder extends AbstractModelObject.Builder { private AlbumType albumType; private ArtistSimplified[] artists; - private CountryCode[] availableMarkets; private Copyright[] copyrights; - private ExternalId externalIds; private ExternalUrl externalUrls; private String[] genres; private String href; private String id; private Image[] images; - private String label; private String name; - private Integer popularity; private String releaseDate; private ReleaseDatePrecision releaseDatePrecision; private Paging tracks; @@ -312,18 +256,6 @@ public Builder setArtists(ArtistSimplified... artists) { return this; } - /** - * Set the available markets of the album to be built. - * - * @param availableMarkets - * ISO 3166-1 alpha-2 country codes. - * @return A {@link Album.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set the copyrights of the album to be built. * @@ -335,17 +267,6 @@ public Builder setCopyrights(Copyright... copyrights) { return this; } - /** - * Set the external IDs of the album to be built. - * - * @param externalIds {@link ExternalId} object. - * @return A {@link Album.Builder}. - */ - public Builder setExternalIds(ExternalId externalIds) { - this.externalIds = externalIds; - return this; - } - /** * Set external URLs of the album to be built. * @@ -401,17 +322,6 @@ public Builder setImages(Image... images) { return this; } - /** - * Set the label of the album to be built. - * - * @param label The album label. - * @return A {@link Album.Builder}. - */ - public Builder setLabel(String label) { - this.label = label; - return this; - } - /** * Set the name of the album to be built. * @@ -423,17 +333,6 @@ public Builder setName(String name) { return this; } - /** - * Set the popularity of the album to be built. - * - * @param popularity The popularity of the album between 0 and 100. - * @return A {@link Album.Builder}. - */ - public Builder setPopularity(Integer popularity) { - this.popularity = popularity; - return this; - } - /** * Set the release date of the album to be built. * @@ -524,21 +423,11 @@ public Album createModelObject(JsonObject jsonObject) { ? new ArtistSimplified.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("artists")) : null) - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson( - jsonObject.getAsJsonArray("available_markets"), CountryCode[].class) - : null) .setCopyrights( hasAndNotNull(jsonObject, "copyrights") ? new Copyright.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("copyrights")) : null) - .setExternalIds( - hasAndNotNull(jsonObject, "external_ids") - ? new ExternalId.JsonUtil().createModelObject( - jsonObject.getAsJsonObject("external_ids")) - : null) .setExternalUrls( hasAndNotNull(jsonObject, "external_urls") ? new ExternalUrl.JsonUtil().createModelObject( @@ -562,18 +451,10 @@ public Album createModelObject(JsonObject jsonObject) { ? new Image.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("images")) : null) - .setLabel( - hasAndNotNull(jsonObject, "label") - ? jsonObject.get("label").getAsString() - : null) .setName( hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() : null) - .setPopularity( - hasAndNotNull(jsonObject, "popularity") - ? jsonObject.get("popularity").getAsInt() - : null) .setReleaseDate( hasAndNotNull(jsonObject, "release_date") ? jsonObject.get("release_date").getAsString() @@ -610,12 +491,12 @@ public boolean equals(Object o) { return false; } Album album = (Album) o; - return Objects.equals(id, album.id) && Objects.equals(label, album.label) && Objects.equals(name, album.name) && + return Objects.equals(id, album.id) && Objects.equals(name, album.name) && Objects.equals(releaseDate, album.releaseDate) && Objects.equals(uri, album.uri); } @Override public int hashCode() { - return Objects.hash(id, label, name, releaseDate, uri); + return Objects.hash(id, name, releaseDate, uri); } } diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/AlbumSimplified.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/AlbumSimplified.java index d67f2bd13..a356c9ae6 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/AlbumSimplified.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/AlbumSimplified.java @@ -1,10 +1,7 @@ package se.michaelthelin.spotify.model_objects.specification; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; -import se.michaelthelin.spotify.enums.AlbumGroup; import se.michaelthelin.spotify.enums.AlbumType; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.enums.ReleaseDatePrecision; @@ -21,14 +18,10 @@ */ @JsonDeserialize(builder = AlbumSimplified.Builder.class) public class AlbumSimplified extends AbstractModelObject implements ISearchModelObject { - /** The album group the album belongs to. */ - private final AlbumGroup albumGroup; /** The type of the album. */ private final AlbumType albumType; /** The artists who performed the album. */ private final ArtistSimplified[] artists; - /** The markets in which the album is available. */ - private final CountryCode[] availableMarkets; /** Known external URLs for this album. */ private final ExternalUrl externalUrls; /** A link to the Web API endpoint providing full details of the album. */ @@ -53,10 +46,8 @@ public class AlbumSimplified extends AbstractModelObject implements ISearchModel private AlbumSimplified(final Builder builder) { super(builder); - this.albumGroup = builder.albumGroup; this.albumType = builder.albumType; this.artists = builder.artists; - this.availableMarkets = builder.availableMarkets; this.externalUrls = builder.externalUrls; this.href = builder.href; this.id = builder.id; @@ -69,15 +60,6 @@ private AlbumSimplified(final Builder builder) { this.uri = builder.uri; } - /** - * Get the Spotify Album Group of the album. - * - * @return The album group date of the album. - */ - public AlbumGroup getAlbumGroup() { - return albumGroup; - } - /** * Get the type of the album. * @@ -96,16 +78,6 @@ public ArtistSimplified[] getArtists() { return artists; } - /** - * Get the country codes of all countries, in which the album is available. - * - * @return An array of ISO 3166-1 alpha-2 country - * codes. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get the external URLs of the album.
* Example: Spotify-URL @@ -199,8 +171,8 @@ public String getUri() { @Override public String toString() { - return "AlbumSimplified(artists=" + Arrays.toString(artists) + ", name=" + name + ", albumGroup=" + albumGroup - + ", albumType=" + albumType + ", availableMarkets=" + Arrays.toString(availableMarkets) + ", externalUrls=" + return "AlbumSimplified(artists=" + Arrays.toString(artists) + ", name=" + name + + ", albumType=" + albumType + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", releaseDate=" + releaseDate + ", releaseDatePrecision=" + releaseDatePrecision + ", restrictions=" + restrictions + ", type=" + type + ", uri=" + uri + ")"; @@ -215,10 +187,8 @@ public Builder builder() { * Builder class for building {@link AlbumSimplified} instances. */ public static final class Builder extends AbstractModelObject.Builder { - private AlbumGroup albumGroup; private AlbumType albumType; private ArtistSimplified[] artists; - private CountryCode[] availableMarkets; private ExternalUrl externalUrls; private String href; private String id; @@ -237,17 +207,6 @@ public Builder() { super(); } - /** - * Set the album group of the album to be built. - * - * @param albumGroup The album group of the album. - * @return A {@link AlbumSimplified.Builder}. - */ - public Builder setAlbumGroup(AlbumGroup albumGroup) { - this.albumGroup = albumGroup; - return this; - } - /** * Set the type of the album to be built. * @@ -270,18 +229,6 @@ public Builder setArtists(ArtistSimplified... artists) { return this; } - /** - * Set the available markets of the album to be built. - * - * @param availableMarkets - * ISO 3166-1 alpha-2 country codes. - * @return A {@link AlbumSimplified.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set external URLs of the album to be built. * @@ -417,11 +364,6 @@ public AlbumSimplified createModelObject(JsonObject jsonObject) { } return new AlbumSimplified.Builder() - .setAlbumGroup( - hasAndNotNull(jsonObject, "album_group") - ? AlbumGroup.keyOf( - jsonObject.get("album_group").getAsString().toLowerCase()) - : null) .setAlbumType( hasAndNotNull(jsonObject, "album_type") ? AlbumType.keyOf( @@ -432,11 +374,6 @@ public AlbumSimplified createModelObject(JsonObject jsonObject) { ? new ArtistSimplified.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("artists")) : null) - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson( - jsonObject.get("available_markets"), CountryCode[].class) - : null) .setExternalUrls( hasAndNotNull(jsonObject, "external_urls") ? new ExternalUrl.JsonUtil().createModelObject( diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Artist.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Artist.java index de724850b..65cc668ce 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Artist.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Artist.java @@ -19,8 +19,6 @@ public class Artist extends AbstractModelObject implements IArtistTrackModelObject, ISearchModelObject { /** Known external URLs for this artist. */ private final ExternalUrl externalUrls; - /** Information about the followers of the artist. */ - private final Followers followers; /** A list of the genres the artist is associated with. */ private final String[] genres; /** A link to the Web API endpoint providing full details of the artist. */ @@ -31,8 +29,6 @@ public class Artist extends AbstractModelObject implements IArtistTrackModelObje private final Image[] images; /** The name of the artist. */ private final String name; - /** The popularity of the artist (0-100). */ - private final Integer popularity; /** The object type: "artist". */ private final ModelObjectType type; /** The Spotify URI for the artist. */ @@ -42,13 +38,11 @@ private Artist(final Builder builder) { super(builder); this.externalUrls = builder.externalUrls; - this.followers = builder.followers; this.genres = builder.genres; this.href = builder.href; this.id = builder.id; this.images = builder.images; this.name = builder.name; - this.popularity = builder.popularity; this.type = builder.type; this.uri = builder.uri; } @@ -63,16 +57,6 @@ public ExternalUrl getExternalUrls() { return externalUrls; } - /** - * Get information about the followers of the artist.
- * Example: Follower count. - * - * @return A {@link Followers} object. - */ - public Followers getFollowers() { - return followers; - } - /** * Get a list of all genres of the artist.
* A great amount of artists may contain no information about their genres. @@ -119,16 +103,6 @@ public String getName() { return name; } - /** - * Get the popularity of the artist in a range between 0 and 100. (higher = more popular)
- * The popularity of the artist is based on the popularity of its tracks. - * - * @return The popularity of the artist. - */ - public Integer getPopularity() { - return popularity; - } - /** * Get the model object type. In this case "artist". * @@ -149,9 +123,9 @@ public String getUri() { @Override public String toString() { - return "Artist(name=" + name + ", externalUrls=" + externalUrls + ", followers=" + followers + ", genres=" + return "Artist(name=" + name + ", externalUrls=" + externalUrls + ", genres=" + Arrays.toString(genres) + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) - + ", popularity=" + popularity + ", type=" + type + ", uri=" + uri + ")"; + + ", type=" + type + ", uri=" + uri + ")"; } @Override @@ -164,13 +138,11 @@ public Builder builder() { */ public static final class Builder extends AbstractModelObject.Builder { private ExternalUrl externalUrls; - private Followers followers; private String[] genres; private String href; private String id; private Image[] images; private String name; - private Integer popularity; private ModelObjectType type; private String uri; @@ -192,17 +164,6 @@ public Builder setExternalUrls(ExternalUrl externalUrls) { return this; } - /** - * Set the followers object of the artist to be built. - * - * @param followers A {@link Followers} object. - * @return A {@link Artist.Builder}. - */ - public Builder setFollowers(Followers followers) { - this.followers = followers; - return this; - } - /** * Set the genres of the artist to be built. * @@ -258,17 +219,6 @@ public Builder setName(String name) { return this; } - /** - * Set the popularity of the artist to be built. - * - * @param popularity The popularity of the artist between 0 and 100. - * @return A {@link Artist.Builder}. - */ - public Builder setPopularity(Integer popularity) { - this.popularity = popularity; - return this; - } - /** * Set the type of the model object. In this case "artist". * @@ -321,11 +271,6 @@ public Artist createModelObject(JsonObject jsonObject) { ? new ExternalUrl.JsonUtil().createModelObject( jsonObject.getAsJsonObject("external_urls")) : null) - .setFollowers( - hasAndNotNull(jsonObject, "followers") - ? new Followers.JsonUtil().createModelObject( - jsonObject.getAsJsonObject("followers")) - : null) .setGenres( hasAndNotNull(jsonObject, "genres") ? new Gson().fromJson( @@ -348,10 +293,6 @@ public Artist createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() : null) - .setPopularity( - hasAndNotNull(jsonObject, "popularity") - ? jsonObject.get("popularity").getAsInt() - : null) .setType( hasAndNotNull(jsonObject, "type") ? ModelObjectType.keyOf( diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Playlist.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Playlist.java index 3f0816848..a19de499b 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Playlist.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Playlist.java @@ -37,8 +37,8 @@ public class Playlist extends AbstractModelObject { private final Boolean publicAccess; /** The version identifier for the current playlist. */ private final String snapshotId; - /** Information about the tracks of the playlist. */ - private final Paging tracks; + /** Information about the items of the playlist. */ + private final Paging items; /** The object type. */ private final ModelObjectType type; /** The Spotify URI for the playlist. */ @@ -58,7 +58,7 @@ private Playlist(final Builder builder) { this.owner = builder.owner; this.publicAccess = builder.publicAccess; this.snapshotId = builder.snapshotId; - this.tracks = builder.tracks; + this.items = builder.items; this.type = builder.type; this.uri = builder.uri; } @@ -179,12 +179,12 @@ public String getSnapshotId() { } /** - * Get information about the tracks of the playlist. + * Get information about the items of the playlist. * - * @return Information about the tracks of the playlist. + * @return Information about the items of the playlist. */ - public Paging getTracks() { - return tracks; + public Paging getItems() { + return items; } /** @@ -208,7 +208,7 @@ public String getUri() { @Override public String toString() { - return "Playlist(name=" + name + ", description=" + description + ", tracks=" + tracks + ", collaborative=" + return "Playlist(name=" + name + ", description=" + description + ", items=" + items + ", collaborative=" + collaborative + ", externalUrls=" + externalUrls + ", followers=" + followers + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", owner=" + owner + ", publicAccess=" + publicAccess + ", snapshotId=" + snapshotId + ", type=" + type + ", uri=" + uri + ")"; @@ -234,7 +234,7 @@ public static final class Builder extends AbstractModelObject.Builder { private User owner; private Boolean publicAccess; private String snapshotId; - private Paging tracks; + private Paging items; private ModelObjectType type; private String uri; @@ -368,13 +368,13 @@ public Builder setSnapshotId(String snapshotId) { } /** - * Set the tracks of the playlist to be built. + * Set the items of the playlist to be built. * - * @param tracks Information about the tracks of the playlist. + * @param items Information about the items of the playlist. * @return A {@link Playlist.Builder}. */ - public Builder setTracks(Paging tracks) { - this.tracks = tracks; + public Builder setItems(Paging items) { + this.items = items; return this; } @@ -473,10 +473,10 @@ public Playlist createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "snapshot_id") ? jsonObject.get("snapshot_id").getAsString() : null) - .setTracks( - hasAndNotNull(jsonObject, "tracks") + .setItems( + hasAndNotNull(jsonObject, "items") ? new PlaylistTrack.JsonUtil().createModelObjectPaging( - jsonObject.getAsJsonObject("tracks")) + jsonObject.getAsJsonObject("items")) : null) .setType( hasAndNotNull(jsonObject, "type") diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistSimplified.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistSimplified.java index 01cda2407..d27d318f1 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistSimplified.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistSimplified.java @@ -37,8 +37,8 @@ public class PlaylistSimplified extends AbstractModelObject implements ISearchMo private final Boolean publicAccess; /** The version identifier for the current playlist. */ private final String snapshotId; - /** Information about the tracks of the playlist. */ - private final PlaylistTracksInformation tracks; + /** Information about the items of the playlist. */ + private final PlaylistTracksInformation items; /** The object type. */ private final ModelObjectType type; /** The Spotify URI for the playlist. */ @@ -57,7 +57,7 @@ private PlaylistSimplified(final Builder builder) { this.owner = builder.owner; this.publicAccess = builder.publicAccess; this.snapshotId = builder.snapshotId; - this.tracks = builder.tracks; + this.items = builder.items; this.type = builder.type; this.uri = builder.uri; } @@ -168,12 +168,12 @@ public String getSnapshotId() { } /** - * Get information about the tracks of the playlist. + * Get information about the items of the playlist. * - * @return Information about the tracks of the playlist. + * @return Information about the items of the playlist. */ - public PlaylistTracksInformation getTracks() { - return tracks; + public PlaylistTracksInformation getItems() { + return items; } /** @@ -197,7 +197,7 @@ public String getUri() { @Override public String toString() { - return "PlaylistSimplified(name=" + name + ", tracks=" + tracks + ", collaborative=" + collaborative + return "PlaylistSimplified(name=" + name + ", items=" + items + ", collaborative=" + collaborative + ", description=" + description + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", owner=" + owner + ", publicAccess=" + publicAccess + ", snapshotId=" + snapshotId + ", type=" + type + ", uri=" + uri + ")"; @@ -222,7 +222,7 @@ public static final class Builder extends AbstractModelObject.Builder { private User owner; private Boolean publicAccess; private String snapshotId; - private PlaylistTracksInformation tracks; + private PlaylistTracksInformation items; private ModelObjectType type; private String uri; @@ -345,13 +345,13 @@ public Builder setSnapshotId(String snapshotId) { } /** - * Set some track information of the playlist to be built. + * Set some item information of the playlist to be built. * - * @param tracks A playlist tracks information object. + * @param items A playlist tracks information object. * @return A {@link PlaylistSimplified.Builder}. */ - public Builder setTracks(PlaylistTracksInformation tracks) { - this.tracks = tracks; + public Builder setItems(PlaylistTracksInformation items) { + this.items = items; return this; } @@ -445,10 +445,10 @@ public PlaylistSimplified createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "snapshot_id") ? jsonObject.get("snapshot_id").getAsString() : null) - .setTracks( - hasAndNotNull(jsonObject, "tracks") + .setItems( + hasAndNotNull(jsonObject, "items") ? new PlaylistTracksInformation.JsonUtil().createModelObject( - jsonObject.getAsJsonObject("tracks")) + jsonObject.getAsJsonObject("items")) : null) .setType( hasAndNotNull(jsonObject, "type") diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistTrack.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistTrack.java index f249c5ce8..f4d9cc523 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistTrack.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/PlaylistTrack.java @@ -24,7 +24,7 @@ public class PlaylistTrack extends AbstractModelObject { /** Whether the track is a local file. */ private final Boolean isLocal; /** The track or episode information. */ - private final IPlaylistItem track; + private final IPlaylistItem item; private PlaylistTrack(final Builder builder) { super(builder); @@ -32,7 +32,7 @@ private PlaylistTrack(final Builder builder) { this.addedAt = builder.addedAt; this.addedBy = builder.addedBy; this.isLocal = builder.isLocal; - this.track = builder.track; + this.item = builder.item; } /** @@ -68,15 +68,15 @@ public Boolean getIsLocal() { /** * Get a full track or episode object from this playlist track object. * - * @return Information about the track. + * @return Information about the item. */ - public IPlaylistItem getTrack() { - return track; + public IPlaylistItem getItem() { + return item; } @Override public String toString() { - return "PlaylistTrack(track=" + track + ", addedAt=" + addedAt + ", addedBy=" + addedBy + ", isLocal=" + isLocal + return "PlaylistTrack(item=" + item + ", addedAt=" + addedAt + ", addedBy=" + addedBy + ", isLocal=" + isLocal + ")"; } @@ -92,7 +92,7 @@ public static final class Builder extends AbstractModelObject.Builder { private Date addedAt; private User addedBy; private Boolean isLocal; - private IPlaylistItem track; + private IPlaylistItem item; /** * Default constructor. @@ -137,11 +137,11 @@ public Builder setIsLocal(Boolean isLocal) { /** * Set the full track or episode object of the playlist track to be built. * - * @param track Information about the track. + * @param item Information about the item. * @return A {@link PlaylistTrack.Builder}. */ - public Builder setTrack(IPlaylistItem track) { - this.track = track; + public Builder setItem(IPlaylistItem item) { + this.item = item; return this; } @@ -169,12 +169,12 @@ public PlaylistTrack createModelObject(JsonObject jsonObject) { } try { - IPlaylistItem track = null; + IPlaylistItem item = null; - if (hasAndNotNull(jsonObject, "track")) { - final JsonObject trackObj = jsonObject.getAsJsonObject("track"); + if (hasAndNotNull(jsonObject, "item")) { + final JsonObject itemObj = jsonObject.getAsJsonObject("item"); - track = PlaylistItemFactory.createPlaylistItem(trackObj); + item = PlaylistItemFactory.createPlaylistItem(itemObj); } return new Builder() @@ -191,7 +191,7 @@ public PlaylistTrack createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "is_local") ? jsonObject.get("is_local").getAsBoolean() : null) - .setTrack(track) + .setItem(item) .build(); } catch (ParseException e) { SpotifyApi.LOGGER.log(Level.SEVERE, e.getMessage()); diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Show.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Show.java index 78369c9a8..20eaf802a 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Show.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Show.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.model_objects.AbstractModelObject; @@ -16,8 +15,6 @@ */ @JsonDeserialize(builder = Show.Builder.class) public class Show extends AbstractModelObject { - /** A list of the countries in which the show can be played. */ - private final CountryCode[] availableMarkets; /** The copyright statements of the show. */ private final Copyright[] copyrights; /** A description of the show. */ @@ -42,8 +39,6 @@ public class Show extends AbstractModelObject { private final String mediaType; /** The name of the show. */ private final String name; - /** The publisher of the show. */ - private final String publisher; /** The object type. */ private final ModelObjectType type; /** The Spotify URI for the show. */ @@ -56,7 +51,6 @@ public class Show extends AbstractModelObject { */ public Show(Builder builder) { super(builder); - this.availableMarkets = builder.availableMarkets; this.copyrights = builder.copyrights; this.description = builder.description; this.explicit = builder.explicit; @@ -69,21 +63,10 @@ public Show(Builder builder) { this.languages = builder.languages; this.mediaType = builder.mediaType; this.name = builder.name; - this.publisher = builder.publisher; this.type = builder.type; this.uri = builder.uri; } - /** - * Get a list of the countries in which the show can be played. - * - * @return An array of ISO 3166-1 alpha-2 country - * * codes. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get the copyright statements of the show. * @@ -194,15 +177,6 @@ public String getName() { return name; } - /** - * Get the publisher of the show. - * - * @return The publisher of the show. - */ - public String getPublisher() { - return publisher; - } - /** * Get the model object type. In this case "show". * @@ -223,11 +197,11 @@ public String getUri() { @Override public String toString() { - return "Show(availableMarkets=" + Arrays.toString(availableMarkets) + ", copyrights=" + Arrays.toString(copyrights) + return "Show(copyrights=" + Arrays.toString(copyrights) + ", description=" + description + ", explicit=" + explicit + ", episodes=" + episodes + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", isExternallyHosted=" + isExternallyHosted + ", languages=" + Arrays.toString(languages) + ", mediaType=" - + mediaType + ", name=" + name + ", publisher=" + publisher + ", type=" + type + ", uri=" + uri + ")"; + + mediaType + ", name=" + name + ", type=" + type + ", uri=" + uri + ")"; } @Override @@ -239,7 +213,6 @@ public Builder builder() { * Builder class for building {@link Show} instances. */ public static final class Builder extends AbstractModelObject.Builder { - private CountryCode[] availableMarkets; private Copyright[] copyrights; private String description; private Boolean explicit; @@ -252,7 +225,6 @@ public static final class Builder extends AbstractModelObject.Builder { private String[] languages; private String mediaType; private String name; - private String publisher; private ModelObjectType type; private String uri; @@ -263,18 +235,6 @@ public Builder() { super(); } - /** - * Set the available markets of the show to be built. - * - * @param availableMarkets A list of the countries in which the show can be played, identified by their - * ISO 3166-1 alpha-2 code. - * @return A {@link Show.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set the copyrights of the show to be built. * @@ -407,17 +367,6 @@ public Builder setName(String name) { return this; } - /** - * Set the publisher for the show to be built. - * - * @param publisher The publisher of the show. - * @return A {@link Show.Builder}. - */ - public Builder setPublisher(String publisher) { - this.publisher = publisher; - return this; - } - /** * Set the type of the model object. In this case "show". * @@ -465,11 +414,6 @@ public Show createModelObject(JsonObject jsonObject) { } return new Builder() - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson( - jsonObject.getAsJsonArray("available_markets"), CountryCode[].class) - : null) .setCopyrights( hasAndNotNull(jsonObject, "copyrights") ? new Gson().fromJson( @@ -523,10 +467,6 @@ public Show createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() : null) - .setPublisher( - hasAndNotNull(jsonObject, "publisher") - ? jsonObject.get("publisher").getAsString() - : null) .setType( hasAndNotNull(jsonObject, "type") ? ModelObjectType.keyOf( diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/ShowSimplified.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/ShowSimplified.java index 1c8cc29d4..f9372f42a 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/ShowSimplified.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/ShowSimplified.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.model_objects.AbstractModelObject; import se.michaelthelin.spotify.requests.data.search.interfaces.ISearchModelObject; @@ -17,8 +16,6 @@ */ @JsonDeserialize(builder = ShowSimplified.Builder.class) public class ShowSimplified extends AbstractModelObject implements ISearchModelObject { - /** A list of the countries in which the show can be played. */ - private final CountryCode[] availableMarkets; /** The copyright statements of the show. */ private final Copyright[] copyrights; /** A description of the show. */ @@ -41,8 +38,6 @@ public class ShowSimplified extends AbstractModelObject implements ISearchModelO private final String mediaType; /** The name of the show. */ private final String name; - /** The publisher of the show. */ - private final String publisher; /** The object type. */ private final ModelObjectType type; /** The Spotify URI for the show. */ @@ -55,7 +50,6 @@ public class ShowSimplified extends AbstractModelObject implements ISearchModelO */ public ShowSimplified(Builder builder) { super(builder); - this.availableMarkets = builder.availableMarkets; this.copyrights = builder.copyrights; this.description = builder.description; this.explicit = builder.explicit; @@ -67,21 +61,10 @@ public ShowSimplified(Builder builder) { this.languages = builder.languages; this.mediaType = builder.mediaType; this.name = builder.name; - this.publisher = builder.publisher; this.type = builder.type; this.uri = builder.uri; } - /** - * Get a list of the countries in which the show can be played. - * - * @return An array of ISO 3166-1 alpha-2 country - * * codes. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get the copyright statements of the show. * @@ -183,15 +166,6 @@ public String getName() { return name; } - /** - * Get the publisher of the show. - * - * @return The publisher of the show. - */ - public String getPublisher() { - return publisher; - } - /** * Get the model object type. In this case "show". * @@ -212,11 +186,11 @@ public String getUri() { @Override public String toString() { - return "ShowSimplified(availableMarkets=" + Arrays.toString(availableMarkets) + ", copyrights=" + return "ShowSimplified(copyrights=" + Arrays.toString(copyrights) + ", description=" + description + ", explicit=" + explicit + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id + ", images=" + Arrays.toString(images) + ", isExternallyHosted=" + isExternallyHosted + ", languages=" + Arrays.toString(languages) + ", mediaType=" - + mediaType + ", name=" + name + ", publisher=" + publisher + ", type=" + type + ", uri=" + uri + ")"; + + mediaType + ", name=" + name + ", type=" + type + ", uri=" + uri + ")"; } @Override @@ -228,7 +202,6 @@ public Builder builder() { * Builder class for building {@link ShowSimplified} instances. */ public static final class Builder extends AbstractModelObject.Builder { - private CountryCode[] availableMarkets; private Copyright[] copyrights; private String description; private Boolean explicit; @@ -240,7 +213,6 @@ public static final class Builder extends AbstractModelObject.Builder { private String[] languages; private String mediaType; private String name; - private String publisher; private ModelObjectType type; private String uri; @@ -251,18 +223,6 @@ public Builder() { super(); } - /** - * Set the available markets of the show to be built. - * - * @param availableMarkets A list of the countries in which the show can be played, identified by their - * ISO 3166-1 alpha-2 code. - * @return A {@link ShowSimplified.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set the copyrights of the show to be built. * @@ -384,17 +344,6 @@ public Builder setName(String name) { return this; } - /** - * Set the publisher for the show to be built. - * - * @param publisher The publisher of the show. - * @return A {@link ShowSimplified.Builder}. - */ - public Builder setPublisher(String publisher) { - this.publisher = publisher; - return this; - } - /** * Set the type of the model object. In this case "show". * @@ -442,11 +391,6 @@ public ShowSimplified createModelObject(JsonObject jsonObject) { } return new Builder() - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson( - jsonObject.getAsJsonArray("available_markets"), CountryCode[].class) - : null) .setCopyrights( hasAndNotNull(jsonObject, "copyrights") ? new Gson().fromJson( @@ -495,10 +439,6 @@ public ShowSimplified createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() : null) - .setPublisher( - hasAndNotNull(jsonObject, "publisher") - ? jsonObject.get("publisher").getAsString() - : null) .setType( hasAndNotNull(jsonObject, "type") ? ModelObjectType.keyOf( diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Track.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Track.java index 0386f325e..64cdf541a 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/Track.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/Track.java @@ -1,9 +1,7 @@ package se.michaelthelin.spotify.model_objects.specification; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.model_objects.AbstractModelObject; import se.michaelthelin.spotify.model_objects.IPlaylistItem; @@ -24,16 +22,12 @@ public class Track extends AbstractModelObject implements IArtistTrackModelObjec private final AlbumSimplified album; /** The artists who performed the track. */ private final ArtistSimplified[] artists; - /** A list of the countries in which the track can be played. */ - private final CountryCode[] availableMarkets; /** The disc number. */ private final Integer discNumber; /** The track length in milliseconds. */ private final Integer durationMs; /** Whether the track is explicit. */ private final Boolean explicit; - /** External IDs for the track. */ - private final ExternalId externalIds; /** External URLs for the track. */ private final ExternalUrl externalUrls; /** The Spotify Web API endpoint URL for the track. */ @@ -42,14 +36,10 @@ public class Track extends AbstractModelObject implements IArtistTrackModelObjec private final String id; /** Whether the track is playable. */ private final Boolean isPlayable; - /** Information about the original track. */ - private final TrackLink linkedFrom; /** Restrictions on the track. */ private final Restrictions restrictions; /** The name of the track. */ private final String name; - /** The popularity of the track. */ - private final Integer popularity; /** A link to a 30 second preview of the track. */ private final String previewUrl; /** The number of the track. */ @@ -64,19 +54,15 @@ private Track(final Builder builder) { this.album = builder.album; this.artists = builder.artists; - this.availableMarkets = builder.availableMarkets; this.discNumber = builder.discNumber; this.durationMs = builder.durationMs; this.explicit = builder.explicit; - this.externalIds = builder.externalIds; this.externalUrls = builder.externalUrls; this.href = builder.href; this.id = builder.id; this.isPlayable = builder.isPlayable; - this.linkedFrom = builder.linkedFrom; this.restrictions = builder.restrictions; this.name = builder.name; - this.popularity = builder.popularity; this.previewUrl = builder.previewUrl; this.trackNumber = builder.trackNumber; this.type = builder.type; @@ -103,16 +89,6 @@ public ArtistSimplified[] getArtists() { return artists; } - /** - * Get the country codes of all countries, in which the track is available. - * - * @return A list of the countries in which the track can be played, identified by their - * ISO 3166-1 alpha-2 code. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get the disc number of the track in its album. * @@ -142,16 +118,6 @@ public Boolean getIsExplicit() { return explicit; } - /** - * Get the external IDs of the track.
- * Example: isrc -> "International Standard Recording Code". - * - * @return Known external IDs for the track. - */ - public ExternalId getExternalIds() { - return externalIds; - } - /** * Get the external URLs of the track.
* Example: Spotify-URL. @@ -195,17 +161,6 @@ public Boolean getIsPlayable() { return isPlayable; } - /** - * Get the track link object of the track if - * Track Relinking was applied and the requested track has been replaced with a different track. The track in the - * {@code linked_from} object contains information about the originally requested track. - * - * @return The track in the {@code linked_from} object contains information about the originally requested track. - */ - public TrackLink getLinkedFrom() { - return linkedFrom; - } - /** * Get the restrictions of the track. Part of the response when * Track Relinking is applied, the original @@ -231,24 +186,6 @@ public String getName() { return name; } - /** - * Get the popularity of the track. The value will be between 0 and 100, with 100 being the most popular.

- *

- * The popularity of a track is a value between 0 and 100, with 100 being the most popular. The popularity is - * calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how - * recent those plays are.

- *

- * Generally speaking, songs that are being played a lot now will have a higher popularity than songs that were played - * a lot in the past. Duplicate tracks (e.g. the same track from a single and an album) are rated independently. - * Artist and album popularity is derived mathematically from track popularity. Note that the popularity value may lag - * actual popularity by a few days: the value is not updated in real time. - * - * @return The popularity of the track. The value will be between 0 and 100, with 100 being the most popular. - */ - public Integer getPopularity() { - return popularity; - } - /** * Get a link to a 30 second preview (MP3 format) of the track. {@code null} if not available. * @@ -291,11 +228,11 @@ public String getUri() { @Override public String toString() { - return "Track(name=" + name + ", artists=" + Arrays.toString(artists) + ", album=" + album + ", availableMarkets=" - + Arrays.toString(availableMarkets) + ", discNumber=" + discNumber + ", durationMs=" + durationMs - + ", explicit=" + explicit + ", externalIds=" + externalIds + ", externalUrls=" + externalUrls + ", href=" - + href + ", id=" + id + ", isPlayable=" + isPlayable + ", linkedFrom=" + linkedFrom + ", restrictions=" - + restrictions + ", popularity=" + popularity + ", previewUrl=" + previewUrl + ", trackNumber=" + trackNumber + return "Track(name=" + name + ", artists=" + Arrays.toString(artists) + ", album=" + album + + ", discNumber=" + discNumber + ", durationMs=" + durationMs + + ", explicit=" + explicit + ", externalUrls=" + externalUrls + ", href=" + + href + ", id=" + id + ", isPlayable=" + isPlayable + ", restrictions=" + + restrictions + ", previewUrl=" + previewUrl + ", trackNumber=" + trackNumber + ", type=" + type + ", uri=" + uri + ")"; } @@ -310,19 +247,15 @@ public Builder builder() { public static final class Builder extends AbstractModelObject.Builder { private AlbumSimplified album; private ArtistSimplified[] artists; - private CountryCode[] availableMarkets; private Integer discNumber; private Integer durationMs; private Boolean explicit; - private ExternalId externalIds; private ExternalUrl externalUrls; private String href; private String id; private Boolean isPlayable; - private TrackLink linkedFrom; private Restrictions restrictions; private String name; - private Integer popularity; private String previewUrl; private Integer trackNumber; private ModelObjectType type; @@ -357,18 +290,6 @@ public Builder setArtists(ArtistSimplified... artists) { return this; } - /** - * Set the available markets of the track to be built. - * - * @param availableMarkets A list of the countries in which the track can be played, identified by their - * ISO 3166-1 alpha-2 code. - * @return A {@link Track.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set the disc number of the track to be built. * @@ -403,17 +324,6 @@ public Builder setExplicit(Boolean explicit) { return this; } - /** - * Set the external IDs of the track to be built. - * - * @param externalIds Known external IDs for the track. - * @return A {@link Track.Builder}. - */ - public Builder setExternalIds(ExternalId externalIds) { - this.externalIds = externalIds; - return this; - } - /** * Set external URLs of the track to be built. * @@ -458,18 +368,6 @@ public Builder setIsPlayable(Boolean isPlayable) { return this; } - /** - * Set the track link object of the track to be built. - * - * @param linkedFrom The track in the {@code linked_from} object contains information about the originally requested - * track. - * @return A {@link Track.Builder}. - */ - public Builder setLinkedFrom(TrackLink linkedFrom) { - this.linkedFrom = linkedFrom; - return this; - } - /** * Set the restrictions object of the track to be built. * @@ -493,18 +391,6 @@ public Builder setName(String name) { return this; } - /** - * Set the popularity of the track to be built. - * - * @param popularity The popularity of the track. The value will be between 0 and 100, with 100 being the most - * popular. - * @return A {@link Track.Builder}. - */ - public Builder setPopularity(Integer popularity) { - this.popularity = popularity; - return this; - } - /** * Set the preview URL of the track to be built. * @@ -584,11 +470,6 @@ public Track createModelObject(JsonObject jsonObject) { ? new ArtistSimplified.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("artists")) : null) - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson( - jsonObject.getAsJsonArray("available_markets"), CountryCode[].class) - : null) .setDiscNumber( hasAndNotNull(jsonObject, "disc_number") ? jsonObject.get("disc_number").getAsInt() @@ -601,11 +482,6 @@ public Track createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "explicit") ? jsonObject.get("explicit").getAsBoolean() : null) - .setExternalIds( - hasAndNotNull(jsonObject, "external_ids") - ? new ExternalId.JsonUtil().createModelObject( - jsonObject.getAsJsonObject("external_ids")) - : null) .setExternalUrls( hasAndNotNull(jsonObject, "external_urls") ? new ExternalUrl.JsonUtil().createModelObject( @@ -623,11 +499,6 @@ public Track createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "is_playable") ? jsonObject.get("is_playable").getAsBoolean() : null) - .setLinkedFrom( - hasAndNotNull(jsonObject, "linked_from") - ? new TrackLink.JsonUtil().createModelObject( - jsonObject.get("linked_from").getAsJsonObject()) - : null) .setRestrictions( hasAndNotNull(jsonObject, "restrictions") ? new Restrictions.JsonUtil().createModelObject( @@ -637,10 +508,6 @@ public Track createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() : null) - .setPopularity( - hasAndNotNull(jsonObject, "popularity") - ? jsonObject.get("popularity").getAsInt() - : null) .setPreviewUrl( hasAndNotNull(jsonObject, "preview_url") ? jsonObject.get("preview_url").getAsString() diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/TrackSimplified.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/TrackSimplified.java index c715cb510..588999ab7 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/TrackSimplified.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/TrackSimplified.java @@ -1,9 +1,7 @@ package se.michaelthelin.spotify.model_objects.specification; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.ModelObjectType; import se.michaelthelin.spotify.model_objects.AbstractModelObject; @@ -18,8 +16,6 @@ public class TrackSimplified extends AbstractModelObject { /** The artists who performed the track. */ private final ArtistSimplified[] artists; - /** A list of the countries in which the track can be played. */ - private final CountryCode[] availableMarkets; /** The disc number. */ private final Integer discNumber; /** The track length in milliseconds. */ @@ -34,8 +30,6 @@ public class TrackSimplified extends AbstractModelObject { private final String id; /** Whether the track is playable. */ private final Boolean isPlayable; - /** Information about the original track. */ - private final TrackLink linkedFrom; /** The name of the track. */ private final String name; /** A link to a 30 second preview of the track. */ @@ -51,7 +45,6 @@ private TrackSimplified(final Builder builder) { super(builder); this.artists = builder.artists; - this.availableMarkets = builder.availableMarkets; this.discNumber = builder.discNumber; this.durationMs = builder.durationMs; this.explicit = builder.explicit; @@ -59,7 +52,6 @@ private TrackSimplified(final Builder builder) { this.href = builder.href; this.id = builder.id; this.isPlayable = builder.isPlayable; - this.linkedFrom = builder.linkedFrom; this.name = builder.name; this.previewUrl = builder.previewUrl; this.trackNumber = builder.trackNumber; @@ -77,16 +69,6 @@ public ArtistSimplified[] getArtists() { return artists; } - /** - * Get the country codes of all countries, in which the track is available. - * - * @return A list of the countries in which the track can be played, identified by their - * ISO 3166-1 alpha-2 code. - */ - public CountryCode[] getAvailableMarkets() { - return availableMarkets; - } - /** * Get the disc number of the track in its album. * @@ -155,17 +137,6 @@ public Boolean getIsPlayable() { return isPlayable; } - /** - * Get the track link object of the track if - * Track Relinking was applied and the requested track has been replaced with a different track. The track in the - * {@code linked_from} object contains information about the originally requested track. - * - * @return The track in the {@code linked_from} object contains information about the originally requested track. - */ - public TrackLink getLinkedFrom() { - return linkedFrom; - } - /** * Get the name of a track. * @@ -215,10 +186,9 @@ public String getUri() { @Override public String toString() { - return "TrackSimplified(name=" + name + ", artists=" + Arrays.toString(artists) + ", availableMarkets=" - + Arrays.toString(availableMarkets) + ", discNumber=" + discNumber + ", durationMs=" + durationMs - + ", explicit=" + explicit + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id - + ", isPlayable=" + isPlayable + ", linkedFrom=" + linkedFrom + ", previewUrl=" + previewUrl + ", trackNumber=" + return "TrackSimplified(name=" + name + ", artists=" + Arrays.toString(artists) + ", discNumber=" + discNumber + + ", durationMs=" + durationMs + ", explicit=" + explicit + ", externalUrls=" + externalUrls + ", href=" + href + + ", id=" + id + ", isPlayable=" + isPlayable + ", previewUrl=" + previewUrl + ", trackNumber=" + trackNumber + ", type=" + type + ", uri=" + uri + ")"; } @@ -232,7 +202,6 @@ public Builder builder() { */ public static final class Builder extends AbstractModelObject.Builder { private ArtistSimplified[] artists; - private CountryCode[] availableMarkets; private Integer discNumber; private Integer durationMs; private Boolean explicit; @@ -240,7 +209,6 @@ public static final class Builder extends AbstractModelObject.Builder { private String href; private String id; private Boolean isPlayable; - private TrackLink linkedFrom; private String name; private String previewUrl; private Integer trackNumber; @@ -265,18 +233,6 @@ public Builder setArtists(ArtistSimplified... artists) { return this; } - /** - * Set the available markets of the track to be built. - * - * @param availableMarkets A list of the countries in which the track can be played, identified by their - * ISO 3166-1 alpha-2 code. - * @return A {@link TrackSimplified.Builder}. - */ - public Builder setAvailableMarkets(CountryCode... availableMarkets) { - this.availableMarkets = availableMarkets; - return this; - } - /** * Set the disc number of the track to be built. * @@ -355,18 +311,6 @@ public Builder setIsPlayable(Boolean isPlayable) { return this; } - /** - * Set the track link object of the track to be built. - * - * @param linkedFrom The track in the {@code linked_from} object contains information about the originally requested - * track. - * @return A {@link TrackSimplified.Builder}. - */ - public Builder setLinkedFrom(TrackLink linkedFrom) { - this.linkedFrom = linkedFrom; - return this; - } - /** * Set the name of the track to be built. * @@ -452,11 +396,6 @@ public TrackSimplified createModelObject(JsonObject jsonObject) { ? new ArtistSimplified.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("artists")) : null) - .setAvailableMarkets( - hasAndNotNull(jsonObject, "available_markets") - ? new Gson().fromJson(jsonObject.getAsJsonArray( - "available_markets"), CountryCode[].class) - : null) .setDiscNumber( hasAndNotNull(jsonObject, "disc_number") ? jsonObject.get("disc_number").getAsInt() @@ -486,11 +425,6 @@ public TrackSimplified createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "is_playable") ? jsonObject.get("is_playable").getAsBoolean() : null) - .setLinkedFrom( - hasAndNotNull(jsonObject, "linked_from") - ? new TrackLink.JsonUtil().createModelObject( - jsonObject.get("linked_from").getAsJsonObject()) - : null) .setName( hasAndNotNull(jsonObject, "name") ? jsonObject.get("name").getAsString() diff --git a/src/main/java/se/michaelthelin/spotify/model_objects/specification/User.java b/src/main/java/se/michaelthelin/spotify/model_objects/specification/User.java index d502fdd3a..d09c3bc29 100644 --- a/src/main/java/se/michaelthelin/spotify/model_objects/specification/User.java +++ b/src/main/java/se/michaelthelin/spotify/model_objects/specification/User.java @@ -2,9 +2,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.gson.JsonObject; -import com.neovisionaries.i18n.CountryCode; import se.michaelthelin.spotify.enums.ModelObjectType; -import se.michaelthelin.spotify.enums.ProductType; import se.michaelthelin.spotify.model_objects.AbstractModelObject; import java.util.Arrays; @@ -22,24 +20,16 @@ public class User extends AbstractModelObject { /** The user's birthdate. */ private final String birthdate; - /** The country of the user. */ - private final CountryCode country; /** The name displayed on the user's profile. */ private final String displayName; - /** The user's email address. */ - private final String email; /** External URLs for the user. */ private final ExternalUrl externalUrls; - /** Information about the followers of the user. */ - private final Followers followers; /** The Spotify Web API endpoint URL for the user. */ private final String href; /** The Spotify user ID for the user. */ private final String id; /** The user's profile image. */ private final Image[] images; - /** The user's Spotify subscription level. */ - private final ProductType product; /** The object type. */ private final ModelObjectType type; /** The Spotify URI for the user. */ @@ -49,15 +39,11 @@ private User(final Builder builder) { super(builder); this.birthdate = builder.birthdate; - this.country = builder.country; this.displayName = builder.displayName; - this.email = builder.email; this.externalUrls = builder.externalUrls; - this.followers = builder.followers; this.href = builder.href; this.id = builder.id; this.images = builder.images; - this.product = builder.product; this.type = builder.type; this.uri = builder.uri; } @@ -74,18 +60,6 @@ public String getBirthdate() { return birthdate; } - /** - * Get the country code of the users set home country.
- * Note: This field is only available when the current user has granted access to the {@code user-read-private} - * scope. - * - * @return An ISO 3166-1 alpha-2 country code. - * @see Spotify: Using Scopes - */ - public CountryCode getCountry() { - return country; - } - /** * Get the users display name if available.
* If the display name is not available, {@code null} will be returned. @@ -96,19 +70,6 @@ public String getDisplayName() { return displayName; } - /** - * Get the users email address.
- * Important! This email address is unverified; there is no proof that it actually belongs to the user.
- * Note: This field is only available when the current user has granted access to the {@code user-read-email} - * scope. - * - * @return The user's email address, as entered by the user when creating their account. - * @see Spotify: Using Scopes - */ - public String getEmail() { - return email; - } - /** * Get the external URLs of the user.
* Example: Spotify-URL. @@ -119,16 +80,6 @@ public ExternalUrl getExternalUrls() { return externalUrls; } - /** - * Get information about the followers of the user.
- * Example: Follower count. - * - * @return Information about the followers of the user. - */ - public Followers getFollowers() { - return followers; - } - /** * Get the Spotify Web API endpoint URL of the user. * @@ -157,19 +108,6 @@ public Image[] getImages() { return images; } - /** - * Get the product type of the users account.
- * Product type refers to premium account, free account, etc.
- * Note: This field is only available when the current user has granted access to the {@code user-read-private} - * scope. - * - * @return The user's Spotify subscription level: "premium", "free", etc. - * @see Spotify: Using Scopes - */ - public ProductType getProduct() { - return product; - } - /** * Get the model object type. In this case "user". * @@ -191,9 +129,9 @@ public String getUri() { @Override public String toString() { - return "User(birthdate=" + birthdate + ", country=" + country + ", displayName=" + displayName + ", email=" + email - + ", externalUrls=" + externalUrls + ", followers=" + followers + ", href=" + href + ", id=" + id + ", images=" - + Arrays.toString(images) + ", product=" + product + ", type=" + type + ", uri=" + uri + ")"; + return "User(birthdate=" + birthdate + ", displayName=" + displayName + + ", externalUrls=" + externalUrls + ", href=" + href + ", id=" + id + ", images=" + + Arrays.toString(images) + ", type=" + type + ", uri=" + uri + ")"; } @Override @@ -206,15 +144,11 @@ public Builder builder() { */ public static final class Builder extends AbstractModelObject.Builder { private String birthdate; - private CountryCode country; private String displayName; - private String email; private ExternalUrl externalUrls; - private Followers followers; private String href; private String id; private Image[] images; - private ProductType product; private ModelObjectType type; private String uri; @@ -236,17 +170,6 @@ public Builder setBirthdate(String birthdate) { return this; } - /** - * Set the home country of the user object to be built. - * - * @param country An ISO 3166-1 alpha-2 country code. - * @return A {@link User.Builder}. - */ - public Builder setCountry(CountryCode country) { - this.country = country; - return this; - } - /** * Set the display name of the user to be built. If the user hasn't a display name, set {@code null} instead. * @@ -258,17 +181,6 @@ public Builder setDisplayName(String displayName) { return this; } - /** - * Set the email address of the user to be built. - * - * @param email The user's email address, as entered by the user when creating their account. - * @return A {@link User.Builder}. - */ - public Builder setEmail(String email) { - this.email = email; - return this; - } - /** * Set external urls of the user to be built. * @@ -280,17 +192,6 @@ public Builder setExternalUrls(ExternalUrl externalUrls) { return this; } - /** - * Set the followers object of the user to be built. - * - * @param followers Information about the followers of the user. - * @return A {@link User.Builder}. - */ - public Builder setFollowers(Followers followers) { - this.followers = followers; - return this; - } - /** * Set href of Spotify api endpoint of the user to be built. * @@ -325,17 +226,6 @@ public Builder setImages(Image... images) { return this; } - /** - * Set the product type of the user to be built. - * - * @param product The user's Spotify subscription level: "premium", "free", etc. - * @return A {@link User.Builder}. - */ - public Builder setProduct(ProductType product) { - this.product = product; - return this; - } - /** * Set the type of the model object. In this case "user". * @@ -386,29 +276,15 @@ public User createModelObject(JsonObject jsonObject) { hasAndNotNull(jsonObject, "birthdate") ? jsonObject.get("birthdate").getAsString() : null) - .setCountry( - hasAndNotNull(jsonObject, "country") - ? CountryCode.getByCode( - jsonObject.get("country").getAsString()) - : null) .setDisplayName( hasAndNotNull(jsonObject, "display_name") ? jsonObject.get("display_name").getAsString() : null) - .setEmail( - hasAndNotNull(jsonObject, "email") - ? jsonObject.get("email").getAsString() - : null) .setExternalUrls( hasAndNotNull(jsonObject, "external_urls") ? new ExternalUrl.JsonUtil().createModelObject( jsonObject.getAsJsonObject("external_urls")) : null) - .setFollowers( - hasAndNotNull(jsonObject, "followers") - ? new Followers.JsonUtil().createModelObject( - jsonObject.getAsJsonObject("followers")) - : null) .setHref( hasAndNotNull(jsonObject, "href") ? jsonObject.get("href").getAsString() @@ -422,11 +298,6 @@ public User createModelObject(JsonObject jsonObject) { ? new Image.JsonUtil().createModelObjectArray( jsonObject.getAsJsonArray("images")) : null) - .setProduct( - hasAndNotNull(jsonObject, "product") - ? ProductType.keyOf( - jsonObject.get("product").getAsString().toLowerCase()) - : null) .setType( hasAndNotNull(jsonObject, "type") ? ModelObjectType.keyOf( diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequest.java deleted file mode 100644 index 4047b38f3..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -package se.michaelthelin.spotify.requests.data.albums; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Album; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information for multiple albums identified by their Spotify IDs. - */ -@JsonDeserialize(builder = GetSeveralAlbumsRequest.Builder.class) -public class GetSeveralAlbumsRequest extends AbstractDataRequest { - - /** - * The private {@link GetSeveralAlbumsRequest} constructor. - * - * @param builder A {@link GetSeveralAlbumsRequest.Builder}. - */ - private GetSeveralAlbumsRequest(final Builder builder) { - super(builder); - } - - /** - * Get multiple albums. - * - * @return An array containing albums. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Album[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Album.JsonUtil().createModelObjectArray(getJson(), "albums"); - } - - /** - * Builder class for building a {@link GetSeveralAlbumsRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetSeveralAlbumsRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The IDs query parameter setter. - * - * @param ids Required. A comma-separated list of the Spotify IDs for the albums. Maximum: 20 IDs. - * @return A {@link GetSeveralAlbumsRequest.Builder}. - * @see Spotify URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 20); - return setQueryParameter("ids", ids); - } - - /** - * The market query parameter setter. - * - * @param market Optional. An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track - * Relinking. - * @return A {@link GetSeveralAlbumsRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - * @see Spotify: Track Relinking Guide - */ - public Builder market(final CountryCode market) { - assert (market != null); - return setQueryParameter("market", market); - } - - /** - * The request build method. - * - * @return A custom {@link GetSeveralAlbumsRequest}. - */ - @Override - public GetSeveralAlbumsRequest build() { - setPath("/v1/albums"); - return new GetSeveralAlbumsRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequest.java deleted file mode 100644 index a819cbdb2..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequest.java +++ /dev/null @@ -1,96 +0,0 @@ -package se.michaelthelin.spotify.requests.data.artists; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Track; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information about an artist’s top tracks by country. - */ -@JsonDeserialize(builder = GetArtistsTopTracksRequest.Builder.class) -public class GetArtistsTopTracksRequest extends AbstractDataRequest { - - /** - * The private {@link GetArtistsTopTracksRequest} constructor. - * - * @param builder A {@link GetArtistsTopTracksRequest.Builder}. - */ - private GetArtistsTopTracksRequest(final Builder builder) { - super(builder); - } - - /** - * Get the top {@link Track} objects. - * - * @return An array of {@link Track} objects. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Track[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Track.JsonUtil().createModelObjectArray(getJson(), "tracks"); - } - - /** - * Builder class for building a {@link GetArtistsTopTracksRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetArtistsTopTracksRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The artist ID setter. - * - * @param id The Spotify ID for the artist. - * @return A {@link GetArtistsTopTracksRequest.Builder}. - * @see Spotify URIs & IDs - */ - public Builder id(final String id) { - assert (id != null); - assert (!id.isEmpty()); - return setPathParameter("id", id); - } - - /** - * The country code setter. - * - * @param country Required. The country: an ISO 3166-1 alpha-2 country code. - * @return A {@link GetArtistsTopTracksRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder country(final CountryCode country) { - assert (country != null); - return setQueryParameter("country", country); - } - - /** - * The request build method. - * - * @return A custom {@link GetArtistsTopTracksRequest}. - */ - @Override - public GetArtistsTopTracksRequest build() { - setPath("/v1/artists/{id}/top-tracks"); - return new GetArtistsTopTracksRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequest.java deleted file mode 100644 index 653574812..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -package se.michaelthelin.spotify.requests.data.artists; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Artist; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information for several artists based on their Spotify IDs. - */ -@JsonDeserialize(builder = GetSeveralArtistsRequest.Builder.class) -public class GetSeveralArtistsRequest extends AbstractDataRequest { - - /** - * The private {@link GetSeveralArtistsRequest} constructor. - * - * @param builder A {@link GetSeveralArtistsRequest.Builder}. - */ - private GetSeveralArtistsRequest(final Builder builder) { - super(builder); - } - - /** - * Get several {@link Artist} objects. - * - * @return An array with {@link Artist} objects. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Artist[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Artist.JsonUtil().createModelObjectArray(getJson(), "artists"); - } - - /** - * Builder class for building a {@link GetSeveralArtistsRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetSeveralArtistsRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The artist IDs setter. - * - * @param ids Required. A comma-separated list of the Spotify IDs for the artists. Maximum: 50 IDs. - * @return A {@link GetSeveralArtistsRequest.Builder}. - * @see Spotify URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link GetSeveralArtistsRequest}. - */ - @Override - public GetSeveralArtistsRequest build() { - setPath("/v1/artists"); - return new GetSeveralArtistsRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequest.java deleted file mode 100644 index a40f060bf..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequest.java +++ /dev/null @@ -1,124 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import com.neovisionaries.i18n.LanguageCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Category; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get a single category used to tag items in Spotify (on, for example, the Spotify player’s "Browse" tab). - */ -@JsonDeserialize(builder = GetCategoryRequest.Builder.class) -public class GetCategoryRequest extends AbstractDataRequest { - - /** - * The private {@link GetCategoryRequest} constructor. - * - * @param builder A {@link GetCategoryRequest.Builder}. - */ - private GetCategoryRequest(final Builder builder) { - super(builder); - } - - /** - * Get a {@link Category}. - * - * @return A {@link Category}. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Category execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Category.JsonUtil().createModelObject(getJson()); - } - - /** - * Builder class for building a {@link GetCategoryRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetCategoryRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The category ID setter. - * - * @param category_id The Spotify category ID for the category. - * @return A {@link GetCategoryRequest.Builder}. - * @see Spotify URIs & IDs - */ - public Builder category_id(final String category_id) { - assert (category_id != null); - assert (category_id.matches("^[a-z]+$")); - return setPathParameter("category_id", category_id); - } - - /** - * The country code setter. - * - * @param country Optional. A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want to - * narrow the list of returned categories to those relevant to a particular country. If omitted, the - * returned items will be globally relevant. - * @return A {@link GetCategoryRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder country(final CountryCode country) { - assert (country != null); - return setQueryParameter("country", country); - } - - /** - * The language code setter. - * - * @param locale Optional. The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 - * country code, joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)". Provide this - * parameter if you want the category metadata returned in a particular language. Note that, if locale - * is not supplied, or if the specified language is not available, all strings will be returned in the - * Spotify default language (American English). The locale parameter, combined with the country - * parameter, may give odd results if not carefully matched. For example - * {@code country=SE&locale=de_DE} will return a list of categories relevant to Sweden but as German - * language strings. - * @return A {@link GetCategoryRequest.Builder} - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - * @see Wikipedia: ISO 639 language code - */ - public Builder locale(final String locale) { - assert (locale != null); - assert (locale.contains("_")); - String[] localeParts = locale.split("_"); - assert (localeParts.length == 2); - assert (LanguageCode.getByCode(localeParts[0]) != null); - assert (CountryCode.getByCode(localeParts[1]) != null); - return setQueryParameter("locale", locale); - } - - /** - * The request build method. - * - * @return A custom {@link GetCategoryRequest}. - */ - @Override - public GetCategoryRequest build() { - setPath("/v1/browse/categories/{category_id}"); - return new GetCategoryRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequest.java deleted file mode 100644 index 64a89e9d5..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequest.java +++ /dev/null @@ -1,138 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import com.neovisionaries.i18n.LanguageCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Category; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.requests.data.AbstractDataPagingRequest; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s "Browse" tab). - */ -@JsonDeserialize(builder = GetListOfCategoriesRequest.Builder.class) -public class GetListOfCategoriesRequest extends AbstractDataRequest> { - - /** - * The private {@link GetListOfCategoriesRequest} constructor. - * - * @param builder A {@link GetListOfCategoriesRequest.Builder}. - */ - private GetListOfCategoriesRequest(final Builder builder) { - super(builder); - } - - /** - * Get a paging of {@link Category} objects. - * - * @return A {@link Category} paging. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Paging execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Category.JsonUtil().createModelObjectPaging(getJson(), "categories"); - } - - /** - * Builder class for building a {@link GetListOfCategoriesRequest}. - */ - public static final class Builder extends AbstractDataPagingRequest.Builder { - - /** - * Create a new {@link GetListOfCategoriesRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The country code setter. - * - * @param country Optional. A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want to - * narrow the list of returned categories to those relevant to a particular country. If omitted, the - * returned items will be globally relevant. - * @return A {@link GetListOfCategoriesRequest.Builder} - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder country(final CountryCode country) { - assert (country != null); - return setQueryParameter("country", country); - } - - /** - * The language code setter. - * - * @param locale Optional. The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 - * country code, joined by an underscore. For example: es_MX, meaning "Spanish (Mexico)". Provide this - * parameter if you want the category metadata returned in a particular language. Note that, if locale - * is not supplied, or if the specified language is not available, all strings will be returned in the - * Spotify default language (American English). The locale parameter, combined with the country - * parameter, may give odd results if not carefully matched. For example - * {@code country=SE&locale=de_DE} will return a list of categories relevant to Sweden but as German - * language strings. - * @return A {@link GetListOfCategoriesRequest.Builder} - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - * @see Wikipedia: ISO 639 language code - */ - public Builder locale(final String locale) { - assert (locale != null); - assert (locale.contains("_")); - String[] localeParts = locale.split("_"); - assert (localeParts.length == 2); - assert (LanguageCode.getByCode(localeParts[0]) != null); - assert (CountryCode.getByCode(localeParts[1]) != null); - return setQueryParameter("locale", locale); - } - - /** - * The limit setter. - * - * @param limit Optional. The maximum number of categories to return. Default: 20. Minimum: 1. Maximum: 50. - * @return A {@link GetListOfCategoriesRequest.Builder}. - */ - @Override - public Builder limit(Integer limit) { - assert (1 <= limit && limit <= 50); - return setQueryParameter("limit", limit); - } - - /** - * The offset setter. - * - * @param offset Optional. The index of the first item to return. Default: 0 (the first object). Use with - * {@link #limit(Integer)} to get the next set of categories. - * @return A {@link GetListOfCategoriesRequest.Builder}. - */ - @Override - public Builder offset(Integer offset) { - assert (offset >= 0); - return setQueryParameter("offset", offset); - } - - /** - * The request build method. - * - * @return A custom {@link GetListOfCategoriesRequest}. - */ - @Override - public GetListOfCategoriesRequest build() { - setPath("/v1/browse/categories"); - return new GetListOfCategoriesRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequest.java deleted file mode 100644 index f32094517..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.requests.data.AbstractDataPagingRequest; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get a list of new album releases featured in Spotify (shown, for example, on a Spotify player’s "Browse" tab). - */ -@JsonDeserialize(builder = GetListOfNewReleasesRequest.Builder.class) -public class GetListOfNewReleasesRequest extends AbstractDataRequest> { - - /** - * The private {@link GetListOfNewReleasesRequest} constructor. - * - * @param builder A {@link GetListOfNewReleasesRequest.Builder}. - */ - private GetListOfNewReleasesRequest(final Builder builder) { - super(builder); - } - - /** - * Get a paging of new {@link AlbumSimplified} releases. - * - * @return An {@link AlbumSimplified} paging. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Paging execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new AlbumSimplified.JsonUtil().createModelObjectPaging(getJson(), "albums"); - } - - /** - * Builder class for building a {@link GetListOfNewReleasesRequest}. - */ - public static final class Builder extends AbstractDataPagingRequest.Builder { - - /** - * Create a new {@link GetListOfNewReleasesRequest.Builder} instance. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The country code setter. - * - * @param country Optional. A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want the - * list of returned items to be relevant to a particular country. If omitted, the returned items will - * be relevant to all countries. - * @return A {@link GetListOfNewReleasesRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder country(final CountryCode country) { - assert (country != null); - return setQueryParameter("country", country); - } - - /** - * The limit setter. - * - * @param limit Optional. The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. - * @return A {@link GetListOfNewReleasesRequest.Builder}. - */ - @Override - public Builder limit(final Integer limit) { - assert (1 <= limit && limit <= 50); - return setQueryParameter("limit", limit); - } - - /** - * The offset setter. - * - * @param offset Optional. The index of the first item to return. Default: 0 (the first object). Use with - * {@link #limit(Integer)} to get the next set of items. - * @return A {@link GetListOfNewReleasesRequest.Builder}. - */ - @Override - public Builder offset(final Integer offset) { - assert (offset >= 0); - return setQueryParameter("offset", offset); - } - - /** - * The request build method. - * - * @return A custom {@link GetListOfNewReleasesRequest}. - */ - @Override - public GetListOfNewReleasesRequest build() { - setPath("/v1/browse/new-releases"); - return new GetListOfNewReleasesRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequest.java deleted file mode 100644 index 3d6d41d40..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.michaelthelin.spotify.requests.data.episodes; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Episode; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information for multiple episodes based on their Spotify IDs. - */ -@JsonDeserialize(builder = GetSeveralEpisodesRequest.Builder.class) -public class GetSeveralEpisodesRequest extends AbstractDataRequest { - - /** - * The private {@link GetSeveralEpisodesRequest} constructor. - * - * @param builder A {@link GetSeveralEpisodesRequest.Builder}. - */ - private GetSeveralEpisodesRequest(final Builder builder) { - super(builder); - } - - /** - * Get several episodes. - * - * @return Multiple {@link Episode} objects. - * @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 Episode[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Episode.JsonUtil().createModelObjectArray(getJson(), "episodes"); - } - - /** - * Builder class for building a {@link GetSeveralEpisodesRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetSeveralEpisodesRequest.Builder}. - *

- * Reading the user’s resume points on episode objects requires the {@code user-read-playback-position} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The episode IDs setter. - * - * @param ids Required. A comma-separated list of the Spotify IDs for the episodes. Maximum: 50 IDs. - * @return A {@link GetSeveralEpisodesRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The market country code setter.

- * If a country code is specified, only shows and episodes that are available in that market will be returned. - * If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter. - * Note: If neither market or user country are provided, the content is considered unavailable for the client.

- * Users can view the country that is associated with their account in the account settings. - * - * @param market Optional. An ISO 3166-1 alpha-2 country code. - * @return A {@link GetSeveralEpisodesRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder market(final CountryCode market) { - assert (market != null); - return setQueryParameter("market", market); - } - - /** - * The request build method. - * - * @return A custom {@link GetSeveralEpisodesRequest}. - */ - @Override - public GetSeveralEpisodesRequest build() { - setPath("/v1/episodes"); - return new GetSeveralEpisodesRequest(this); - } - - @Override - protected GetSeveralEpisodesRequest.Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequest.java deleted file mode 100644 index a07e32152..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequest.java +++ /dev/null @@ -1,104 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Remove one or more albums from the current user’s "Your Music" library. - */ -@JsonDeserialize(builder = RemoveAlbumsForCurrentUserRequest.Builder.class) -public class RemoveAlbumsForCurrentUserRequest extends AbstractDataRequest { - - /** - * The private {@link RemoveAlbumsForCurrentUserRequest} constructor. - * - * @param builder A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - */ - private RemoveAlbumsForCurrentUserRequest(final Builder builder) { - super(builder); - } - - /** - * Remove one or more albums from the current user’s ‘Your Music’ library. - * - * @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. - */ - public String execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return deleteJson(); - } - - /** - * Builder class for building a {@link RemoveAlbumsForCurrentUserRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link RemoveAlbumsForCurrentUserRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The album IDs setter. - * - * @param ids Optional. A comma-separated list of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The album IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * @param ids Optional. A JSON array of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link RemoveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link RemoveAlbumsForCurrentUserRequest.Builder}. - */ - @Override - public RemoveAlbumsForCurrentUserRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/albums"); - return new RemoveAlbumsForCurrentUserRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveFromLibraryRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveFromLibraryRequest.java new file mode 100644 index 000000000..39f482432 --- /dev/null +++ b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveFromLibraryRequest.java @@ -0,0 +1,92 @@ +package se.michaelthelin.spotify.requests.data.library; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.gson.JsonArray; +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; + +/** + * Remove a list of Spotify URIs from the user's library. + */ +@JsonDeserialize(builder = RemoveFromLibraryRequest.Builder.class) +public class RemoveFromLibraryRequest extends AbstractDataRequest { + + /** + * The private {@link RemoveFromLibraryRequest} constructor. + * + * @param builder A {@link RemoveFromLibraryRequest.Builder}. + */ + private RemoveFromLibraryRequest(final Builder builder) { + super(builder); + } + + /** + * Remove items from the user's library. + * + * @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. + */ + public String execute() throws + IOException, + SpotifyWebApiException, + ParseException { + return deleteJson(); + } + + /** + * Builder class for building a {@link RemoveFromLibraryRequest}. + */ + public static final class Builder extends AbstractDataRequest.Builder { + + /** + * Create a new {@link RemoveFromLibraryRequest.Builder} instance. + *

+ * Modification of the current user's library requires authorization of the + * {@code user-library-modify} scope. + * + * @param accessToken Required. A valid access token from the Spotify Accounts service. + * @see Spotify: Using Scopes + */ + public Builder(final String accessToken) { + super(accessToken); + } + + /** + * The URIs setter. + * + * @param uris Required. The Spotify URIs to remove. Maximum: 50 URIs. + * @return A {@link RemoveFromLibraryRequest.Builder}. + */ + public Builder uris(final String... uris) { + assert (uris != null); + assert (uris.length <= 50); + final JsonArray urisArray = new JsonArray(); + for (final String uri : uris) { + urisArray.add(uri); + } + return setBodyParameter("uris", urisArray); + } + + /** + * The request build method. + * + * @return A custom {@link RemoveFromLibraryRequest}. + */ + @Override + public RemoveFromLibraryRequest build() { + setContentType(ContentType.APPLICATION_JSON); + setPath("/v1/me/library"); + return new RemoveFromLibraryRequest(this); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequest.java deleted file mode 100644 index 2f2f70967..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequest.java +++ /dev/null @@ -1,106 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Remove one or more episodes from the current user's library. - */ -@JsonDeserialize(builder = RemoveUsersSavedEpisodesRequest.Builder.class) -public class RemoveUsersSavedEpisodesRequest extends AbstractDataRequest { - - /** - * The private {@link RemoveUsersSavedEpisodesRequest} constructor. - * - * @param builder A {@link RemoveUsersSavedEpisodesRequest.Builder}. - */ - private RemoveUsersSavedEpisodesRequest(final RemoveUsersSavedEpisodesRequest.Builder builder) { - super(builder); - } - - /** - * Remove one or more episodes from current Spotify user’s library. - * - * @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 deleteJson(); - } - - /** - * Builder class for building a {@link RemoveUsersSavedEpisodesRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link RemoveUsersSavedEpisodesRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The episode IDs setter. - * - * @param ids Optional. A comma-separated list of Spotify IDs for the episodes to be deleted from the user’s library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedEpisodesRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public RemoveUsersSavedEpisodesRequest.Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The episode IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * - * @param ids Optional. A JSON array of Spotify IDs for the episodes to be deleted from the user’s library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedEpisodesRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public RemoveUsersSavedEpisodesRequest.Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link RemoveUsersSavedEpisodesRequest}. - */ - @Override - public RemoveUsersSavedEpisodesRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/episodes"); - return new RemoveUsersSavedEpisodesRequest(this); - } - - @Override - protected RemoveUsersSavedEpisodesRequest.Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequest.java deleted file mode 100644 index 305271bdd..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequest.java +++ /dev/null @@ -1,122 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -import com.neovisionaries.i18n.CountryCode; -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; - -/** - * Delete one or more shows from current Spotify user’s library. - */ -@JsonDeserialize(builder = RemoveUsersSavedShowsRequest.Builder.class) -public class RemoveUsersSavedShowsRequest extends AbstractDataRequest { - - /** - * The private {@link RemoveUsersSavedShowsRequest} constructor. - * - * @param builder A {@link RemoveUsersSavedShowsRequest.Builder}. - */ - private RemoveUsersSavedShowsRequest(final Builder builder) { - super(builder); - } - - /** - * Delete one or more shows from current Spotify user’s library. - * - * @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 deleteJson(); - } - - /** - * Builder class for building a {@link RemoveUsersSavedShowsRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link RemoveUsersSavedShowsRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The show IDs setter. - * - * @param ids Optional. A comma-separated list of Spotify IDs for the shows to be deleted from the user’s library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedShowsRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The market country code setter.

- * If a country code is specified, only shows that are available in that market will be removed. - * If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter. - * Note: If neither market or user country are provided, the content is considered unavailable for the client.

- * Users can view the country that is associated with their account in the account settings. - * - * @param market Optional. An ISO 3166-1 alpha-2 country code. - * @return A {@link RemoveUsersSavedShowsRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public Builder market(final CountryCode market) { - assert (market != null); - return setQueryParameter("market", market); - } - - /** - * The show IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * @param ids Optional. A JSON array of Spotify IDs for the shows to be deleted from the user’s library. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedShowsRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link RemoveUsersSavedShowsRequest}. - */ - @Override - public RemoveUsersSavedShowsRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/shows"); - return new RemoveUsersSavedShowsRequest(this); - } - - @Override - protected RemoveUsersSavedShowsRequest.Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequest.java deleted file mode 100644 index 1d7dc8aba..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequest.java +++ /dev/null @@ -1,104 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Remove one or more tracks from the current user’s "Your Music" library. - */ -@JsonDeserialize(builder = RemoveUsersSavedTracksRequest.Builder.class) -public class RemoveUsersSavedTracksRequest extends AbstractDataRequest { - - /** - * The private {@link RemoveUsersSavedTracksRequest} constructor. - * - * @param builder A {@link RemoveUsersSavedTracksRequest.Builder}. - */ - private RemoveUsersSavedTracksRequest(final Builder builder) { - super(builder); - } - - /** - * Remove one or more tracks from the current user’s ‘Your Music’ library. - * - * @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. - */ - public String execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return deleteJson(); - } - - /** - * Builder class for building a {@link RemoveUsersSavedTracksRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link RemoveUsersSavedTracksRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The track IDs setter. - * - * @param ids Optional. A comma-separated list of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedTracksRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The track IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * @param ids Optional. A JSON array of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link RemoveUsersSavedTracksRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link RemoveUsersSavedTracksRequest}. - */ - @Override - public RemoveUsersSavedTracksRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/tracks"); - return new RemoveUsersSavedTracksRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequest.java deleted file mode 100644 index 224497c21..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Save one or more albums to the current user’s "Your Music" library. - */ -@JsonDeserialize(builder = SaveAlbumsForCurrentUserRequest.Builder.class) -public class SaveAlbumsForCurrentUserRequest extends AbstractDataRequest { - - /** - * The private {@link SaveAlbumsForCurrentUserRequest} constructor. - * - * @param builder A {@link SaveAlbumsForCurrentUserRequest.Builder}. - */ - private SaveAlbumsForCurrentUserRequest(final Builder builder) { - super(builder); - } - - /** - * Save an album to the "Your Music" library. - * - * @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. - */ - public String execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return putJson(); - } - - /** - * Builder class for building a {@link SaveAlbumsForCurrentUserRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link SaveAlbumsForCurrentUserRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The album IDs setter. - * - * @param ids Optional. A comma-separated list of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link SaveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The album IDs setter. - * - * @param ids Optional. A json array consisting of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link SaveAlbumsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link SaveAlbumsForCurrentUserRequest}. - */ - @Override - public SaveAlbumsForCurrentUserRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/albums"); - return new SaveAlbumsForCurrentUserRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequest.java deleted file mode 100644 index e96c10e40..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequest.java +++ /dev/null @@ -1,107 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Save one or more episodes to the current user's library. - */ -@JsonDeserialize(builder = SaveEpisodesForCurrentUserRequest.Builder.class) -public class SaveEpisodesForCurrentUserRequest extends AbstractDataRequest { - - /** - * The private {@link SaveEpisodesForCurrentUserRequest} constructor. - * - * @param builder A {@link SaveEpisodesForCurrentUserRequest.Builder}. - */ - private SaveEpisodesForCurrentUserRequest(final SaveEpisodesForCurrentUserRequest.Builder builder) { - super(builder); - } - - /** - * Save one or more episodes. - * - * @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 putJson(); - } - - /** - * Builder class for building a {@link SaveEpisodesForCurrentUserRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link SaveEpisodesForCurrentUserRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Scopes - */ - public Builder(String accessToken) { - super(accessToken); - } - - /** - * The episode IDs setter. - * - * @param ids Optional. A comma-separated list of Spotify IDs for the episodes to be added to the user’s library. - * @return A {@link SaveEpisodesForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public SaveEpisodesForCurrentUserRequest.Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The episode IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * - * @param ids Optional. A JSON array of Spotify IDs for the episodes to be added to the user’s library. - * @return A {@link SaveEpisodesForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public SaveEpisodesForCurrentUserRequest.Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link SaveEpisodesForCurrentUserRequest}. - */ - @Override - public SaveEpisodesForCurrentUserRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/episodes"); - return new SaveEpisodesForCurrentUserRequest(this); - } - - @Override - protected SaveEpisodesForCurrentUserRequest.Builder self() { - return this; - } - } - -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequest.java deleted file mode 100644 index 795436b25..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequest.java +++ /dev/null @@ -1,105 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Save one or more shows to current Spotify user’s library. - */ -@JsonDeserialize(builder = SaveShowsForCurrentUserRequest.Builder.class) -public class SaveShowsForCurrentUserRequest extends AbstractDataRequest { - - /** - * The private {@link SaveShowsForCurrentUserRequest} constructor. - * - * @param builder A {@link SaveShowsForCurrentUserRequest.Builder}. - */ - private SaveShowsForCurrentUserRequest(final Builder builder) { - super(builder); - } - - /** - * Save one or more shows. - * - * @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 putJson(); - } - - /** - * Builder class for building a {@link SaveShowsForCurrentUserRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link SaveShowsForCurrentUserRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(String accessToken) { - super(accessToken); - } - - /** - * The show IDs setter. - * - * @param ids Optional. A comma-separated list of Spotify IDs for the shows to be added to the user’s library. - * @return A {@link SaveShowsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The show IDs setter. - *

- * Note: If the ids have already been set with {@link #ids(String)}, any ids added here will be ignored. - * @param ids Optional. A JSON array of Spotify IDs for the shows to be added to the user’s library. - * @return A {@link SaveShowsForCurrentUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link SaveShowsForCurrentUserRequest}. - */ - @Override - public SaveShowsForCurrentUserRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/shows"); - return new SaveShowsForCurrentUserRequest(this); - } - - @Override - protected SaveShowsForCurrentUserRequest.Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveToLibraryRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveToLibraryRequest.java new file mode 100644 index 000000000..fb28649c8 --- /dev/null +++ b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveToLibraryRequest.java @@ -0,0 +1,92 @@ +package se.michaelthelin.spotify.requests.data.library; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.gson.JsonArray; +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; + +/** + * Save a list of Spotify URIs to the user's library. + */ +@JsonDeserialize(builder = SaveToLibraryRequest.Builder.class) +public class SaveToLibraryRequest extends AbstractDataRequest { + + /** + * The private {@link SaveToLibraryRequest} constructor. + * + * @param builder A {@link SaveToLibraryRequest.Builder}. + */ + private SaveToLibraryRequest(final Builder builder) { + super(builder); + } + + /** + * Save items to the user's library. + * + * @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. + */ + public String execute() throws + IOException, + SpotifyWebApiException, + ParseException { + return putJson(); + } + + /** + * Builder class for building a {@link SaveToLibraryRequest}. + */ + public static final class Builder extends AbstractDataRequest.Builder { + + /** + * Create a new {@link SaveToLibraryRequest.Builder} instance. + *

+ * Modification of the current user's library requires authorization of the + * {@code user-library-modify} scope. + * + * @param accessToken Required. A valid access token from the Spotify Accounts service. + * @see Spotify: Using Scopes + */ + public Builder(final String accessToken) { + super(accessToken); + } + + /** + * The URIs setter. + * + * @param uris Required. The Spotify URIs to save. Maximum: 50 URIs. + * @return A {@link SaveToLibraryRequest.Builder}. + */ + public Builder uris(final String... uris) { + assert (uris != null); + assert (uris.length <= 50); + final JsonArray urisArray = new JsonArray(); + for (final String uri : uris) { + urisArray.add(uri); + } + return setBodyParameter("uris", urisArray); + } + + /** + * The request build method. + * + * @return A custom {@link SaveToLibraryRequest}. + */ + @Override + public SaveToLibraryRequest build() { + setContentType(ContentType.APPLICATION_JSON); + setPath("/v1/me/library"); + return new SaveToLibraryRequest(this); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequest.java deleted file mode 100644 index 5bd446162..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.gson.JsonArray; -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; - -/** - * Save one or more tracks to the current user’s "Your Music" library. - */ -@JsonDeserialize(builder = SaveTracksForUserRequest.Builder.class) -public class SaveTracksForUserRequest extends AbstractDataRequest { - - /** - * The private {@link SaveTracksForUserRequest} constructor. - * - * @param builder A {@link SaveTracksForUserRequest.Builder}. - */ - private SaveTracksForUserRequest(final Builder builder) { - super(builder); - } - - /** - * Save one or more tracks. - * - * @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. - */ - public String execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return putJson(); - } - - /** - * Builder class for building a {@link SaveTracksForUserRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link SaveTracksForUserRequest.Builder} instance. - *

- * Modification of the current user's "Your Music" collection requires authorization of the - * {@code user-library-modify} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The track IDs setter. - * - * @param ids Optional. A comma-separated list of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link SaveTracksForUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The track IDs setter. - * - * @param ids Optional. A json array consisting of the Spotify IDs. Maximum: 50 IDs. - * @return A {@link SaveTracksForUserRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final JsonArray ids) { - assert (ids != null); - assert (!ids.isJsonNull()); - assert (ids.size() <= 50); - return setBodyParameter("ids", ids); - } - - /** - * The request build method. - * - * @return A custom {@link SaveTracksForUserRequest}. - */ - @Override - public SaveTracksForUserRequest build() { - setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/me/tracks"); - return new SaveTracksForUserRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequest.java index ebc4f4170..b1351f329 100644 --- a/src/main/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequest.java +++ b/src/main/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequest.java @@ -10,7 +10,7 @@ import java.io.IOException; /** - * Create a playlist for a Spotify user. (The playlist will be empty until you add tracks + * Create a playlist for the current user. (The playlist will be empty until you add tracks * with an {@link AddItemsToPlaylistRequest}.) */ @JsonDeserialize(builder = CreatePlaylistRequest.Builder.class) @@ -57,19 +57,6 @@ public Builder(final String accessToken) { super(accessToken); } - /** - * The user ID setter. - * - * @param user_id The user's Spotify user ID. - * @return A {@link CreatePlaylistRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder user_id(final String user_id) { - assert (user_id != null); - assert (!user_id.isEmpty()); - return setPathParameter("user_id", user_id); - } - /** * The playlist name setter. * @@ -129,7 +116,7 @@ public Builder description(final String description) { @Override public CreatePlaylistRequest build() { setContentType(ContentType.APPLICATION_JSON); - setPath("/v1/users/{user_id}/playlists"); + setPath("/v1/me/playlists"); return new CreatePlaylistRequest(this); } diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequest.java deleted file mode 100644 index d06cdb92d..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequest.java +++ /dev/null @@ -1,118 +0,0 @@ -package se.michaelthelin.spotify.requests.data.playlists; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.model_objects.specification.PlaylistSimplified; -import se.michaelthelin.spotify.requests.data.AbstractDataPagingRequest; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get a list of the playlists owned or followed by a Spotify user. - */ -@JsonDeserialize(builder = GetListOfUsersPlaylistsRequest.Builder.class) -public class GetListOfUsersPlaylistsRequest extends AbstractDataRequest> { - - /** - * The private {@link GetListOfUsersPlaylistsRequest} constructor. - * - * @param builder A {@link GetListOfUsersPlaylistsRequest.Builder}. - */ - private GetListOfUsersPlaylistsRequest(final Builder builder) { - super(builder); - } - - /** - * Get an user's playlists. - * - * @return A {@link PlaylistSimplified} paging. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Paging execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new PlaylistSimplified.JsonUtil().createModelObjectPaging(getJson()); - } - - /** - * Builder class for building a {@link GetListOfUsersPlaylistsRequest}. - */ - public static final class Builder extends AbstractDataPagingRequest.Builder { - - /** - * Create a new {@link GetListOfUsersPlaylistsRequest.Builder}. - *

- * Private playlists are only retrievable for the current user and requires the {@code playlist-read-private} - * scope to have been authorized by the user. Note: This scope alone will not return collaborative playlists, - * even though they are always private. - *

- * Collaborative playlists are only retrievable for the current user and requires the - * {@code playlist-read-collaborative} scope to have been authorized by the user. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - * @see Spotify: Using Scopes - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The user ID setter. - * - * @param user_id The user's Spotify user ID. - * @return A {@link GetListOfUsersPlaylistsRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder user_id(final String user_id) { - assert (user_id != null); - assert (!user_id.isEmpty()); - return setPathParameter("user_id", user_id); - } - - /** - * The limit setter. - * - * @param limit Optional. The maximum number of playlists to return. Default: 20. Minimum: 1. Maximum: 50. - * @return A {@link GetListOfUsersPlaylistsRequest.Builder}. - */ - @Override - public Builder limit(final Integer limit) { - assert (1 <= limit && limit <= 50); - return setQueryParameter("limit", limit); - } - - /** - * The offset setter. - * - * @param offset Optional. The index of the first playlist to return. Default: 0 (the first object). Maximum offset: - * 100.000. Use with {@link #limit(Integer)} to get the next set of playlists. - * @return A {@link GetListOfUsersPlaylistsRequest.Builder}. - */ - @Override - public Builder offset(final Integer offset) { - assert (0 <= offset && offset <= 100000); - return setQueryParameter("offset", offset); - } - - /** - * The request build method. - * - * @return A custom {@link GetListOfUsersPlaylistsRequest}. - */ - @Override - public GetListOfUsersPlaylistsRequest build() { - setPath("/v1/users/{user_id}/playlists"); - return new GetListOfUsersPlaylistsRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequest.java deleted file mode 100644 index d2355125c..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.michaelthelin.spotify.requests.data.shows; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.ShowSimplified; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information for multiple shows based on their Spotify IDs. - */ -@JsonDeserialize(builder = GetSeveralShowsRequest.Builder.class) -public class GetSeveralShowsRequest extends AbstractDataRequest { - - /** - * The private {@link GetSeveralShowsRequest} constructor. - * - * @param builder A {@link GetSeveralShowsRequest.Builder}. - */ - private GetSeveralShowsRequest(final Builder builder) { - super(builder); - } - - /** - * Get several shows. - * - * @return Multiple {@link ShowSimplified} objects. - * @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 ShowSimplified[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new ShowSimplified.JsonUtil().createModelObjectArray(getJson(), "shows"); - } - - /** - * Builder class for building a {@link GetSeveralShowsRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetSeveralShowsRequest.Builder}. - *

- * Reading the user’s resume points on episode objects requires the {@code user-read-playback-position} scope. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The show IDs setter. - * - * @param ids Required. A comma-separated list of the Spotify IDs for the shows. Maximum: 50 IDs. - * @return A {@link GetSeveralShowsRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public GetSeveralShowsRequest.Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The market country code setter.

- * If a country code is specified, only shows and episodes that are available in that market will be returned. - * If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter. - * Note: If neither market or user country are provided, the content is considered unavailable for the client.

- * Users can view the country that is associated with their account in the account settings. - * - * @param market Optional. An ISO 3166-1 alpha-2 country code. - * @return A {@link GetSeveralShowsRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - */ - public GetSeveralShowsRequest.Builder market(final CountryCode market) { - assert (market != null); - return setQueryParameter("market", market); - } - - /** - * The request build method. - * - * @return A custom {@link GetSeveralShowsRequest}. - */ - @Override - public GetSeveralShowsRequest build() { - setPath("/v1/shows"); - return new GetSeveralShowsRequest(this); - } - - @Override - protected GetSeveralShowsRequest.Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequest.java deleted file mode 100644 index e0027ebb0..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -package se.michaelthelin.spotify.requests.data.tracks; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.neovisionaries.i18n.CountryCode; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Track; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get Spotify catalog information for multiple tracks based on their Spotify IDs. - */ -@JsonDeserialize(builder = GetSeveralTracksRequest.Builder.class) -public class GetSeveralTracksRequest extends AbstractDataRequest { - - /** - * The private {@link GetSeveralTracksRequest} constructor. - * - * @param builder A {@link GetSeveralTracksRequest.Builder}. - */ - private GetSeveralTracksRequest(final Builder builder) { - super(builder); - } - - /** - * Get several tracks. - * - * @return Multiple {@link Track} objects. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public Track[] execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new Track.JsonUtil().createModelObjectArray(getJson(), "tracks"); - } - - /** - * Builder class for building a {@link GetSeveralTracksRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetSeveralTracksRequest.Builder}. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The track IDs setter. - * - * @param ids Required. A comma-separated list of the Spotify IDs for the tracks. Maximum: 50 IDs. - * @return A {@link GetSeveralTracksRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder ids(final String ids) { - assert (ids != null); - assert (ids.split(",").length <= 50); - return setQueryParameter("ids", ids); - } - - /** - * The market country code setter. - * - * @param market Optional. An ISO 3166-1 alpha-2 country code. Provide this - * parameter if you want to apply Track Relinking. - * @return A {@link GetSeveralTracksRequest.Builder}. - * @see Wikipedia: ISO 3166-1 alpha-2 country codes - * @see Spotify: Track Relinking Guide - */ - public Builder market(final CountryCode market) { - assert (market != null); - return setQueryParameter("market", market); - } - - /** - * The request build method. - * - * @return A custom {@link GetSeveralTracksRequest}. - */ - @Override - public GetSeveralTracksRequest build() { - setPath("/v1/tracks"); - return new GetSeveralTracksRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/main/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequest.java b/src/main/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequest.java deleted file mode 100644 index ac4581bbf..000000000 --- a/src/main/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -package se.michaelthelin.spotify.requests.data.users_profile; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.hc.core5.http.ParseException; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.User; -import se.michaelthelin.spotify.requests.data.AbstractDataRequest; - -import java.io.IOException; - -/** - * Get public profile information about a Spotify user. - */ -@JsonDeserialize(builder = GetUsersProfileRequest.Builder.class) -public class GetUsersProfileRequest extends AbstractDataRequest { - - /** - * The private {@link GetUsersProfileRequest} constructor. - * - * @param builder A {@link GetUsersProfileRequest.Builder}. - */ - private GetUsersProfileRequest(final Builder builder) { - super(builder); - } - - /** - * Get the profile of a current user. - * - * @return A {@link User}. - * @throws IOException In case of networking issues. - * @throws SpotifyWebApiException The Web API returned an error further specified in this exception's root cause. - */ - public User execute() throws - IOException, - SpotifyWebApiException, - ParseException { - return new User.JsonUtil().createModelObject(getJson()); - } - - /** - * Builder class for building a {@link GetUsersProfileRequest}. - */ - public static final class Builder extends AbstractDataRequest.Builder { - - /** - * Create a new {@link GetUsersProfileRequest.Builder}. - * - * @param accessToken Required. A valid access token from the Spotify Accounts service. - */ - public Builder(final String accessToken) { - super(accessToken); - } - - /** - * The user ID setter. - * - * @param user_id The user's Spotify user ID. - * @return A {@link GetUsersProfileRequest.Builder}. - * @see Spotify: URIs & IDs - */ - public Builder user_id(final String user_id) { - assert (user_id != null); - assert (!user_id.isEmpty()); - return setPathParameter("user_id", user_id); - } - - /** - * The request build method. - * - * @return A custom {@link GetUsersProfileRequest}. - */ - @Override - public GetUsersProfileRequest build() { - setPath("/v1/users/{user_id}"); - return new GetUsersProfileRequest(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/src/test/fixtures/requests/data/albums/GetSeveralAlbumsRequest.json b/src/test/fixtures/requests/data/albums/GetSeveralAlbumsRequest.json deleted file mode 100644 index 931d6b33d..000000000 --- a/src/test/fixtures/requests/data/albums/GetSeveralAlbumsRequest.json +++ /dev/null @@ -1,302 +0,0 @@ -{ - "albums": [ - { - "album_type": "album", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/53A0W3U0s8diEn9RhXQhVz" - }, - "href": "https://api.spotify.com/v1/artists/53A0W3U0s8diEn9RhXQhVz", - "id": "53A0W3U0s8diEn9RhXQhVz", - "name": "Keane", - "type": "artist", - "uri": "spotify:artist:53A0W3U0s8diEn9RhXQhVz" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "IE", - "IS", - "IT", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "RO", - "SE", - "SG", - "SI", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "copyrights": [ - { - "text": "(C) 2013 Universal Island Records, a division of Universal Music Operations Limited", - "type": "C" - }, - { - "text": "(P) 2013 Universal Island Records, a division of Universal Music Operations Limited", - "type": "P" - } - ], - "external_ids": { - "upc": "00602537518357" - }, - "external_urls": { - "spotify": "https://open.spotify.com/album/41MnTivkwTO3UUJ8DrqEJJ" - }, - "genres": [], - "href": "https://api.spotify.com/v1/albums/41MnTivkwTO3UUJ8DrqEJJ", - "id": "41MnTivkwTO3UUJ8DrqEJJ", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/89b92c6b59131776c0cd8e5df46301ffcf36ed69", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/eb6f0b2594d81f8d9dced193f3e9a3bc4318aedc", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/21e1ebcd7ebd3b679d9d5084bba1e163638b103a", - "width": 64 - } - ], - "name": "The Best Of Keane (Deluxe Edition)", - "popularity": 65, - "release_date": "2013-11-08", - "release_date_precision": "day", - "tracks": { - "href": "https://api.spotify.com/v1/albums/41MnTivkwTO3UUJ8DrqEJJ/tracks?offset=0&limit=50", - "items": [ - { - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/53A0W3U0s8diEn9RhXQhVz" - }, - "href": "https://api.spotify.com/v1/artists/53A0W3U0s8diEn9RhXQhVz", - "id": "53A0W3U0s8diEn9RhXQhVz", - "name": "Keane", - "type": "artist", - "uri": "spotify:artist:53A0W3U0s8diEn9RhXQhVz" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "IE", - "IS", - "IT", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "RO", - "SE", - "SG", - "SI", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "disc_number": 1, - "duration_ms": 215986, - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/track/4r9PmSmbAOOWqaGWLf6M9Q" - }, - "href": "https://api.spotify.com/v1/tracks/4r9PmSmbAOOWqaGWLf6M9Q", - "id": "4r9PmSmbAOOWqaGWLf6M9Q", - "name": "Everybody's Changing", - "preview_url": "https://p.scdn.co/mp3-preview/641fd877ee0f42f3713d1649e20a9734cc64b8f9", - "track_number": 1, - "type": "track", - "uri": "spotify:track:4r9PmSmbAOOWqaGWLf6M9Q" - }, - { - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/53A0W3U0s8diEn9RhXQhVz" - }, - "href": "https://api.spotify.com/v1/artists/53A0W3U0s8diEn9RhXQhVz", - "id": "53A0W3U0s8diEn9RhXQhVz", - "name": "Keane", - "type": "artist", - "uri": "spotify:artist:53A0W3U0s8diEn9RhXQhVz" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "IE", - "IS", - "IT", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "RO", - "SE", - "SG", - "SI", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "disc_number": 1, - "duration_ms": 235880, - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/track/0HJQD8uqX2Bq5HVdLnd3ep" - }, - "href": "https://api.spotify.com/v1/tracks/0HJQD8uqX2Bq5HVdLnd3ep", - "id": "0HJQD8uqX2Bq5HVdLnd3ep", - "name": "Somewhere Only We Know", - "preview_url": "https://p.scdn.co/mp3-preview/e001676375ea2b4807cee2f98b51f2f3fe0d109b", - "track_number": 2, - "type": "track", - "uri": "spotify:track:0HJQD8uqX2Bq5HVdLnd3ep" - } - ], - "limit": 50, - "next": null, - "offset": 0, - "previous": null, - "total": 9 - }, - "type": "album", - "uri": "spotify:album:6UXCm6bOO4gFlDQZV5yL37" - } - ] -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/artists/GetArtistsTopTracksRequest.json b/src/test/fixtures/requests/data/artists/GetArtistsTopTracksRequest.json deleted file mode 100644 index dca621cd3..000000000 --- a/src/test/fixtures/requests/data/artists/GetArtistsTopTracksRequest.json +++ /dev/null @@ -1,199 +0,0 @@ -{ - "tracks": [ - { - "album": { - "album_type": "album", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/43ZHCT0cAZBISjO8DG9PnE" - }, - "href": "https://api.spotify.com/v1/artists/43ZHCT0cAZBISjO8DG9PnE", - "id": "43ZHCT0cAZBISjO8DG9PnE", - "name": "Elvis Presley", - "type": "artist", - "uri": "spotify:artist:43ZHCT0cAZBISjO8DG9PnE" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "US", - "UY" - ], - "external_urls": { - "spotify": "https://open.spotify.com/album/7xe8VI48TxUpU1IIo0RfGi" - }, - "href": "https://api.spotify.com/v1/albums/7xe8VI48TxUpU1IIo0RfGi", - "id": "7xe8VI48TxUpU1IIo0RfGi", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/4295b5ff74d4f944367144acbe616b6f62d20b17", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/203104e5843248c700b078f391d4bc759c5d7f47", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/0c0a172373b0211c590b241270d05b70889075a1", - "width": 64 - } - ], - "name": "Blue Hawaii", - "type": "album", - "uri": "spotify:album:7xe8VI48TxUpU1IIo0RfGi" - }, - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/43ZHCT0cAZBISjO8DG9PnE" - }, - "href": "https://api.spotify.com/v1/artists/43ZHCT0cAZBISjO8DG9PnE", - "id": "43ZHCT0cAZBISjO8DG9PnE", - "name": "Elvis Presley", - "type": "artist", - "uri": "spotify:artist:43ZHCT0cAZBISjO8DG9PnE" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "US", - "UY" - ], - "disc_number": 1, - "duration_ms": 179773, - "explicit": false, - "external_ids": { - "isrc": "USRC16101350" - }, - "external_urls": { - "spotify": "https://open.spotify.com/track/44AyOl4qVkzS48vBsbNXaC" - }, - "href": "https://api.spotify.com/v1/tracks/44AyOl4qVkzS48vBsbNXaC", - "id": "44AyOl4qVkzS48vBsbNXaC", - "name": "Can't Help Falling in Love", - "popularity": 70, - "preview_url": "https://p.scdn.co/mp3-preview/26e409b39a2da6dc18fab61020c90be2938dc0e9", - "track_number": 5, - "type": "track", - "uri": "spotify:track:44AyOl4qVkzS48vBsbNXaC" - } - ] -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/artists/GetSeveralArtistsRequest.json b/src/test/fixtures/requests/data/artists/GetSeveralArtistsRequest.json deleted file mode 100644 index efffd7ffb..000000000 --- a/src/test/fixtures/requests/data/artists/GetSeveralArtistsRequest.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/0oSGxfWSnnOXhD2fKuz2Gy" - }, - "followers": { - "href": null, - "total": 633494 - }, - "genres": [ - "art rock", - "glam rock", - "permanent wave" - ], - "href": "https://api.spotify.com/v1/artists/0oSGxfWSnnOXhD2fKuz2Gy", - "id": "0oSGxfWSnnOXhD2fKuz2Gy", - "images": [ - { - "height": 1000, - "url": "https://i.scdn.co/image/32bd9707b42a2c081482ec9cd3ffa8879f659f95", - "width": 1000 - }, - { - "height": 640, - "url": "https://i.scdn.co/image/865f24753e5e4f40a383bf24a9cdda598a4559a8", - "width": 640 - }, - { - "height": 200, - "url": "https://i.scdn.co/image/7ddd6fa5cf78aee2f2e8b347616151393022b7d9", - "width": 200 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/c8dc28c191432862afce298216458a6f00bbfbd8", - "width": 64 - } - ], - "name": "David Bowie", - "popularity": 77, - "type": "artist", - "uri": "spotify:artist:0oSGxfWSnnOXhD2fKuz2Gy" - }, - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/3dBVyJ7JuOMt4GE9607Qin" - }, - "followers": { - "href": null, - "total": 52338 - }, - "genres": [ - "glam rock", - "protopunk" - ], - "href": "https://api.spotify.com/v1/artists/3dBVyJ7JuOMt4GE9607Qin", - "id": "3dBVyJ7JuOMt4GE9607Qin", - "images": [ - { - "height": 1300, - "url": "https://i.scdn.co/image/5515a710c94ccd4edd8b9a0587778ed5e3f997da", - "width": 1000 - }, - { - "height": 832, - "url": "https://i.scdn.co/image/c990e667b4ca8240c73b0db06e6d76a3b27ce929", - "width": 640 - }, - { - "height": 260, - "url": "https://i.scdn.co/image/de2fa1d11c59e63143117d44ec9990b9e40451a2", - "width": 200 - }, - { - "height": 83, - "url": "https://i.scdn.co/image/b39638735adb4a4a54621293b99ab65c546f605e", - "width": 64 - } - ], - "name": "T. Rex", - "popularity": 58, - "type": "artist", - "uri": "spotify:artist:3dBVyJ7JuOMt4GE9607Qin" - } - ] -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/browse/GetCategoryRequest.json b/src/test/fixtures/requests/data/browse/GetCategoryRequest.json deleted file mode 100644 index 1f85a526d..000000000 --- a/src/test/fixtures/requests/data/browse/GetCategoryRequest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "href": "https://api.spotify.com/v1/browse/categories/party", - "icons": [ - { - "height": 274, - "url": "https://datsnxq1rwndn.cloudfront.net/media/derived/party-274x274_73d1907a7371c3bb96a288390a96ee27_0_0_274_274.jpg", - "width": 274 - } - ], - "id": "party", - "name": "Party" -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/browse/GetListOfCategoriesRequest.json b/src/test/fixtures/requests/data/browse/GetListOfCategoriesRequest.json deleted file mode 100644 index 2f6f91e6d..000000000 --- a/src/test/fixtures/requests/data/browse/GetListOfCategoriesRequest.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "categories": { - "href": "https://api.spotify.com/v1/browse/categories?offset=0&limit=20", - "items": [ - { - "href": "https://api.spotify.com/v1/browse/categories/toplists", - "icons": [ - { - "height": 275, - "url": "https://datsnxq1rwndn.cloudfront.net/media/derived/toplists_11160599e6a04ac5d6f2757f5511778f_0_0_275_275.jpg", - "width": 275 - } - ], - "id": "toplists", - "name": "Top Lists" - }, - { - "href": "https://api.spotify.com/v1/browse/categories/mood", - "icons": [ - { - "height": 274, - "url": "https://datsnxq1rwndn.cloudfront.net/media/original/mood-274x274_976986a31ac8c49794cbdc7246fd5ad7_274x274.jpg", - "width": 274 - } - ], - "id": "mood", - "name": "Mood" - }, - { - "href": "https://api.spotify.com/v1/browse/categories/party", - "icons": [ - { - "height": 274, - "url": "https://datsnxq1rwndn.cloudfront.net/media/derived/party-274x274_73d1907a7371c3bb96a288390a96ee27_0_0_274_274.jpg", - "width": 274 - } - ], - "id": "party", - "name": "Party" - }, - { - "href": "https://api.spotify.com/v1/browse/categories/pop", - "icons": [ - { - "height": 274, - "url": "https://datsnxq1rwndn.cloudfront.net/media/derived/pop-274x274_447148649685019f5e2a03a39e78ba52_0_0_274_274.jpg", - "width": 274 - } - ], - "id": "pop", - "name": "Pop" - }, - { - "href": "https://api.spotify.com/v1/browse/categories/workout", - "icons": [ - { - "height": 275, - "url": "https://datsnxq1rwndn.cloudfront.net/media/derived/workout_856581c1c545a5305e49a3cd8be804a0_0_0_275_275.jpg", - "width": 275 - } - ], - "id": "workout", - "name": "Workout" - } - ], - "limit": 20, - "next": "https://api.spotify.com/v1/browse/categories?offset=20&limit=20", - "offset": 0, - "previous": null, - "total": 31 - } -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/browse/GetListOfNewReleasesRequest.json b/src/test/fixtures/requests/data/browse/GetListOfNewReleasesRequest.json deleted file mode 100644 index 86817ef3c..000000000 --- a/src/test/fixtures/requests/data/browse/GetListOfNewReleasesRequest.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "albums": { - "href": "https://api.spotify.com/v1/browse/new-releases?country=SE&offset=0&limit=20", - "items": [ - { - "album_type": "single", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/2RdwBSPQiwcmiDo9kixcl8" - }, - "href": "https://api.spotify.com/v1/artists/2RdwBSPQiwcmiDo9kixcl8", - "id": "2RdwBSPQiwcmiDo9kixcl8", - "name": "Pharrell Williams", - "type": "artist", - "uri": "spotify:artist:2RdwBSPQiwcmiDo9kixcl8" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "US", - "UY" - ], - "external_urls": { - "spotify": "https://open.spotify.com/album/5ZX4m5aVSmWQ5iHAPQpT71" - }, - "href": "https://api.spotify.com/v1/albums/5ZX4m5aVSmWQ5iHAPQpT71", - "id": "5ZX4m5aVSmWQ5iHAPQpT71", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/e6b635ebe3ef4ba22492f5698a7b5d417f78b88a", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/92ae5b0fe64870c09004dd2e745a4fb1bf7de39d", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/8a7ab6fc2c9f678308ba0f694ecd5718dc6bc930", - "width": 64 - } - ], - "name": "Runnin'", - "type": "album", - "uri": "spotify:album:5ZX4m5aVSmWQ5iHAPQpT71" - }, - { - "album_type": "single", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/3TVXtAsR1Inumwj472S9r4" - }, - "href": "https://api.spotify.com/v1/artists/3TVXtAsR1Inumwj472S9r4", - "id": "3TVXtAsR1Inumwj472S9r4", - "name": "Drake", - "type": "artist", - "uri": "spotify:artist:3TVXtAsR1Inumwj472S9r4" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "external_urls": { - "spotify": "https://open.spotify.com/album/0geTzdk2InlqIoB16fW9Nd" - }, - "href": "https://api.spotify.com/v1/albums/0geTzdk2InlqIoB16fW9Nd", - "id": "0geTzdk2InlqIoB16fW9Nd", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/d40e9c3d22bde2fbdb2ecc03cccd7a0e77f42e4c", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/dff06a3375f6d9b32ecb081eb9a60bbafecb5731", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/808a02bd7fc59b0652c9df9f68675edbffe07a79", - "width": 64 - } - ], - "name": "Sneakin’", - "type": "album", - "uri": "spotify:album:0geTzdk2InlqIoB16fW9Nd" - } - ], - "limit": 20, - "next": "https://api.spotify.com/v1/browse/new-releases?country=SE&offset=20&limit=20", - "offset": 0, - "previous": null, - "total": 500 - } -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/episodes/GetSeveralEpisodesRequest.json b/src/test/fixtures/requests/data/episodes/GetSeveralEpisodesRequest.json deleted file mode 100644 index 94eafe406..000000000 --- a/src/test/fixtures/requests/data/episodes/GetSeveralEpisodesRequest.json +++ /dev/null @@ -1,320 +0,0 @@ -{ - "episodes": [ - { - "audio_preview_url": "https://p.scdn.co/mp3-preview/9b0ebffde166917f35f9eab25af874e765261776", - "description": "We try to convince CNET's Jeff Bakalar that the Witcher's extended universe is amazing while he clues us in on where the real money is made. We've also got updates on the Grand Theft Auto movie, Splatoon, Alex's Mad Max impressions, and hot New York real ", - "duration_ms": 8052140, - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/episode/4GI3dxEafwap1sFiTGPKd1" - }, - "href": "https://api.spotify.com/v1/episodes/4GI3dxEafwap1sFiTGPKd1", - "id": "4GI3dxEafwap1sFiTGPKd1", - "images": [ - { - "height": 327, - "url": "https://i.scdn.co/image/207663099fe4dab2eafbc2b52813d283e80be07a", - "width": 580 - }, - { - "height": 169, - "url": "https://i.scdn.co/image/156b88e30fbeb1864e75401b619e53238e252dd5", - "width": 300 - }, - { - "height": 36, - "url": "https://i.scdn.co/image/e96c7aa1c2415e29a68d93f4089c8add48b29984", - "width": 64 - } - ], - "is_externally_hosted": false, - "is_playable": true, - "language": "en-US", - "languages": [ - "en-US" - ], - "name": "The Giant Beastcast: Episode 0", - "release_date": "2015-05-22", - "release_date_precision": "day", - "resume_point": { - "fully_played": false, - "resume_position_ms": 3579000 - }, - "show": { - "available_markets": [ - "AD", - "AE", - "AR", - "AT", - "AU", - "BE", - "BG", - "BH", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "DZ", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IL", - "IN", - "IS", - "IT", - "JO", - "JP", - "KW", - "LB", - "LI", - "LT", - "LU", - "LV", - "MA", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "OM", - "PA", - "PE", - "PH", - "PL", - "PS", - "PT", - "PY", - "QA", - "RO", - "SE", - "SG", - "SK", - "SV", - "TH", - "TN", - "TR", - "TW", - "US", - "UY", - "VN", - "ZA" - ], - "copyrights": [], - "description": "The Giant Bomb East team gathers to talk about the week in video games, their lives, and basically anything that interests them. All from New York City!", - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/show/5AvwZVawapvyhJUIx71pdJ" - }, - "href": "https://api.spotify.com/v1/shows/5AvwZVawapvyhJUIx71pdJ", - "id": "5AvwZVawapvyhJUIx71pdJ", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/1ddf77cc09b21b34b9536f76794b43bac7240688", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/b96bc3c4b41162cf3dbec9f66cd0ba63fde47849", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/e699a95e7494c7c898a85f3676572b71faecf032", - "width": 64 - } - ], - "is_externally_hosted": false, - "languages": [ - "en-US" - ], - "media_type": "audio", - "name": "The Giant Beastcast", - "publisher": "Giant Bomb", - "type": "show", - "uri": "spotify:show:5AvwZVawapvyhJUIx71pdJ" - }, - "type": "episode", - "uri": "spotify:episode:4GI3dxEafwap1sFiTGPKd1" - }, - { - "audio_preview_url": "https://p.scdn.co/mp3-preview/09cec54c8e55316a020ca988888ff95a59fdd664", - "description": "Austin Walker joins us as we deliver updates on Splatoon, Danny Trejo, and Jeff's Australian accent. We also dig into topics ranging from streaming Adult Only games to the current online gaming environment.", - "duration_ms": 6817880, - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/episode/1rcYQNrhIqpG3eJyRlRuKJ" - }, - "href": "https://api.spotify.com/v1/episodes/1rcYQNrhIqpG3eJyRlRuKJ", - "id": "1rcYQNrhIqpG3eJyRlRuKJ", - "images": [ - { - "height": 237, - "url": "https://i.scdn.co/image/9f158e066a07176a943278775ecd0da7136dfbd8", - "width": 640 - }, - { - "height": 111, - "url": "https://i.scdn.co/image/ca24d4363195b14aa0b1e1d370643f1d3d76243d", - "width": 300 - }, - { - "height": 24, - "url": "https://i.scdn.co/image/59bc0c009b3fe8903aac2a9113307bd66208faf4", - "width": 64 - } - ], - "is_externally_hosted": false, - "is_playable": true, - "language": "en-US", - "languages": [ - "en-US" - ], - "name": "The Giant Beastcast: Episode 01", - "release_date": "2015-05-29", - "release_date_precision": "day", - "resume_point": { - "fully_played": false, - "resume_position_ms": 0 - }, - "show": { - "available_markets": [ - "AD", - "AE", - "AR", - "AT", - "AU", - "BE", - "BG", - "BH", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "DZ", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IL", - "IN", - "IS", - "IT", - "JO", - "JP", - "KW", - "LB", - "LI", - "LT", - "LU", - "LV", - "MA", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "OM", - "PA", - "PE", - "PH", - "PL", - "PS", - "PT", - "PY", - "QA", - "RO", - "SE", - "SG", - "SK", - "SV", - "TH", - "TN", - "TR", - "TW", - "US", - "UY", - "VN", - "ZA" - ], - "copyrights": [], - "description": "The Giant Bomb East team gathers to talk about the week in video games, their lives, and basically anything that interests them. All from New York City!", - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/show/5AvwZVawapvyhJUIx71pdJ" - }, - "href": "https://api.spotify.com/v1/shows/5AvwZVawapvyhJUIx71pdJ", - "id": "5AvwZVawapvyhJUIx71pdJ", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/1ddf77cc09b21b34b9536f76794b43bac7240688", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/b96bc3c4b41162cf3dbec9f66cd0ba63fde47849", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/e699a95e7494c7c898a85f3676572b71faecf032", - "width": 64 - } - ], - "is_externally_hosted": false, - "languages": [ - "en-US" - ], - "media_type": "audio", - "name": "The Giant Beastcast", - "publisher": "Giant Bomb", - "type": "show", - "uri": "spotify:show:5AvwZVawapvyhJUIx71pdJ" - }, - "type": "episode", - "uri": "spotify:episode:1rcYQNrhIqpG3eJyRlRuKJ" - } - ] -} diff --git a/src/test/fixtures/requests/data/playlists/CreatePlaylistRequest.json b/src/test/fixtures/requests/data/playlists/CreatePlaylistRequest.json index ddeb6e010..25a8947c7 100644 --- a/src/test/fixtures/requests/data/playlists/CreatePlaylistRequest.json +++ b/src/test/fixtures/requests/data/playlists/CreatePlaylistRequest.json @@ -23,7 +23,7 @@ }, "public": false, "snapshot_id": "s0o3TSuYnRLl2jch+oA4OEbKwq/fNxhGBkSPnvhZdmWjNV0q3uCAWuGIhEx8SHIx", - "tracks": { + "items": { "href": "https://api.spotify.com/v1/users/thelinmichael/playlists/7d2D2S200NyUE5KYs80PwO/tracks", "items": [], "limit": 100, diff --git a/src/test/fixtures/requests/data/playlists/GetListOfUsersPlaylistsRequest.json b/src/test/fixtures/requests/data/playlists/GetListOfUsersPlaylistsRequest.json deleted file mode 100644 index a49622131..000000000 --- a/src/test/fixtures/requests/data/playlists/GetListOfUsersPlaylistsRequest.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "href": "https://api.spotify.com/v1/users/wizzler/playlists", - "items": [ - { - "collaborative": false, - "external_urls": { - "spotify": "https://open.spotify.com/user/wizzler/playlists/53Y8wT46QIMz5H4WQ8O22c" - }, - "href": "https://api.spotify.com/v1/users/wizzler/playlists/53Y8wT46QIMz5H4WQ8O22c", - "id": "53Y8wT46QIMz5H4WQ8O22c", - "images": [], - "name": "Wizzlers Big Playlist", - "owner": { - "external_urls": { - "spotify": "https://open.spotify.com/user/wizzler" - }, - "href": "https://api.spotify.com/v1/users/wizzler", - "id": "wizzler", - "type": "user", - "uri": "spotify:user:wizzler" - }, - "public": true, - "snapshot_id": "bNLWdmhh+HDsbHzhckXeDC0uyKyg4FjPI/KEsKjAE526usnz2LxwgyBoMShVL+z+", - "tracks": { - "href": "https://api.spotify.com/v1/users/wizzler/playlists/53Y8wT46QIMz5H4WQ8O22c/tracks", - "total": 30 - }, - "type": "playlist", - "uri": "spotify:user:wizzler:playlist:53Y8wT46QIMz5H4WQ8O22c" - }, - { - "collaborative": false, - "external_urls": { - "spotify": "https://open.spotify.com/user/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju" - }, - "href": "https://api.spotify.com/v1/users/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju", - "id": "1AVZz0mBuGbCEoNRQdYQju", - "images": [], - "name": "Another Playlist", - "owner": { - "external_urls": { - "spotify": "https://open.spotify.com/user/wizzlersmate" - }, - "href": "https://api.spotify.com/v1/users/wizzlersmate", - "id": "wizzlersmate", - "type": "user", - "uri": "spotify:user:wizzlersmate" - }, - "public": true, - "snapshot_id": "Y0qg/IT5T02DKpw4uQKc/9RUrqQJ07hbTKyEeDRPOo9LU0g0icBrIXwVkHfQZ/aD", - "tracks": { - "href": "https://api.spotify.com/v1/users/wizzlersmate/playlists/1AVZz0mBuGbCEoNRQdYQju/tracks", - "total": 58 - }, - "type": "playlist", - "uri": "spotify:user:wizzlersmate:playlist:1AVZz0mBuGbCEoNRQdYQju" - } - ], - "limit": 9, - "next": null, - "offset": 0, - "previous": null, - "total": 9 -} diff --git a/src/test/fixtures/requests/data/playlists/GetPlaylistRequest.json b/src/test/fixtures/requests/data/playlists/GetPlaylistRequest.json index 7ea8c4c1f..3cd58ef4e 100644 --- a/src/test/fixtures/requests/data/playlists/GetPlaylistRequest.json +++ b/src/test/fixtures/requests/data/playlists/GetPlaylistRequest.json @@ -27,7 +27,7 @@ }, "public": null, "snapshot_id": "bNLWdmhh+HDsbHzhckXeDC0uyKyg4FjPI/KEsKjAE526usnz2LxwgyBoMShVL+z+", - "tracks": { + "items": { "href": "https://api.spotify.com/v1/users/spotify/playlists/59ZbFPES4DQwEjBpWHzrtC/tracks", "items": [ { @@ -42,7 +42,7 @@ "uri": "spotify:user:spotify" }, "is_local": false, - "track": { + "item": { "album": { "album_type": "single", "available_markets": [ diff --git a/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest.json b/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest.json index f29f6207b..6de02153c 100644 --- a/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest.json +++ b/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest.json @@ -13,7 +13,7 @@ "uri": "spotify:user:spotify_espa%C3%B1a" }, "is_local": false, - "track": { + "item": { "album": { "album_type": "single", "artists": [ diff --git a/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest_Episode.json b/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest_Episode.json index e68d03b89..77afccf23 100644 --- a/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest_Episode.json +++ b/src/test/fixtures/requests/data/playlists/GetPlaylistsItemsRequest_Episode.json @@ -14,7 +14,7 @@ }, "is_local": false, "primary_color": null, - "track": { + "item": { "audio_preview_url": "https://p.scdn.co/mp3-preview/9b0ebffde166917f35f9eab25af874e765261776", "description": "We try to convince CNET's Jeff Bakalar that the Witcher's extended universe is amazing while he clues us in on where the real money is made. We've also got updates on the Grand Theft Auto movie, Splatoon, Alex's Mad Max impressions, and hot New York real ", "duration_ms": 8052140, diff --git a/src/test/fixtures/requests/data/shows/GetSeveralShowsRequest.json b/src/test/fixtures/requests/data/shows/GetSeveralShowsRequest.json deleted file mode 100644 index 2429dc38c..000000000 --- a/src/test/fixtures/requests/data/shows/GetSeveralShowsRequest.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "shows": [ - { - "available_markets": [ - "AD", - "AE", - "AR", - "AT", - "AU", - "BE", - "BG", - "BH", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "DZ", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IL", - "IN", - "IS", - "IT", - "JO", - "JP", - "KW", - "LB", - "LI", - "LT", - "LU", - "LV", - "MA", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "OM", - "PA", - "PE", - "PH", - "PL", - "PS", - "PT", - "PY", - "QA", - "RO", - "SE", - "SG", - "SK", - "SV", - "TH", - "TN", - "TR", - "TW", - "US", - "UY", - "VN", - "ZA" - ], - "copyrights": [], - "description": "Candid conversations with entrepreneurs, artists, athletes, visionaries of all kinds—about their successes, and their failures, and what they learned from both. Hosted by Alex Blumberg, from Gimlet Media.", - "explicit": true, - "external_urls": { - "spotify": "https://open.spotify.com/show/5CfCWKI5pZ28U0uOzXkDHe" - }, - "href": "https://api.spotify.com/v1/shows/5CfCWKI5pZ28U0uOzXkDHe", - "id": "5CfCWKI5pZ28U0uOzXkDHe", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/12903409b9e5dd26f2a41e401cd7fcabd5164ed4", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/4f19eb7986a7c2246d713dcc46684e2187ccea4f", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/c0b072976a28792a4b451dfc7011a2176ec8cd34", - "width": 64 - } - ], - "is_externally_hosted": false, - "languages": [ - "en" - ], - "media_type": "audio", - "name": "Without Fail", - "publisher": "Gimlet", - "type": "show", - "uri": "spotify:show:5CfCWKI5pZ28U0uOzXkDHe" - }, - { - "available_markets": [ - "AD", - "AE", - "AR", - "AT", - "AU", - "BE", - "BG", - "BH", - "BO", - "BR", - "CA", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "DZ", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IL", - "IN", - "IS", - "IT", - "JO", - "JP", - "KW", - "LB", - "LI", - "LT", - "LU", - "LV", - "MA", - "MC", - "MT", - "MX", - "MY", - "NI", - "NL", - "NO", - "NZ", - "OM", - "PA", - "PE", - "PH", - "PL", - "PS", - "PT", - "PY", - "QA", - "RO", - "SE", - "SG", - "SK", - "SV", - "TH", - "TN", - "TR", - "TW", - "US", - "UY", - "VN", - "ZA" - ], - "copyrights": [], - "description": "Giant Bomb discusses the latest video game news and new releases, taste-test questionable beverages, and get wildly off-topic in this weekly podcast.", - "explicit": false, - "external_urls": { - "spotify": "https://open.spotify.com/show/5as3aKmN2k11yfDDDSrvaZ" - }, - "href": "https://api.spotify.com/v1/shows/5as3aKmN2k11yfDDDSrvaZ", - "id": "5as3aKmN2k11yfDDDSrvaZ", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/9bd9b3be1111810a91cd768115a57ee5a08c7145", - "width": 640 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/1f5c122086aa4602742ba2301302f2f9bc1f0345", - "width": 300 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/b97f288023e547f40862976c89a5c342eacaaac1", - "width": 64 - } - ], - "is_externally_hosted": false, - "languages": [ - "en-US" - ], - "media_type": "audio", - "name": "Giant Bombcast", - "publisher": "Giant Bomb", - "type": "show", - "uri": "spotify:show:5as3aKmN2k11yfDDDSrvaZ" - } - ] -} diff --git a/src/test/fixtures/requests/data/tracks/GetSeveralTracksRequest.json b/src/test/fixtures/requests/data/tracks/GetSeveralTracksRequest.json deleted file mode 100644 index 74662de22..000000000 --- a/src/test/fixtures/requests/data/tracks/GetSeveralTracksRequest.json +++ /dev/null @@ -1,382 +0,0 @@ -{ - "tracks": [ - { - "album": { - "album_type": "album", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/0C0XlULifJtAgn6ZNCW2eu" - }, - "href": "https://api.spotify.com/v1/artists/0C0XlULifJtAgn6ZNCW2eu", - "id": "0C0XlULifJtAgn6ZNCW2eu", - "name": "The Killers", - "type": "artist", - "uri": "spotify:artist:0C0XlULifJtAgn6ZNCW2eu" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "external_urls": { - "spotify": "https://open.spotify.com/album/4OHNH3sDzIxnmUADXzv2kT" - }, - "href": "https://api.spotify.com/v1/albums/4OHNH3sDzIxnmUADXzv2kT", - "id": "4OHNH3sDzIxnmUADXzv2kT", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/ac68a9e4a867ec3ce8249cd90a2d7c73755fb487", - "width": 629 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/d0186ad64df7d6fc5f65c20c7d16f4279ffeb815", - "width": 295 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/7c3ec33d478f5f517eeb5339c2f75f150e4d601e", - "width": 63 - } - ], - "name": "Hot Fuss (Deluxe Version)", - "type": "album", - "uri": "spotify:album:4OHNH3sDzIxnmUADXzv2kT" - }, - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/0C0XlULifJtAgn6ZNCW2eu" - }, - "href": "https://api.spotify.com/v1/artists/0C0XlULifJtAgn6ZNCW2eu", - "id": "0C0XlULifJtAgn6ZNCW2eu", - "name": "The Killers", - "type": "artist", - "uri": "spotify:artist:0C0XlULifJtAgn6ZNCW2eu" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "disc_number": 1, - "duration_ms": 222200, - "explicit": false, - "external_ids": { - "isrc": "GBFFP0300052" - }, - "external_urls": { - "spotify": "https://open.spotify.com/track/3n3Ppam7vgaVa1iaRUc9Lp" - }, - "href": "https://api.spotify.com/v1/tracks/3n3Ppam7vgaVa1iaRUc9Lp", - "id": "3n3Ppam7vgaVa1iaRUc9Lp", - "name": "Mr. Brightside", - "popularity": 73, - "preview_url": "https://p.scdn.co/mp3-preview/4839b070015ab7d6de9fec1756e1f3096d908fba", - "track_number": 2, - "type": "track", - "uri": "spotify:track:3n3Ppam7vgaVa1iaRUc9Lp" - }, - { - "album": { - "album_type": "album", - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/0C0XlULifJtAgn6ZNCW2eu" - }, - "href": "https://api.spotify.com/v1/artists/0C0XlULifJtAgn6ZNCW2eu", - "id": "0C0XlULifJtAgn6ZNCW2eu", - "name": "The Killers", - "type": "artist", - "uri": "spotify:artist:0C0XlULifJtAgn6ZNCW2eu" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "external_urls": { - "spotify": "https://open.spotify.com/album/4OHNH3sDzIxnmUADXzv2kT" - }, - "href": "https://api.spotify.com/v1/albums/4OHNH3sDzIxnmUADXzv2kT", - "id": "4OHNH3sDzIxnmUADXzv2kT", - "images": [ - { - "height": 640, - "url": "https://i.scdn.co/image/ac68a9e4a867ec3ce8249cd90a2d7c73755fb487", - "width": 629 - }, - { - "height": 300, - "url": "https://i.scdn.co/image/d0186ad64df7d6fc5f65c20c7d16f4279ffeb815", - "width": 295 - }, - { - "height": 64, - "url": "https://i.scdn.co/image/7c3ec33d478f5f517eeb5339c2f75f150e4d601e", - "width": 63 - } - ], - "name": "Hot Fuss (Deluxe Version)", - "type": "album", - "uri": "spotify:album:4OHNH3sDzIxnmUADXzv2kT" - }, - "artists": [ - { - "external_urls": { - "spotify": "https://open.spotify.com/artist/0C0XlULifJtAgn6ZNCW2eu" - }, - "href": "https://api.spotify.com/v1/artists/0C0XlULifJtAgn6ZNCW2eu", - "id": "0C0XlULifJtAgn6ZNCW2eu", - "name": "The Killers", - "type": "artist", - "uri": "spotify:artist:0C0XlULifJtAgn6ZNCW2eu" - } - ], - "available_markets": [ - "AD", - "AR", - "AT", - "AU", - "BE", - "BG", - "BO", - "BR", - "CH", - "CL", - "CO", - "CR", - "CY", - "CZ", - "DE", - "DK", - "DO", - "EC", - "EE", - "ES", - "FI", - "FR", - "GB", - "GR", - "GT", - "HK", - "HN", - "HU", - "ID", - "IE", - "IS", - "IT", - "JP", - "LI", - "LT", - "LU", - "LV", - "MC", - "MT", - "MY", - "NI", - "NL", - "NO", - "NZ", - "PA", - "PE", - "PH", - "PL", - "PT", - "PY", - "SE", - "SG", - "SK", - "SV", - "TR", - "TW", - "UY" - ], - "disc_number": 1, - "duration_ms": 197280, - "explicit": false, - "external_ids": { - "isrc": "GBFFP0300054" - }, - "external_urls": { - "spotify": "https://open.spotify.com/track/3twNvmDtFQtAd5gMKedhLD" - }, - "href": "https://api.spotify.com/v1/tracks/3twNvmDtFQtAd5gMKedhLD", - "id": "3twNvmDtFQtAd5gMKedhLD", - "name": "Somebody Told Me", - "popularity": 65, - "preview_url": "https://p.scdn.co/mp3-preview/34470fdacaec1a5e9265d3d7c00c84804a9b564a", - "track_number": 4, - "type": "track", - "uri": "spotify:track:3twNvmDtFQtAd5gMKedhLD" - } - ] -} \ No newline at end of file diff --git a/src/test/fixtures/requests/data/users_profile/GetUsersProfileRequest.json b/src/test/fixtures/requests/data/users_profile/GetUsersProfileRequest.json deleted file mode 100644 index ea9de308a..000000000 --- a/src/test/fixtures/requests/data/users_profile/GetUsersProfileRequest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "display_name": "Lilla Namo", - "external_urls": { - "spotify": "https://open.spotify.com/user/tuggareutangranser" - }, - "followers": { - "href": null, - "total": 4561 - }, - "href": "https://api.spotify.com/v1/users/tuggareutangranser", - "id": "tuggareutangranser", - "images": [ - { - "height": null, - "url": "http://profile-images.scdn.co/artists/default/d4f208d4d49c6f3e1363765597d10c4277f5b74f", - "width": null - } - ], - "type": "user", - "uri": "spotify:user:tuggareutangranser" -} \ No newline at end of file diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetAlbumRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetAlbumRequestTest.java index e14a75f1d..3ad5d6f64 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetAlbumRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetAlbumRequestTest.java @@ -50,17 +50,12 @@ public void shouldReturnDefault(final Album album) { album.getAlbumType()); assertNotNull( album.getArtists()); - assertEquals( - 57, - album.getAvailableMarkets().length); assertEquals( 1, album.getCopyrights().length); assertEquals( "P", album.getCopyrights()[0].getType().toString()); - assertNotNull( - album.getExternalIds()); assertNotNull( album.getExternalUrls()); assertEquals( @@ -75,14 +70,9 @@ public void shouldReturnDefault(final Album album) { assertEquals( 3, album.getImages().length); - assertNull( - album.getLabel()); assertEquals( "She's So Unusual", album.getName()); - assertEquals( - 39, - (int) album.getPopularity()); assertEquals( "1983", album.getReleaseDate()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequestTest.java deleted file mode 100644 index aff3987a3..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/albums/GetSeveralAlbumsRequestTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package se.michaelthelin.spotify.requests.data.albums; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Album; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetSeveralAlbumsRequestTest extends AbstractDataTest { - - private final GetSeveralAlbumsRequest defaultRequest = SPOTIFY_API.getSeveralAlbums(ID_ALBUM, ID_ALBUM) - .setHttpManager(TestUtil.MockedHttpManager.returningJson("requests/data/albums/GetSeveralAlbumsRequest.json")) - .build(); - - private final GetSeveralAlbumsRequest emptyRequest = SPOTIFY_API.getSeveralAlbums(ID_ALBUM, ID_ALBUM) - .setHttpManager(TestUtil.MockedHttpManager.returningJson("requests/data/albums/GetSeveralAlbumsRequest_None.json")) - .build(); - - public GetSeveralAlbumsRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/albums?ids=5zT1JLIj9E57p3e1rFm9Uq%2C5zT1JLIj9E57p3e1rFm9Uq", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Album[] albums) { - assertEquals( - 1, - albums.length); - } - - @Test - public void shouldReturnEmpty_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnEmpty(emptyRequest.execute()); - } - - @Test - public void shouldReturnEmpty_async() throws ExecutionException, InterruptedException { - shouldReturnEmpty(emptyRequest.executeAsync().get()); - } - - public void shouldReturnEmpty(final Album[] albums) { - assertEquals( - 0, - albums.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistRequestTest.java index 50e4272c3..81d05b2f8 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistRequestTest.java @@ -13,7 +13,6 @@ import java.util.concurrent.ExecutionException; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; public class GetArtistRequestTest extends AbstractDataTest { private final GetArtistRequest defaultRequest = ITest.SPOTIFY_API.getArtist(ITest.ID_ARTIST) @@ -47,8 +46,6 @@ public void shouldReturnDefault(final Artist artist) { assertEquals( "https://open.spotify.com/artist/0OdUWJ0sBjDrqHygGUXeCF", artist.getExternalUrls().get("spotify")); - assertNotNull( - artist.getFollowers()); assertEquals( "indie folk", artist.getGenres()[0]); @@ -64,9 +61,6 @@ public void shouldReturnDefault(final Artist artist) { assertEquals( "Band of Horses", artist.getName()); - assertEquals( - 59, - (int) artist.getPopularity()); assertEquals( ModelObjectType.ARTIST, artist.getType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsAlbumsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsAlbumsRequestTest.java index c1bd4fde5..51c473bc3 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsAlbumsRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsAlbumsRequestTest.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test; import se.michaelthelin.spotify.ITest; import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.enums.AlbumGroup; import se.michaelthelin.spotify.enums.AlbumType; import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified; @@ -56,9 +55,6 @@ public void shouldReturnDefault(final Paging albumSimplifiedPag assertEquals( 2, albumSimplifiedPaging.getItems().length); - assertEquals( - AlbumGroup.SINGLE, - albumSimplifiedPaging.getItems()[0].getAlbumGroup()); assertEquals( AlbumType.SINGLE, albumSimplifiedPaging.getItems()[0].getAlbumType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequestTest.java deleted file mode 100644 index 2e43b31f9..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetArtistsTopTracksRequestTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package se.michaelthelin.spotify.requests.data.artists; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Track; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetArtistsTopTracksRequestTest extends AbstractDataTest { - private final GetArtistsTopTracksRequest defaultRequest = ITest.SPOTIFY_API.getArtistsTopTracks(ITest.ID_ARTIST, ITest.COUNTRY) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/artists/GetArtistsTopTracksRequest.json")) - .build(); - - public GetArtistsTopTracksRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/artists/0LcJLqbBmaGUft1e9Mm8HV/top-tracks?country=SE", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Track[] tracks) { - assertEquals( - 1, - tracks.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequestTest.java deleted file mode 100644 index 599ec618b..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/artists/GetSeveralArtistsRequestTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package se.michaelthelin.spotify.requests.data.artists; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Artist; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetSeveralArtistsRequestTest extends AbstractDataTest { - private final GetSeveralArtistsRequest defaultRequest = ITest.SPOTIFY_API.getSeveralArtists(ITest.ID_ARTIST, ITest.ID_ARTIST) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/artists/GetSeveralArtistsRequest.json")) - .build(); - - public GetSeveralArtistsRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/artists?ids=0LcJLqbBmaGUft1e9Mm8HV%2C0LcJLqbBmaGUft1e9Mm8HV", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Artist[] artists) { - assertEquals( - 2, - artists.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequestTest.java deleted file mode 100644 index d35cb0839..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetCategoryRequestTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Category; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetCategoryRequestTest extends AbstractDataTest { - private final GetCategoryRequest defaultRequest = SPOTIFY_API.getCategory(CATEGORY_ID) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/browse/GetCategoryRequest.json")) - .country(COUNTRY) - .locale(LOCALE) - .build(); - - public GetCategoryRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/browse/categories/dinner?country=SE&locale=sv_SE", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Category category) { - assertEquals( - "https://api.spotify.com/v1/browse/categories/party", - category.getHref()); - assertEquals( - 1, - category.getIcons().length); - assertEquals( - "party", - category.getId()); - assertEquals( - "Party", - category.getName()); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequestTest.java deleted file mode 100644 index 766c9c539..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfCategoriesRequestTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Category; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class GetListOfCategoriesRequestTest extends AbstractDataTest> { - private final GetListOfCategoriesRequest defaultRequest = SPOTIFY_API.getListOfCategories() - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/browse/GetListOfCategoriesRequest.json")) - .country(COUNTRY) - .limit(LIMIT) - .locale(LOCALE) - .offset(OFFSET) - .build(); - - public GetListOfCategoriesRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/browse/categories?country=SE&limit=10&locale=sv_SE&offset=0", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Paging categoryPaging) { - assertEquals( - "https://api.spotify.com/v1/browse/categories?offset=0&limit=20", - categoryPaging.getHref()); - assertEquals( - 5, - categoryPaging.getItems().length); - assertEquals( - 20, - (int) categoryPaging.getLimit()); - assertEquals( - "https://api.spotify.com/v1/browse/categories?offset=20&limit=20", - categoryPaging.getNext()); - assertEquals( - 0, - (int) categoryPaging.getOffset()); - assertNull( - categoryPaging.getPrevious()); - assertEquals( - 31, - (int) categoryPaging.getTotal()); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequestTest.java deleted file mode 100644 index addba1d09..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/browse/GetListOfNewReleasesRequestTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package se.michaelthelin.spotify.requests.data.browse; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.AlbumSimplified; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class GetListOfNewReleasesRequestTest extends AbstractDataTest> { - private final GetListOfNewReleasesRequest defaultRequest = SPOTIFY_API.getListOfNewReleases() - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/browse/GetListOfNewReleasesRequest.json")) - .country(COUNTRY) - .limit(LIMIT) - .offset(OFFSET) - .build(); - - public GetListOfNewReleasesRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/browse/new-releases?country=SE&limit=10&offset=0", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Paging albumSimplifiedPaging) { - assertEquals( - "https://api.spotify.com/v1/browse/new-releases?country=SE&offset=0&limit=20", - albumSimplifiedPaging.getHref()); - assertEquals( - 2, - albumSimplifiedPaging.getItems().length); - assertEquals( - 20, - (int) albumSimplifiedPaging.getLimit()); - assertEquals( - "https://api.spotify.com/v1/browse/new-releases?country=SE&offset=20&limit=20", - albumSimplifiedPaging.getNext()); - assertEquals( - 0, - (int) albumSimplifiedPaging.getOffset()); - assertNull( - albumSimplifiedPaging.getPrevious()); - assertEquals( - 500, - (int) albumSimplifiedPaging.getTotal()); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequestTest.java deleted file mode 100644 index 5167e8b19..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/episodes/GetSeveralEpisodesRequestTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package se.michaelthelin.spotify.requests.data.episodes; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Episode; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetSeveralEpisodesRequestTest extends AbstractDataTest { - private final GetSeveralEpisodesRequest defaultRequest = ITest.SPOTIFY_API - .getSeveralEpisodes(ITest.ID_EPISODE, ITest.ID_EPISODE) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/episodes/GetSeveralEpisodesRequest.json")) - .market(ITest.MARKET) - .build(); - - public GetSeveralEpisodesRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/episodes?ids=4GI3dxEafwap1sFiTGPKd1%2C4GI3dxEafwap1sFiTGPKd1&market=SE", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Episode[] episodes) { - assertEquals( - 2, - episodes.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequestTest.java deleted file mode 100644 index 79e8e472f..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveAlbumsForCurrentUserRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class RemoveAlbumsForCurrentUserRequestTest extends AbstractDataTest { - private final RemoveAlbumsForCurrentUserRequest defaultRequest = ITest.SPOTIFY_API - .removeAlbumsForCurrentUser(ITest.ID_ALBUM, ITest.ID_ALBUM) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final RemoveAlbumsForCurrentUserRequest bodyRequest = ITest.SPOTIFY_API - .removeAlbumsForCurrentUser(ITest.ALBUMS) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public RemoveAlbumsForCurrentUserRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/albums?ids=5zT1JLIj9E57p3e1rFm9Uq%2C5zT1JLIj9E57p3e1rFm9Uq", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.ALBUMS); - assertEquals("https://api.spotify.com:443/v1/me/albums", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequestTest.java deleted file mode 100644 index 50853595c..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedEpisodesRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class RemoveUsersSavedEpisodesRequestTest extends AbstractDataTest { - private final RemoveUsersSavedEpisodesRequest defaultRequest = ITest.SPOTIFY_API - .removeUsersSavedEpisodes(ITest.ID_EPISODE, ITest.ID_EPISODE) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final RemoveUsersSavedEpisodesRequest bodyRequest = ITest.SPOTIFY_API - .removeUsersSavedEpisodes(ITest.EPISODES) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public RemoveUsersSavedEpisodesRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/episodes?ids=4GI3dxEafwap1sFiTGPKd1%2C4GI3dxEafwap1sFiTGPKd1", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.EPISODES); - assertEquals("https://api.spotify.com:443/v1/me/episodes", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequestTest.java deleted file mode 100644 index e0c7712be..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedShowsRequestTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class RemoveUsersSavedShowsRequestTest extends AbstractDataTest { - private final RemoveUsersSavedShowsRequest defaultRequest = ITest.SPOTIFY_API - .removeUsersSavedShows(ITest.ID_SHOW, ITest.ID_SHOW) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .market(ITest.MARKET) - .build(); - private final RemoveUsersSavedShowsRequest bodyRequest = ITest.SPOTIFY_API - .removeUsersSavedShows(ITest.SHOWS) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .market(ITest.MARKET) - .build(); - - public RemoveUsersSavedShowsRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/shows?ids=5AvwZVawapvyhJUIx71pdJ%2C5AvwZVawapvyhJUIx71pdJ&market=SE", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.SHOWS); - assertEquals("https://api.spotify.com:443/v1/me/shows?market=SE", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequestTest.java deleted file mode 100644 index e3d44bdcc..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/RemoveUsersSavedTracksRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class RemoveUsersSavedTracksRequestTest extends AbstractDataTest { - private final RemoveUsersSavedTracksRequest defaultRequest = ITest.SPOTIFY_API - .removeUsersSavedTracks(ITest.ID_TRACK, ITest.ID_TRACK) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final RemoveUsersSavedTracksRequest bodyRequest = ITest.SPOTIFY_API - .removeUsersSavedTracks(ITest.TRACKS) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public RemoveUsersSavedTracksRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/tracks?ids=01iyCAUm8EvOFqVWYJ3dVX%2C01iyCAUm8EvOFqVWYJ3dVX", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.TRACKS); - assertEquals("https://api.spotify.com:443/v1/me/tracks", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequestTest.java deleted file mode 100644 index e97102dc1..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveAlbumsForCurrentUserRequestTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class SaveAlbumsForCurrentUserRequestTest extends AbstractDataTest { - private final SaveAlbumsForCurrentUserRequest defaultRequest = ITest.SPOTIFY_API - .saveAlbumsForCurrentUser(ITest.ID_ALBUM, ITest.ID_ALBUM) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final SaveAlbumsForCurrentUserRequest bodyRequest = ITest.SPOTIFY_API - .saveAlbumsForCurrentUser(ITest.ALBUMS.getAsJsonArray()) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public SaveAlbumsForCurrentUserRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/albums?ids=5zT1JLIj9E57p3e1rFm9Uq%2C5zT1JLIj9E57p3e1rFm9Uq", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter( - bodyRequest, - "ids", - ITest.ALBUMS); - assertEquals( - "https://api.spotify.com:443/v1/me/albums", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequestTest.java deleted file mode 100644 index 424df69de..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveEpisodesForCurrentUserRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class SaveEpisodesForCurrentUserRequestTest extends AbstractDataTest { - private final SaveEpisodesForCurrentUserRequest defaultRequest = ITest.SPOTIFY_API - .saveEpisodesForCurrentUser(ITest.ID_EPISODE, ITest.ID_EPISODE) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final SaveEpisodesForCurrentUserRequest bodyRequest = ITest.SPOTIFY_API - .saveEpisodesForCurrentUser(ITest.EPISODES) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public SaveEpisodesForCurrentUserRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/episodes?ids=4GI3dxEafwap1sFiTGPKd1%2C4GI3dxEafwap1sFiTGPKd1", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.EPISODES); - assertEquals("https://api.spotify.com:443/v1/me/episodes", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequestTest.java deleted file mode 100644 index ab208bc99..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveShowsForCurrentUserRequestTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class SaveShowsForCurrentUserRequestTest extends AbstractDataTest { - private final SaveShowsForCurrentUserRequest defaultRequest = ITest.SPOTIFY_API - .saveShowsForCurrentUser(ITest.ID_SHOW, ITest.ID_SHOW) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final SaveShowsForCurrentUserRequest bodyRequest = ITest.SPOTIFY_API - .saveShowsForCurrentUser(ITest.SHOWS) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public SaveShowsForCurrentUserRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/shows?ids=5AvwZVawapvyhJUIx71pdJ%2C5AvwZVawapvyhJUIx71pdJ", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter(bodyRequest, - "ids", - ITest.SHOWS); - assertEquals("https://api.spotify.com:443/v1/me/shows", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequestTest.java deleted file mode 100644 index cdd67ef07..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/library/SaveTracksForUserRequestTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package se.michaelthelin.spotify.requests.data.library; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static se.michaelthelin.spotify.Assertions.assertHasBodyParameter; -import static se.michaelthelin.spotify.Assertions.assertHasHeader; - -public class SaveTracksForUserRequestTest extends AbstractDataTest { - private final SaveTracksForUserRequest defaultRequest = ITest.SPOTIFY_API - .saveTracksForUser(ITest.ID_TRACK, ITest.ID_TRACK) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - private final SaveTracksForUserRequest bodyRequest = ITest.SPOTIFY_API - .saveTracksForUser(ITest.TRACKS) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson(null)) - .build(); - - public SaveTracksForUserRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/me/tracks?ids=01iyCAUm8EvOFqVWYJ3dVX%2C01iyCAUm8EvOFqVWYJ3dVX", - defaultRequest.getUri().toString()); - - assertHasAuthorizationHeader(bodyRequest); - assertHasHeader(defaultRequest, "Content-Type", "application/json"); - assertHasBodyParameter( - bodyRequest, - "ids", - ITest.TRACKS); - assertEquals( - "https://api.spotify.com:443/v1/me/tracks", - bodyRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final String string) { - assertNull( - string); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestNumericStringTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestNumericStringTest.java index 80b3b6d05..c7777dc86 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestNumericStringTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestNumericStringTest.java @@ -17,7 +17,7 @@ public void shouldPreserveNumericStringsAsStrings() { CreatePlaylistRequest request = new SpotifyApi.Builder() .setAccessToken("test-token") .build() - .createPlaylist("testuser", "2025") + .createPlaylist("2025") .description("2025") .build(); @@ -43,7 +43,7 @@ public void shouldPreserveMixedTypesCorrectly() { CreatePlaylistRequest request = new SpotifyApi.Builder() .setAccessToken("test-token") .build() - .createPlaylist("testuser", "123.45") // decimal number as string + .createPlaylist("123.45") // decimal number as string .description("abc123") // mixed alphanumeric .build(); @@ -61,7 +61,7 @@ public void shouldPreserveEmptyAndNullLikeStrings() { CreatePlaylistRequest request = new SpotifyApi.Builder() .setAccessToken("test-token") .build() - .createPlaylist("testuser", "null") + .createPlaylist("null") .description("true") .build(); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestTest.java index c3ae7f16d..ee7243fba 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/CreatePlaylistRequestTest.java @@ -17,7 +17,7 @@ public class CreatePlaylistRequestTest extends AbstractDataTest { private final CreatePlaylistRequest defaultRequest = ITest.SPOTIFY_API - .createPlaylist(ITest.ID_USER, ITest.NAME) + .createPlaylist(ITest.NAME) .setHttpManager( TestUtil.MockedHttpManager.returningJson( "requests/data/playlists/CreatePlaylistRequest.json")) @@ -50,7 +50,7 @@ public void shouldComplyWithReference() { "description", ITest.DESCRIPTION); assertEquals( - "https://api.spotify.com:443/v1/users/abbaspotify/playlists", + "https://api.spotify.com:443/v1/me/playlists", defaultRequest.getUri().toString()); } @@ -93,7 +93,7 @@ public void shouldReturnDefault(final Playlist playlist) { "s0o3TSuYnRLl2jch+oA4OEbKwq/fNxhGBkSPnvhZdmWjNV0q3uCAWuGIhEx8SHIx", playlist.getSnapshotId()); assertNotNull( - playlist.getTracks()); + playlist.getItems()); assertEquals( ModelObjectType.PLAYLIST, playlist.getType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequestTest.java deleted file mode 100644 index e0fedbfb9..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetListOfUsersPlaylistsRequestTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package se.michaelthelin.spotify.requests.data.playlists; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Paging; -import se.michaelthelin.spotify.model_objects.specification.PlaylistSimplified; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; - -public class GetListOfUsersPlaylistsRequestTest extends AbstractDataTest> { - private final GetListOfUsersPlaylistsRequest defaultRequest = ITest.SPOTIFY_API - .getListOfUsersPlaylists(ITest.ID_USER) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/playlists/GetListOfUsersPlaylistsRequest.json")) - .limit(ITest.LIMIT) - .offset(ITest.OFFSET) - .build(); - - private final GetListOfUsersPlaylistsRequest requestWithUserIdWithSymbol$ = ITest.SPOTIFY_API - .getListOfUsersPlaylists(ITest.ID_USER_WITH_$) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/playlists/GetListOfUsersPlaylistsRequest_UserWith$.json")) - .limit(ITest.LIMIT) - .offset(ITest.OFFSET) - .build(); - - public GetListOfUsersPlaylistsRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/users/abbaspotify/playlists?limit=10&offset=0", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - @Test - public void shouldReturnDefaultFor_UserId_With_$_async() throws ExecutionException, InterruptedException { - Paging playlistSimplifiedPaging = requestWithUserIdWithSymbol$.executeAsync().get(); - assertEquals( - "https://api.spotify.com/v1/users/%24wizzler%24/playlists", - playlistSimplifiedPaging.getHref()); - assertEquals( - 2, - playlistSimplifiedPaging.getItems().length); - assertEquals( - 9, - (int) playlistSimplifiedPaging.getLimit()); - assertNull( - playlistSimplifiedPaging.getNext()); - assertEquals( - 0, - (int) playlistSimplifiedPaging.getOffset()); - assertNull( - playlistSimplifiedPaging.getPrevious()); - assertEquals( - 9, - (int) playlistSimplifiedPaging.getTotal()); - } - - public void shouldReturnDefault(final Paging playlistSimplifiedPaging) { - assertEquals( - "https://api.spotify.com/v1/users/wizzler/playlists", - playlistSimplifiedPaging.getHref()); - assertEquals( - 2, - playlistSimplifiedPaging.getItems().length); - assertEquals( - 9, - (int) playlistSimplifiedPaging.getLimit()); - assertNull( - playlistSimplifiedPaging.getNext()); - assertEquals( - 0, - (int) playlistSimplifiedPaging.getOffset()); - assertNull( - playlistSimplifiedPaging.getPrevious()); - assertEquals( - 9, - (int) playlistSimplifiedPaging.getTotal()); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistRequestTest.java index ca8a7781f..10b891a61 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistRequestTest.java @@ -133,7 +133,7 @@ public void shouldReturnDefault(final Playlist playlist) { "bNLWdmhh+HDsbHzhckXeDC0uyKyg4FjPI/KEsKjAE526usnz2LxwgyBoMShVL+z+", playlist.getSnapshotId()); assertNotNull( - playlist.getTracks()); + playlist.getItems()); assertEquals( ModelObjectType.PLAYLIST, playlist.getType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistsItemsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistsItemsRequestTest.java index f6d1c322a..db6fc1244 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistsItemsRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/playlists/GetPlaylistsItemsRequestTest.java @@ -71,7 +71,7 @@ public void shouldReturnDefault(final Paging playlistTrackPaging) playlistTrackPaging.getItems().length); assertInstanceOf( Track.class, - playlistTrackPaging.getItems()[0].getTrack()); + playlistTrackPaging.getItems()[0].getItem()); assertEquals( 100, (int) playlistTrackPaging.getLimit()); @@ -106,7 +106,7 @@ public void shouldReturnDefaultEpisode(final Paging playlistTrack playlistTrackPaging.getItems().length); assertInstanceOf( Episode.class, - playlistTrackPaging.getItems()[0].getTrack()); + playlistTrackPaging.getItems()[0].getItem()); assertEquals( 100, (int) playlistTrackPaging.getLimit()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequestTest.java deleted file mode 100644 index b8390b855..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetSeveralShowsRequestTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package se.michaelthelin.spotify.requests.data.shows; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.ShowSimplified; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetSeveralShowsRequestTest extends AbstractDataTest { - - private final GetSeveralShowsRequest defaultRequest = SPOTIFY_API.getSeveralShows(ID_SHOW, ID_SHOW) - .setHttpManager(TestUtil.MockedHttpManager.returningJson("requests/data/shows/GetSeveralShowsRequest.json")) - .build(); - - public GetSeveralShowsRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/shows?ids=5AvwZVawapvyhJUIx71pdJ%2C5AvwZVawapvyhJUIx71pdJ", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final ShowSimplified[] shows) { - assertEquals( - 2, - shows.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetShowRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetShowRequestTest.java index 10c25e4eb..c40e7c583 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetShowRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/shows/GetShowRequestTest.java @@ -43,9 +43,6 @@ public void shouldReturnDefault_async() throws ExecutionException, InterruptedEx } public void shouldReturnDefault(final Show show) { - assertEquals( - 77, - show.getAvailableMarkets().length); assertEquals( 0, show.getCopyrights().length); @@ -81,9 +78,6 @@ public void shouldReturnDefault(final Show show) { assertEquals( "Acht Milliarden – Der Auslands-Podcast", show.getName()); - assertEquals( - "DER SPIEGEL", - show.getPublisher()); assertEquals( ModelObjectType.SHOW, show.getType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequestTest.java deleted file mode 100644 index 0a27f99c9..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetSeveralTracksRequestTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package se.michaelthelin.spotify.requests.data.tracks; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.Track; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class GetSeveralTracksRequestTest extends AbstractDataTest { - private final GetSeveralTracksRequest defaultRequest = ITest.SPOTIFY_API - .getSeveralTracks(ITest.ID_TRACK) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/tracks/GetSeveralTracksRequest.json")) - .market(ITest.MARKET) - .build(); - - public GetSeveralTracksRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - "https://api.spotify.com:443/v1/tracks?ids=01iyCAUm8EvOFqVWYJ3dVX&market=SE", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final Track[] tracks) { - assertEquals( - 2, - tracks.length); - } -} diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetTrackRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetTrackRequestTest.java index 592288b38..08c5afa71 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetTrackRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/tracks/GetTrackRequestTest.java @@ -51,9 +51,6 @@ public void shouldReturnDefault(final Track track) { assertNotNull( track.getArtists(), ""); - assertEquals( - 57, - track.getAvailableMarkets().length); assertEquals( 1, (int) track.getDiscNumber()); @@ -62,8 +59,6 @@ public void shouldReturnDefault(final Track track) { (int) track.getDurationMs()); assertFalse( track.getIsExplicit()); - assertNotNull( - track.getExternalIds()); assertNotNull( track.getExternalUrls()); assertEquals( @@ -75,9 +70,6 @@ public void shouldReturnDefault(final Track track) { assertEquals( "Mr. Brightside", track.getName()); - assertEquals( - 73, - (int) track.getPopularity()); assertEquals( "https://p.scdn.co/mp3-preview/4839b070015ab7d6de9fec1756e1f3096d908fba", track.getPreviewUrl()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetCurrentUsersProfileRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetCurrentUsersProfileRequestTest.java index 6f84d946c..6efe4b424 100644 --- a/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetCurrentUsersProfileRequestTest.java +++ b/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetCurrentUsersProfileRequestTest.java @@ -1,12 +1,10 @@ package se.michaelthelin.spotify.requests.data.users_profile; -import com.neovisionaries.i18n.CountryCode; import org.apache.hc.core5.http.ParseException; import org.junit.jupiter.api.Test; import se.michaelthelin.spotify.ITest; import se.michaelthelin.spotify.TestUtil; import se.michaelthelin.spotify.enums.ModelObjectType; -import se.michaelthelin.spotify.enums.ProductType; import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; import se.michaelthelin.spotify.model_objects.specification.User; import se.michaelthelin.spotify.requests.data.AbstractDataTest; @@ -50,19 +48,11 @@ public void shouldReturnDefault(final User user) { assertEquals( "1937-06-01", user.getBirthdate()); - assertEquals( - CountryCode.SE, - user.getCountry()); assertEquals( "JM Wizzler", user.getDisplayName()); - assertEquals( - "email@example.com", - user.getEmail()); assertNotNull( user.getExternalUrls()); - assertNotNull( - user.getFollowers()); assertEquals( "https://api.spotify.com/v1/users/wizzler", user.getHref()); @@ -72,9 +62,6 @@ public void shouldReturnDefault(final User user) { assertEquals( 1, user.getImages().length); - assertEquals( - ProductType.PREMIUM, - user.getProduct()); assertEquals( ModelObjectType.USER, user.getType()); diff --git a/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequestTest.java b/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequestTest.java deleted file mode 100644 index 7e527f6e7..000000000 --- a/src/test/java/se/michaelthelin/spotify/requests/data/users_profile/GetUsersProfileRequestTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package se.michaelthelin.spotify.requests.data.users_profile; - -import org.apache.hc.core5.http.ParseException; -import org.junit.jupiter.api.Test; -import se.michaelthelin.spotify.ITest; -import se.michaelthelin.spotify.TestUtil; -import se.michaelthelin.spotify.enums.ModelObjectType; -import se.michaelthelin.spotify.exceptions.SpotifyWebApiException; -import se.michaelthelin.spotify.model_objects.specification.User; -import se.michaelthelin.spotify.requests.data.AbstractDataTest; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class GetUsersProfileRequestTest extends AbstractDataTest { - private final GetUsersProfileRequest defaultRequest = ITest.SPOTIFY_API - .getUsersProfile(ITest.ID_USER_NON_ASCII) - .setHttpManager( - TestUtil.MockedHttpManager.returningJson( - "requests/data/users_profile/GetUsersProfileRequest.json")) - .build(); - - public GetUsersProfileRequestTest() throws Exception { - } - - @Test - public void shouldComplyWithReference() { - assertHasAuthorizationHeader(defaultRequest); - assertEquals( - // Yes, ABBA is not spelled that way ;) - // But it should be ensured non-ASCII characters are handled properly as well. - // Therefore, "abbaspötify" is used instead of "abbaspotify". - // "abbaspötify" should become abbasp%C3%B6tify after URL encoding. - // These characters do exist, for example there are plenty of them in the German speaking area, - // they are used in profile names and Spotify permits them. - // Additionally, the URL encoding is not only applied to non-ASCII characters as the set of characters allowed to be used in an URL - // is just a subset of ASCII. - // Only used ids and category ids are prone to this as the other ids used by spotify are Base62 encoded and - // therefore do not contain characters requiring to be encoded via Percent/URL encoding. - "https://api.spotify.com:443/v1/users/abbasp%C3%B6tify", - defaultRequest.getUri().toString()); - } - - @Test - public void shouldReturnDefault_sync() throws IOException, SpotifyWebApiException, ParseException { - shouldReturnDefault(defaultRequest.execute()); - } - - @Test - public void shouldReturnDefault_async() throws ExecutionException, InterruptedException { - shouldReturnDefault(defaultRequest.executeAsync().get()); - } - - public void shouldReturnDefault(final User user) { - assertEquals( - "Lilla Namo", - user.getDisplayName()); - assertNotNull( - user.getExternalUrls()); - assertNotNull( - user.getFollowers()); - assertEquals( - "https://api.spotify.com/v1/users/tuggareutangranser", - user.getHref()); - assertEquals( - "tuggareutangranser", - user.getId()); - assertEquals( - 1, - user.getImages().length); - assertEquals( - ModelObjectType.USER, - user.getType()); - assertEquals( - "spotify:user:tuggareutangranser", - user.getUri()); - } -}