File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1788,6 +1788,31 @@ describe('Spotify Web API', () => {
1788
1788
} ) ;
1789
1789
} ) ;
1790
1790
1791
+ test ( "should add songs to the user's queue:" , done => {
1792
+ sinon . stub ( HttpManager , '_makeRequest' , function (
1793
+ method ,
1794
+ options ,
1795
+ uri ,
1796
+ callback
1797
+ ) {
1798
+ expect ( method ) . toBe ( superagent . post ) ;
1799
+ expect ( uri ) . toBe ( 'https://api.spotify.com/v1/me/player/queue' ) ;
1800
+ expect ( options . query ) . toEqual ( {
1801
+ uri : 'spotify:track:2jpDioAB9tlYXMdXDK3BGl'
1802
+ } ) ;
1803
+ expect ( options . headers ) . toEqual ( {
1804
+ Authorization : 'Bearer someAccessToken'
1805
+ } ) ;
1806
+ callback ( null , null ) ;
1807
+ } ) ;
1808
+
1809
+ var api = new SpotifyWebApi ( {
1810
+ accessToken : 'someAccessToken'
1811
+ } ) ;
1812
+
1813
+ api . addToQueue ( 'spotify:track:2jpDioAB9tlYXMdXDK3BGl' ) . then ( done ) ;
1814
+ } ) ;
1815
+
1791
1816
test ( "should get user's devices:" , done => {
1792
1817
sinon . stub ( HttpManager , '_makeRequest' ) . callsFake ( function (
1793
1818
method ,
Original file line number Diff line number Diff line change @@ -1029,6 +1029,28 @@ SpotifyWebApi.prototype = {
1029
1029
} ,
1030
1030
1031
1031
/**
1032
+
1033
+ * Add track or episode to device queue
1034
+ * @param {string } [uri] uri of the track or episode to add
1035
+ * @param {Object } [options] Options, being device_id.
1036
+ * @param {requestCallback } [callback] Optional callback method to be called instead of the promise.
1037
+ * @returns {Promise|undefined } A promise that if successful, resolves into a paging object of tracks,
1038
+ * otherwise an error. Not returned if a callback is given.
1039
+ */
1040
+ addToQueue : function ( uri , options , callback ) {
1041
+ return WebApiRequest . builder ( this . getAccessToken ( ) )
1042
+ . withPath ( '/v1/me/player/queue' )
1043
+ . withQueryParameters (
1044
+ {
1045
+ uri : uri
1046
+ } ,
1047
+ options
1048
+ )
1049
+ . build ( )
1050
+ . execute ( HttpManager . post , callback ) ;
1051
+ } ,
1052
+
1053
+
1032
1054
* Get the Current User 's Available Devices
1033
1055
* @param { requestCallback } [ callback ] Optional callback method to be called instead of the promise .
1034
1056
* @returns { Promise | undefined } A promise that if successful , resolves into an array of device objects ,
You can’t perform that action at this time.
0 commit comments