Skip to content

Commit

Permalink
expose undocumented podcast episode/show endpoints spotify/web-api#55…
Browse files Browse the repository at this point in the history
  • Loading branch information
repentsinner committed Aug 21, 2019
1 parent 37a7865 commit 02fc419
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,33 @@ SpotifyWebApi.prototype = {
}
},

/**
* Look up a podcast episode.
* @param {string} episodeId The episode's ID.
* @param {Object} [options] The possible options.
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
* @example getEpisode('3Qm86XLflmIXVm1wcwkgDK').then(...)
* @returns {Promise|undefined} A promise that if successful, returns an object containing information
* about the episode. Not returned if a callback is given.
*/
getEpisode: function(episodeId, options, callback) {
// In case someone is using a version where options parameter did not exist.
var actualCallback, actualOptions;
if (typeof options === 'function' && !callback) {
actualCallback = options;
actualOptions = {};
} else {
actualCallback = callback;
actualOptions = options;
}

return WebApiRequest.builder(this.getAccessToken())
.withPath('/v1/episodes/' + episodeId)
.withQueryParameters(actualOptions)
.build()
.execute(HttpManager.get, actualCallback);
},

/**
* Look up a track.
* @param {string} trackId The track's ID.
Expand Down Expand Up @@ -165,6 +192,33 @@ SpotifyWebApi.prototype = {
.execute(HttpManager.get, actualCallback);
},

/**
* Look up a podcast show.
* @param {string} albumId The show's ID.
* @param {Object} [options] The possible options.
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
* @example getShow('0sNOF9WDwhWunNAHPD3Baj').then(...)
* @returns {Promise|undefined} A promise that if successful, returns an object containing information
* about the show. Not returned if a callback is given.
*/
getShow: function(showId, options, callback) {
// In case someone is using a version where options parameter did not exist.
var actualCallback, actualOptions;
if (typeof options === 'function' && !callback) {
actualCallback = options;
actualOptions = {};
} else {
actualCallback = callback;
actualOptions = options;
}

return WebApiRequest.builder(this.getAccessToken())
.withPath('/v1/shows/' + showId)
.withQueryParameters(actualOptions)
.build()
.execute(HttpManager.get, actualCallback);
},

/**
* Look up an album.
* @param {string} albumId The album's ID.
Expand Down

0 comments on commit 02fc419

Please sign in to comment.