From 10e078d5e3fec9c5c14ecb4c7e09a39eaf269594 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:00:14 -0300 Subject: [PATCH 01/16] Add SavedShow and ShowSimplified models --- src/lib/models/index.ts | 2 + src/lib/models/library/saved-show.ts | 14 +++++++ src/lib/models/shows/show-simplified.ts | 56 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/lib/models/library/saved-show.ts create mode 100644 src/lib/models/shows/show-simplified.ts diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index d845b89d..5f354009 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -10,6 +10,7 @@ export { default as Error } from './common/error'; export { default as Followers } from './common/followers'; export { default as Image } from './common/image'; export { default as SavedAlbum } from './library/saved-album'; +export { default as SavedShow } from './library/saved-show'; export { default as SavedTrack } from './library/saved-track'; export { default as TrackLink } from './other/track-link'; export { default as CursorBasedPage } from './paging/cursor-based-page'; @@ -25,6 +26,7 @@ export { default as Playlist } from './playlist/playlist'; export { default as PlaylistSimplified } from './playlist/playlist-simplified'; export { default as PlaylistTrack } from './playlist/playlist-track'; export { default as SearchResults } from './search/search-results'; +export { default as ShowSimplified } from './shows/show'; export { default as AudioAnalysis } from './track/audio-analysis'; export { default as AudioFeatures } from './track/audio-features'; export { default as Track } from './track/track'; diff --git a/src/lib/models/library/saved-show.ts b/src/lib/models/library/saved-show.ts new file mode 100644 index 00000000..349403da --- /dev/null +++ b/src/lib/models/library/saved-show.ts @@ -0,0 +1,14 @@ +import ShowSimplified from '../shows/show-simplified'; + +class SavedShow { + addedAt: string; + + show: ShowSimplified; + + constructor(json: any) { + this.addedAt = json.added_at; + this.show = new ShowSimplified(json.show); + } +} + +export default SavedShow; diff --git a/src/lib/models/shows/show-simplified.ts b/src/lib/models/shows/show-simplified.ts new file mode 100644 index 00000000..0fa30ab2 --- /dev/null +++ b/src/lib/models/shows/show-simplified.ts @@ -0,0 +1,56 @@ +import Copyright from '../common/copyright'; +import Image from '../common/image'; + +class ShowSimplified { + availableMarkets: string[]; + + copyrights: Copyright[]; + + description: string; + + explicit: boolean; + + externalUrls: any; + + href: string; + + id: string; + + images: Image[]; + + isExternallyHosted: boolean | null; + + languages: string[]; + + mediaType: string; + + name: string; + + publisher: string; + + type: 'show'; + + uri: string; + + constructor(json: any) { + this.availableMarkets = json.available_markets; + this.copyrights = json.copyrights.map( + (copyrightJson: any) => new Copyright(copyrightJson) + ); + this.description = json.description; + this.explicit = json.explicit; + this.externalUrls = json.external_urls; + this.href = json.href; + this.id = json.id; + this.images = json.images.map((imageJson: any) => new Image(imageJson)); + this.isExternallyHosted = json.is_externally_hosted; + this.languages = json.languages; + this.mediaType = json.media_type; + this.name = json.name; + this.publisher = json.publisher; + this.type = json.type; + this.uri = json.uri; + } +} + +export default ShowSimplified; From 21fef338b86744adef2358c03611ffb2cfadee79 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:00:51 -0300 Subject: [PATCH 02/16] Adjust library requests with podcasts API --- src/lib/library.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/lib/library.ts b/src/lib/library.ts index 0531ae92..31a1369b 100644 --- a/src/lib/library.ts +++ b/src/lib/library.ts @@ -1,9 +1,9 @@ import { getAxiosSpotifyInstance } from './driver'; -import { Page, SavedAlbum, SavedTrack } from './models'; +import { Page, SavedAlbum, SavedShow, SavedTrack } from './models'; export const areSavedToCurrentUserLibrary = async ( ids: string[], - type: 'tracks' | 'albums' + type: 'tracks' | 'albums' | 'shows' ) => { const params = { ids: ids.join() }; const response = await getAxiosSpotifyInstance().get( @@ -35,9 +35,20 @@ export const getCurrentUserSavedTracks = async (params?: { return new Page(response.data, SavedTrack); }; -export const saveAlbumsOrTracksForCurrentUser = async ( +export const getCurrentUserSavedShows = async (params?: { + limit?: number; + offset?: number; + market?: string; +}) => { + const response = await getAxiosSpotifyInstance().get('/me/shows', { + params, + }); + return new Page(response.data, SavedShow); +}; + +export const saveToCurrentUserLibrary = async ( ids: string[], - type: 'albums' | 'tracks' + type: 'albums' | 'tracks' | 'shows' ) => { const response = await getAxiosSpotifyInstance().put(`/me/${type}`, { ids, @@ -45,9 +56,9 @@ export const saveAlbumsOrTracksForCurrentUser = async ( return response.data; }; -export const removeAlbumsOrTracksForCurrentUser = async ( +export const removeFromCurrentUserLibrary = async ( ids: string[], - type: 'albums' | 'tracks' + type: 'albums' | 'tracks' | 'shows' ) => { const data = { ids }; const response = await getAxiosSpotifyInstance().delete(`/me/${type}`, { From 4f563afd24d8bf1ff4789b6dfeb0f29d1fb5479e Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:04:22 -0300 Subject: [PATCH 03/16] Rename folder to pattern --- src/lib/models/index.ts | 2 +- src/lib/models/library/saved-show.ts | 2 +- src/lib/models/{shows => show}/show-simplified.ts | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/lib/models/{shows => show}/show-simplified.ts (100%) diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index 5f354009..e3c14ecd 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -26,7 +26,7 @@ export { default as Playlist } from './playlist/playlist'; export { default as PlaylistSimplified } from './playlist/playlist-simplified'; export { default as PlaylistTrack } from './playlist/playlist-track'; export { default as SearchResults } from './search/search-results'; -export { default as ShowSimplified } from './shows/show'; +export { default as ShowSimplified } from './show/show'; export { default as AudioAnalysis } from './track/audio-analysis'; export { default as AudioFeatures } from './track/audio-features'; export { default as Track } from './track/track'; diff --git a/src/lib/models/library/saved-show.ts b/src/lib/models/library/saved-show.ts index 349403da..071af43a 100644 --- a/src/lib/models/library/saved-show.ts +++ b/src/lib/models/library/saved-show.ts @@ -1,4 +1,4 @@ -import ShowSimplified from '../shows/show-simplified'; +import ShowSimplified from '../show/show-simplified'; class SavedShow { addedAt: string; diff --git a/src/lib/models/shows/show-simplified.ts b/src/lib/models/show/show-simplified.ts similarity index 100% rename from src/lib/models/shows/show-simplified.ts rename to src/lib/models/show/show-simplified.ts From 341c67bafb3d37f36ee77b0c3a935d4a693fecd8 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:32:57 -0300 Subject: [PATCH 04/16] Add Episode and EpisodeSimplified models --- src/lib/models/episode/episode-simplified.ts | 69 ++++++++++++++++++++ src/lib/models/episode/episode.ts | 13 ++++ src/lib/models/index.ts | 2 + 3 files changed, 84 insertions(+) create mode 100644 src/lib/models/episode/episode-simplified.ts create mode 100644 src/lib/models/episode/episode.ts diff --git a/src/lib/models/episode/episode-simplified.ts b/src/lib/models/episode/episode-simplified.ts new file mode 100644 index 00000000..15a8e113 --- /dev/null +++ b/src/lib/models/episode/episode-simplified.ts @@ -0,0 +1,69 @@ +import Image from '../common/image'; + +class EpisodeSimplified { + audioPreviewUrl: string; + + description: string; + + durationMs: number; + + explicit: boolean; + + externalUrls: any; + + href: string; + + id: string; + + images: Image[]; + + isExternallyHosted: boolean | null; + + isPlayable: boolean; + + languages: string[]; + + name: string; + + releaseDate: string; + + releaseDatePrecision: 'year' | 'month' | 'day'; + + resumePoint: ResumePoint; + + type: 'episode'; + + uri: string; + + constructor(json: any) { + this.audioPreviewUrl = json.audio_preview_url; + this.description = json.description; + this.durationMs = json.duration_ms; + this.explicit = json.explicit; + this.externalUrls = json.external_urls; + this.href = json.href; + this.id = json.id; + this.images = json.images.map((imageJson: any) => new Image(imageJson)); + this.isExternallyHosted = json.is_externally_hosted; + this.isPlayable = json.is_playable; + this.languages = json.languages; + this.name = json.name; + this.releaseDate = json.release_date; + this.releaseDatePrecision = json.release_date_precision; + this.resumePoint = new ResumePoint(json.resume_point); + this.type = json.type; + this.uri = json.uri; + } +} + +class ResumePoint { + fullyPlayed: boolean; + resumePositionMs: number; + + constructor(json: any) { + this.fullyPlayed = json.fully_played; + this.resumePositionMs = json.resume_position_ms; + } +} + +export default EpisodeSimplified; diff --git a/src/lib/models/episode/episode.ts b/src/lib/models/episode/episode.ts new file mode 100644 index 00000000..ecda8d30 --- /dev/null +++ b/src/lib/models/episode/episode.ts @@ -0,0 +1,13 @@ +import EpisodeSimplified from './episode-simplified'; +import ShowSimplified from '../show/show-simplified'; + +class Episode extends EpisodeSimplified { + show: ShowSimplified; + + constructor(json: any) { + super(json); + this.show = new ShowSimplified(json.show); + } +} + +export default Episode; diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index e3c14ecd..7ab776d1 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -9,6 +9,8 @@ export { default as Copyright } from './common/copyright'; export { default as Error } from './common/error'; export { default as Followers } from './common/followers'; export { default as Image } from './common/image'; +export { default as Episode } from './episode/episode'; +export { default as EpisodeSimplified } from './episode/episode-simplified'; export { default as SavedAlbum } from './library/saved-album'; export { default as SavedShow } from './library/saved-show'; export { default as SavedTrack } from './library/saved-track'; From 67e787ba529bc24b91924ed184e920d4249e29c9 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:33:39 -0300 Subject: [PATCH 05/16] Implement episode data retrieval requests --- src/lib/episodes.ts | 21 +++++++++++++++++++++ src/lib/index.ts | 1 + 2 files changed, 22 insertions(+) create mode 100644 src/lib/episodes.ts diff --git a/src/lib/episodes.ts b/src/lib/episodes.ts new file mode 100644 index 00000000..4e2a56e7 --- /dev/null +++ b/src/lib/episodes.ts @@ -0,0 +1,21 @@ +import { getAxiosSpotifyInstance } from './driver'; +import { Episode } from './models'; + +export const getSeveralEpisodes = async ( + ids: string[], + params?: { market?: string } +) => { + const response = await getAxiosSpotifyInstance().get('/episodes', { + params: { ids: ids.join(','), ...params }, + }); + return response.data.episodes.map( + (episodeJson: any) => new Episode(episodeJson) + ); +}; + +export const getEpisode = async (id: string, params?: { market?: string }) => { + const response = await getAxiosSpotifyInstance().get(`/episodes/${id}`, { + params, + }); + return new Episode(response.data); +}; diff --git a/src/lib/index.ts b/src/lib/index.ts index 3cb19124..23e7ad11 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -2,6 +2,7 @@ export * from './albums'; export * from './artists'; export * from './browse'; export * from './driver'; +export * from './episodes'; export * from './follow'; export * from './library'; export * from './personalization'; From fc2772c0ef7e4799ce698c4c2381c57550a6a477 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:57:57 -0300 Subject: [PATCH 06/16] Add Show model and update EpisodeSimplified --- src/lib/models/episode/episode-simplified.ts | 5 +++-- src/lib/models/index.ts | 3 ++- src/lib/models/show/show.ts | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/lib/models/show/show.ts diff --git a/src/lib/models/episode/episode-simplified.ts b/src/lib/models/episode/episode-simplified.ts index 15a8e113..c78d761d 100644 --- a/src/lib/models/episode/episode-simplified.ts +++ b/src/lib/models/episode/episode-simplified.ts @@ -29,7 +29,7 @@ class EpisodeSimplified { releaseDatePrecision: 'year' | 'month' | 'day'; - resumePoint: ResumePoint; + resumePoint?: ResumePoint; type: 'episode'; @@ -50,7 +50,8 @@ class EpisodeSimplified { this.name = json.name; this.releaseDate = json.release_date; this.releaseDatePrecision = json.release_date_precision; - this.resumePoint = new ResumePoint(json.resume_point); + if (json.resume_point) + this.resumePoint = new ResumePoint(json.resume_point); this.type = json.type; this.uri = json.uri; } diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index 7ab776d1..91f5d73c 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -28,7 +28,8 @@ export { default as Playlist } from './playlist/playlist'; export { default as PlaylistSimplified } from './playlist/playlist-simplified'; export { default as PlaylistTrack } from './playlist/playlist-track'; export { default as SearchResults } from './search/search-results'; -export { default as ShowSimplified } from './show/show'; +export { default as Show } from './show/show'; +export { default as ShowSimplified } from './show/show-simplified'; export { default as AudioAnalysis } from './track/audio-analysis'; export { default as AudioFeatures } from './track/audio-features'; export { default as Track } from './track/track'; diff --git a/src/lib/models/show/show.ts b/src/lib/models/show/show.ts new file mode 100644 index 00000000..ceeb5ccb --- /dev/null +++ b/src/lib/models/show/show.ts @@ -0,0 +1,17 @@ +import EpisodeSimplified from '../episode/episode-simplified'; +import Page from '../paging/page'; +import ShowSimplified from './show-simplified'; + +class Show extends ShowSimplified { + episodes: Page; + + constructor(json: any) { + super(json); + this.episodes = new Page( + json.episodes, + EpisodeSimplified + ); + } +} + +export default Show; From 45b0daf358de215f9ac5f203649fde84f284fdbb Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 21:59:56 -0300 Subject: [PATCH 07/16] Implement show data retrieval requests --- src/lib/index.ts | 1 + src/lib/shows.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/lib/shows.ts diff --git a/src/lib/index.ts b/src/lib/index.ts index 23e7ad11..e9d1801d 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -9,6 +9,7 @@ export * from './personalization'; export * from './playlists'; export * from './player'; export * from './search'; +export * from './shows'; export * from './tracks'; export * from './users-profile'; export * from './models'; diff --git a/src/lib/shows.ts b/src/lib/shows.ts new file mode 100644 index 00000000..081e2a21 --- /dev/null +++ b/src/lib/shows.ts @@ -0,0 +1,36 @@ +import { getAxiosSpotifyInstance } from './driver'; +import { Show, ShowSimplified, Page, EpisodeSimplified } from './models'; + +export const getSeveralShows = async ( + ids: string[], + params?: { market?: string } +) => { + const response = await getAxiosSpotifyInstance().get('/shows', { + params: { ids: ids.join(','), ...params }, + }); + return response.data.shows.map( + (showJson: any) => new ShowSimplified(showJson) + ); +}; + +export const getShow = async (id: string, params?: { market?: string }) => { + const response = await getAxiosSpotifyInstance().get(`/shows/${id}`, { + params, + }); + return new Show(response.data); +}; + +export const getShowEpisodes = async ( + id: string, + params?: { + limit?: number; + offset?: number; + market?: string; + } +) => { + const response = await getAxiosSpotifyInstance().get( + `/shows/${id}/episodes`, + { params } + ); + return new Page(response.data, EpisodeSimplified); +}; From b2fd3bc4c2edca1b6a0f3617b98a5c0d666e3f3f Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:35:49 -0300 Subject: [PATCH 08/16] Adapt CurrentlyPlaying item and add actions --- src/lib/models/player/currently-playing.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/models/player/currently-playing.ts b/src/lib/models/player/currently-playing.ts index 69b34285..bc7cac6b 100644 --- a/src/lib/models/player/currently-playing.ts +++ b/src/lib/models/player/currently-playing.ts @@ -1,19 +1,28 @@ import Context from './context'; import Track from '../track/track'; +import Episode from '../episode/episode'; class CurrentlyPlaying { + actions: any; context: Context | null; currentlyPlayingType: string; isPlaying: boolean; - item: Track | null; + item: Track | Episode | null; progressMs: number; timestamp: number; constructor(json: any) { + this.actions = json.actions; this.context = json.context ? new Context(json.context) : null; this.currentlyPlayingType = json.currently_playing_type; this.isPlaying = json.is_playing; - this.item = json.item ? new Track(json.item) : null; + if (this.currentlyPlayingType === 'track' && json.item) { + this.item = new Track(json.item); + } else if (this.currentlyPlayingType === 'episode' && json.item) { + this.item = new Episode(json.item); + } else { + this.item = null; + } this.progressMs = json.progress_ms; this.timestamp = json.timestamp; } From d4fadbb98743119eb8b458b6c9cdd35f5482cdb8 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:36:39 -0300 Subject: [PATCH 09/16] Adjust player requests with podcast API --- src/lib/player.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/player.ts b/src/lib/player.ts index 3fcada1b..36e15608 100644 --- a/src/lib/player.ts +++ b/src/lib/player.ts @@ -27,10 +27,12 @@ export const getCurrentUserRecentlyPlayedTracks = async (params?: { export const getCurrentUserCurrentlyPlayingTrack = async (params?: { market?: string; + additionalTypes?: 'track' | 'episode' | ['track', 'episode']; }) => { + const snakeCaseParams = propertiesToSnakeCase(params); const response = await getAxiosSpotifyInstance().get( '/me/player/currently-playing', - { params } + { params: snakeCaseParams } ); return new CurrentlyPlaying(response.data); }; @@ -44,9 +46,11 @@ export const getUserAvailableDevices = async () => { export const getUserPlaybackInformation = async (params?: { market?: string; + additionalTypes?: 'track' | 'episode' | ['track', 'episode']; }) => { + const snakeCaseParams = propertiesToSnakeCase(params); const response = await getAxiosSpotifyInstance().get('/me/player/', { - params, + params: snakeCaseParams, }); return new CurrentlyPlayingContext(response.data); }; From 7aee7841618c24d3951df529d7e5c5943a6f29fb Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:50:37 -0300 Subject: [PATCH 10/16] Adapt SearchResults to allow episodes and shows --- src/lib/models/search/search-results.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/models/search/search-results.ts b/src/lib/models/search/search-results.ts index 4681eeb3..05c85be1 100644 --- a/src/lib/models/search/search-results.ts +++ b/src/lib/models/search/search-results.ts @@ -1,7 +1,9 @@ import Page from '../paging/page'; import AlbumSimplified from '../album/album-simplified'; import Artist from '../artist/artist'; +import EpisodeSimplified from '../episode/episode-simplified'; import PlaylistSimplified from '../playlist/playlist-simplified'; +import ShowSimplified from '../show/show-simplified'; import Track from '../track/track'; class SearchResults { @@ -9,6 +11,8 @@ class SearchResults { artists?: Page; playlists?: Page; tracks?: Page; + episodes?: Page; + shows?: Page; constructor(json: any) { if (json.albums) { @@ -31,6 +35,20 @@ class SearchResults { if (json.tracks) { this.tracks = new Page(json, Track, 'tracks'); } + if (json.episodes) { + this.episodes = new Page( + json, + EpisodeSimplified, + 'episodes' + ); + } + if (json.shows) { + this.shows = new Page( + json, + ShowSimplified, + 'shows' + ); + } } } From 7e530e9bc155825395888277cd2a486b4563539f Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:51:21 -0300 Subject: [PATCH 11/16] Implement search for shows and episodes --- src/lib/search.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/lib/search.ts b/src/lib/search.ts index 2bb96912..4b72e386 100644 --- a/src/lib/search.ts +++ b/src/lib/search.ts @@ -6,6 +6,8 @@ import { PlaylistSimplified, Track, SearchResults, + ShowSimplified, + EpisodeSimplified, } from './models'; const genericSearch = async (params: { @@ -71,3 +73,29 @@ export const searchTracks = async ( const searchResults = await genericSearch(params); return new Page(searchResults.data, Track, 'tracks'); }; + +export const searchShows = async ( + query: string, + options?: { market?: string; limit?: number; offset?: number } +) => { + const params = { q: query, type: 'show', ...options }; + const searchResults = await genericSearch(params); + return new Page( + searchResults.data, + ShowSimplified, + 'shows' + ); +}; + +export const searchEpisodes = async ( + query: string, + options?: { market?: string; limit?: number; offset?: number } +) => { + const params = { q: query, type: 'episode', ...options }; + const searchResults = await genericSearch(params); + return new Page( + searchResults.data, + EpisodeSimplified, + 'episodes' + ); +}; From 409bf289007db100720aeca92fa9a3322758f2df Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:52:15 -0300 Subject: [PATCH 12/16] Fix lint problem --- src/lib/models/episode/episode-simplified.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/models/episode/episode-simplified.ts b/src/lib/models/episode/episode-simplified.ts index c78d761d..609ec22f 100644 --- a/src/lib/models/episode/episode-simplified.ts +++ b/src/lib/models/episode/episode-simplified.ts @@ -50,8 +50,9 @@ class EpisodeSimplified { this.name = json.name; this.releaseDate = json.release_date; this.releaseDatePrecision = json.release_date_precision; - if (json.resume_point) + if (json.resume_point) { this.resumePoint = new ResumePoint(json.resume_point); + } this.type = json.type; this.uri = json.uri; } From a5cb12578cca4b6aca2742a994bd835b14fa17d7 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 22:53:30 -0300 Subject: [PATCH 13/16] Update version to 0.6.0 in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7993d2a5..50971499 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "Robson Junior (https://github.com/JRobsonJr)" ], "license": "MIT", - "version": "0.5.2", + "version": "0.6.0", "dependencies": { "@types/lodash": "^4.14.121", "axios": "^0.18.1", From 39f787c763d515185f57a1aa00ac95a72572e6d7 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 23:06:34 -0300 Subject: [PATCH 14/16] Update CHANGELOG --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 234bb328..072bd6fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- Podcast-related (episodes and shows) retrieval and searching endpoints. +- Episode, SimplifiedEpisode, Show, SimplifiedShow and SavedShow models. +- actions to CurrentlyPlaying object. + +### Changed + +- areSavedToCurrentUserLibrary supports shows. +- getCurrentUserCurrentlyPlayingTrack and getUserPlaybackInformation support episodes. +- saveAlbumsOrTracksForCurrentUser renamed into saveToCurrentUserLibrary to improve naming and saving shows. +- removeAlbumsOrTracksForCurrentUser renamed into removeFromCurrentUserLibrary to improve naming and removing shows. +- CurrentlyPlaying model supports an episode as its item. +- SearchResults model supports episodes and shows as possible fields. + ## [0.5.2] - 2019-10-27 ### Added From 9f80b28e1b1a49575f9d674d0a1135f3fd12b2cf Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Fri, 27 Mar 2020 23:12:28 -0300 Subject: [PATCH 15/16] Fix breaking tests --- test/common/matching-attributes.test.ts | 2 +- test/library.test.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/common/matching-attributes.test.ts b/test/common/matching-attributes.test.ts index 168c68ea..65417e55 100644 --- a/test/common/matching-attributes.test.ts +++ b/test/common/matching-attributes.test.ts @@ -146,7 +146,7 @@ export const checkMatchingCurrentlyPlayingAttributes = ( if (response.context) { checkMatchingContextAttributes(response.context, mock.context); } - if (response.item) { + if (response.item && response.item instanceof Track) { checkMatchingTrackAttributes(response.item, mock.item); } const attributes = [ diff --git a/test/library.test.ts b/test/library.test.ts index e1b26fe2..edf8a4a6 100644 --- a/test/library.test.ts +++ b/test/library.test.ts @@ -14,8 +14,8 @@ import { getCurrentUserSavedTracks, SavedTrack, areSavedToCurrentUserLibrary, - saveAlbumsOrTracksForCurrentUser, - removeAlbumsOrTracksForCurrentUser, + saveToCurrentUserLibrary, + removeFromCurrentUserLibrary, } from '../src/lib'; import { savedAlbumsMock } from './mocks/library/saved-albums.mock'; import { savedTracksMock } from './mocks/library/saved-tracks.mock'; @@ -133,7 +133,7 @@ describe('Library requests', () => { }); }); - describe('#saveAlbumsOrTracksForCurrentUser()', () => { + describe('#saveToCurrentUserLibrary()', () => { describe('type tracks', () => { beforeEach(() => { nock('https://api.spotify.com/v1') @@ -142,7 +142,7 @@ describe('Library requests', () => { }); it('response should be empty', async () => { - const savedResponse = await saveAlbumsOrTracksForCurrentUser( + const savedResponse = await saveToCurrentUserLibrary( ['2jpDioAB9tlYXMdXDK3BGl'], 'tracks' ); @@ -158,7 +158,7 @@ describe('Library requests', () => { }); it('response should be empty', async () => { - const savedResponse = await saveAlbumsOrTracksForCurrentUser( + const savedResponse = await saveToCurrentUserLibrary( ['3VNWq8rTnQG6fM1eldSpZ0'], 'albums' ); @@ -167,7 +167,7 @@ describe('Library requests', () => { }); }); - describe('#removeAlbumsOrTracksForCurrentUser()', () => { + describe('#removeFromCurrentUserLibrary()', () => { describe('type tracks', () => { beforeEach(() => { nock('https://api.spotify.com/v1') @@ -176,7 +176,7 @@ describe('Library requests', () => { }); it('response should be empty', async () => { - const removeResponse = await removeAlbumsOrTracksForCurrentUser( + const removeResponse = await removeFromCurrentUserLibrary( ['2jpDioAB9tlYXMdXDK3BGl'], 'tracks' ); @@ -192,7 +192,7 @@ describe('Library requests', () => { }); it('response should be empty', async () => { - const removeResponse = await removeAlbumsOrTracksForCurrentUser( + const removeResponse = await removeFromCurrentUserLibrary( ['3VNWq8rTnQG6fM1eldSpZ0'], 'albums' ); From 7ab2ccf5d4bb29c2ab883d8ae78a59e9c34e77c9 Mon Sep 17 00:00:00 2001 From: Robson Junior Date: Sat, 28 Mar 2020 17:10:58 -0300 Subject: [PATCH 16/16] Improve CHANGELOG with more descriptive points --- CHANGELOG.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 072bd6fd..0188a3a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added -- Podcast-related (episodes and shows) retrieval and searching endpoints. -- Episode, SimplifiedEpisode, Show, SimplifiedShow and SavedShow models. -- actions to CurrentlyPlaying object. +- Podcast-related retrieval and searching endpoints: `getEpisode`, `getSeveralEpisodes`, `getCurrentUserSavedShows`, `searchShows`, `searchEpisodes`. +- Podcast-related models: `EpisodeSimplified`, `Episode`, `SavedShow`, `Show`, `ShowSimplified`. +- `actions` to `CurrentlyPlaying` and `Episode` as a possible `item` type. +- `episodes` and `shows` as possible attributes in `SearchResults`. +- `additionalTypes` to the query parameters of `getCurrentUserCurrentlyPlayingTrack` and `getUserPlaybackInformation` to allow considering an `Episode` as the currently playing media. +- `'shows'` as a possible value for the `type` in `areSavedToCurrentUserLibrary`. ### Changed -- areSavedToCurrentUserLibrary supports shows. -- getCurrentUserCurrentlyPlayingTrack and getUserPlaybackInformation support episodes. -- saveAlbumsOrTracksForCurrentUser renamed into saveToCurrentUserLibrary to improve naming and saving shows. -- removeAlbumsOrTracksForCurrentUser renamed into removeFromCurrentUserLibrary to improve naming and removing shows. -- CurrentlyPlaying model supports an episode as its item. -- SearchResults model supports episodes and shows as possible fields. +- `saveAlbumsOrTracksForCurrentUser` renamed to `saveToCurrentUserLibrary` and support to shows. +- `removeAlbumsOrTracksForCurrentUser` renamed to `removeFromCurrentUserLibrary` and support to shows. ## [0.5.2] - 2019-10-27