@@ -1585,6 +1585,93 @@ SpotifyWebApi.prototype = {
1585
1585
}
1586
1586
} ,
1587
1587
1588
+ /**
1589
+ * Get the Current User's Connect Devices
1590
+ * @param {requestCallback } [callback] Optional callback method to be called instead of the promise.
1591
+ * @returns {Promise|undefined } A promise that if successful, resolves into a paging object of tracks,
1592
+ * otherwise an error. Not returned if a callback is given.
1593
+ */
1594
+ getMyDevices : function ( callback ) {
1595
+ var request = WebApiRequest . builder ( )
1596
+ . withPath ( '/v1/me/player/devices' )
1597
+ . build ( ) ;
1598
+
1599
+ this . _addAccessToken ( request , this . getAccessToken ( ) ) ;
1600
+
1601
+ var promise = this . _performRequest ( HttpManager . get , request ) ;
1602
+
1603
+ if ( callback ) {
1604
+ promise . then ( function ( data ) {
1605
+ callback ( null , data ) ;
1606
+ } , function ( err ) {
1607
+ callback ( err ) ;
1608
+ } ) ;
1609
+ } else {
1610
+ return promise ;
1611
+ }
1612
+ } ,
1613
+
1614
+ /**
1615
+ * Get the Current User's Current Playback State
1616
+ * @param {Object } [options] Options, being market.
1617
+ * @param {requestCallback } [callback] Optional callback method to be called instead of the promise.
1618
+ * @returns {Promise|undefined } A promise that if successful, resolves into a paging object of tracks,
1619
+ * otherwise an error. Not returned if a callback is given.
1620
+ */
1621
+ getMyCurrentPlaybackState : function ( options , callback ) {
1622
+ var request = WebApiRequest . builder ( )
1623
+ . withPath ( '/v1/me/player' )
1624
+ . build ( ) ;
1625
+
1626
+ this . _addAccessToken ( request , this . getAccessToken ( ) ) ;
1627
+ this . _addQueryParameters ( request , options ) ;
1628
+
1629
+ var promise = this . _performRequest ( HttpManager . get , request ) ;
1630
+
1631
+ if ( callback ) {
1632
+ promise . then ( function ( data ) {
1633
+ callback ( null , data ) ;
1634
+ } , function ( err ) {
1635
+ callback ( err ) ;
1636
+ } ) ;
1637
+ } else {
1638
+ return promise ;
1639
+ }
1640
+ } ,
1641
+
1642
+ /**
1643
+ * Transfer a User's Playback
1644
+ * @param {Object } [options] Options, being market.
1645
+ * @param {requestCallback } [callback] Optional callback method to be called instead of the promise.
1646
+ * @returns {Promise|undefined } A promise that if successful, resolves into a paging object of tracks,
1647
+ * otherwise an error. Not returned if a callback is given.
1648
+ */
1649
+ transferMyPlayback : function ( options , callback ) {
1650
+ var request = WebApiRequest . builder ( )
1651
+ . withPath ( '/v1/me/player' )
1652
+ . withHeaders ( { 'Content-Type' : 'application/json' } )
1653
+ . withBodyParameters ( {
1654
+ 'device_ids' : options . deviceIds ,
1655
+ 'play' : options . play || false
1656
+ } )
1657
+ . build ( ) ;
1658
+
1659
+ this . _addAccessToken ( request , this . getAccessToken ( ) ) ;
1660
+ this . _addBodyParameters ( request , options ) ;
1661
+
1662
+ var promise = this . _performRequest ( HttpManager . put , request ) ;
1663
+
1664
+ if ( callback ) {
1665
+ promise . then ( function ( data ) {
1666
+ callback ( null , data ) ;
1667
+ } , function ( err ) {
1668
+ callback ( err ) ;
1669
+ } ) ;
1670
+ } else {
1671
+ return promise ;
1672
+ }
1673
+ } ,
1674
+
1588
1675
/**
1589
1676
* Add the current user as a follower of one or more other Spotify users.
1590
1677
* @param {string[] } userIds The IDs of the users to be followed.
0 commit comments