Class: SpotifyWebApi::MePlayerPlayRequest

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

Overview

MePlayerPlayRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(context_uri = SKIP, uris = SKIP, offset = SKIP, position_ms = SKIP) ⇒ MePlayerPlayRequest

Returns a new instance of MePlayerPlayRequest.



64
65
66
67
68
69
70
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 64

def initialize(context_uri = SKIP, uris = SKIP, offset = SKIP,
               position_ms = SKIP)
  @context_uri = context_uri unless context_uri == SKIP
  @uris = uris unless uris == SKIP
  @offset = offset unless offset == SKIP
  @position_ms = position_ms unless position_ms == SKIP
end

Instance Attribute Details

#context_uriString

Optional. Spotify URI of the context to play. Valid contexts are albums, artists & playlists. ‘context_uri:“spotify:album:1Je1IMUlBXcx1Fz0WE7oPT”`

Returns:

  • (String)


16
17
18
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 16

def context_uri
  @context_uri
end

#offsetObject

Optional. Indicates from where in the context playback should start. Only available when context_uri corresponds to an album or playlist object “position” is zero based and can’t be negative. Example: ‘“offset”: 5` “uri” is a string representing the uri of the item to start at. Example: `“offset”: “spotify:track:1301WleyT98MSxVHPZCA6M”`

Returns:

  • (Object)


31
32
33
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 31

def offset
  @offset
end

#position_msInteger

Indicates from what position to start playback. Must be a positive number. Passing in a position that is greater than the length of the track will cause the player to start playing the next song.

Returns:

  • (Integer)


37
38
39
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 37

def position_ms
  @position_ms
end

#urisArray[String]

Optional. A JSON array of the Spotify track URIs to play. For example: ‘[“spotify:track:4iV5W9uYEdYUVa79Axb7Rh”, “spotify:track:1301WleyT98MSxVHPZCA6M”]`

Returns:

  • (Array[String])


22
23
24
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 22

def uris
  @uris
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  context_uri = hash.key?('context_uri') ? hash['context_uri'] : SKIP
  uris = hash.key?('uris') ? hash['uris'] : SKIP
  offset = hash.key?('offset') ? hash['offset'] : SKIP
  position_ms = hash.key?('position_ms') ? hash['position_ms'] : SKIP

  # Create object from extracted values.
  MePlayerPlayRequest.new(context_uri,
                          uris,
                          offset,
                          position_ms)
end

.namesObject

A mapping from model property names to API property names.



40
41
42
43
44
45
46
47
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 40

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['context_uri'] = 'context_uri'
  @_hash['uris'] = 'uris'
  @_hash['offset'] = 'offset'
  @_hash['position_ms'] = 'position_ms'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
# File 'lib/spotify_web_api/models/me_player_play_request.rb', line 50

def self.optionals
  %w[
    context_uri
    uris
    offset
    position_ms
  ]
end