Class: SpotifyWebApi::MePlayerRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/me_player_request.rb

Overview

MePlayerRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(device_ids = nil, play = SKIP) ⇒ MePlayerRequest

Returns a new instance of MePlayerRequest.



45
46
47
48
# File 'lib/spotify_web_api/models/me_player_request.rb', line 45

def initialize(device_ids = nil, play = SKIP)
  @device_ids = device_ids
  @play = play unless play == SKIP
end

Instance Attribute Details

#device_idsArray[String]

A JSON array containing the ID of the device on which playback should be started/transferred.<br/>For example:‘"74ASZWbe4lXaubB36ztrGX"`<br/>_Note: Although an array is accepted, only a single device_id is currently supported. Supplying more than one will return `400 Bad Request`_

Returns:

  • (Array[String])


18
19
20
# File 'lib/spotify_web_api/models/me_player_request.rb', line 18

def device_ids
  @device_ids
end

#playTrueClass | FalseClass

true: ensure playback happens on new device.<br/>false or not provided: keep the current playback state.

Returns:

  • (TrueClass | FalseClass)


23
24
25
# File 'lib/spotify_web_api/models/me_player_request.rb', line 23

def play
  @play
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/spotify_web_api/models/me_player_request.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  device_ids = hash.key?('device_ids') ? hash['device_ids'] : nil
  play = hash.key?('play') ? hash['play'] : SKIP

  # Create object from extracted values.
  MePlayerRequest.new(device_ids,
                      play)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
# File 'lib/spotify_web_api/models/me_player_request.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['device_ids'] = 'device_ids'
  @_hash['play'] = 'play'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/spotify_web_api/models/me_player_request.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
# File 'lib/spotify_web_api/models/me_player_request.rb', line 34

def self.optionals
  %w[
    play
  ]
end