class Spotify::SDK::Connect
Public Instance Methods
Collect the first active device.
@example
@sdk.connect.active_device # => #<Spotify::SDK::Connect::Device:...>
@see developer.spotify.com/console/get-users-available-devices/
@param [Hash] override_opts Custom options for HTTParty. @return [Array,NilClass] device The first device with `is_active`. If no device found, returns `nil`.
# File lib/spotify/sdk/connect.rb, line 70 def active_device(override_opts={}) devices(override_opts).find(&:active?) end
Collect all the active devices.
@example
@sdk.connect.active_devices # => [#<Spotify::SDK::Connect::Device:...>, ...]
@see developer.spotify.com/console/get-users-available-devices/
@param [Hash] override_opts Custom options for HTTParty. @return [Array] devices A list of all devices that are marked as `is_active`.
# File lib/spotify/sdk/connect.rb, line 55 def active_devices(override_opts={}) devices(override_opts).select(&:active?) end
Collect all the user's available devices. GET /v1/me/player/devices
@example
@sdk.connect.devices # => [#<Spotify::SDK::Connect::Device:...>, ...]
@see developer.spotify.com/console/get-users-available-devices/
@param [Hash] override_opts Custom options for HTTParty. @return [Array] devices A list of all devices.
# File lib/spotify/sdk/connect.rb, line 37 def devices(override_opts={}) response = send_http_request(:get, "/v1/me/player/devices", override_opts) response[:devices].map do |device| Spotify::SDK::Connect::Device.new(device, self) end end
Get the current playback. GET /v1/me/player
@example
playback = @sdk.connect.playback
@see developer.spotify.com/console/get-user-player/ @see developer.spotify.com/documentation/web-api/reference/player/get-information-about-the-users-current-playback/
@param [String] market The market you'd like to request. @param [Hash] override_opts Custom options for HTTParty. @return [Spotify::SDK::Connect::PlaybackState] playback_state Return the playback state object.
# File lib/spotify/sdk/connect.rb, line 20 def playback(market="from_token", override_opts={}) playback_state = send_http_request(:get, "/v1/me/player?market=%s" % market, override_opts) Spotify::SDK::Connect::PlaybackState.new(playback_state, self) end