Class: SpotifyWebApi::PlaylistsTracksRequest

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

Overview

PlaylistsTracksRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(uris = SKIP, position = SKIP) ⇒ PlaylistsTracksRequest

Returns a new instance of PlaylistsTracksRequest.



54
55
56
57
# File 'lib/spotify_web_api/models/playlists_tracks_request.rb', line 54

def initialize(uris = SKIP, position = SKIP)
  @uris = uris unless uris == SKIP
  @position = position unless position == SKIP
end

Instance Attribute Details

#positionInteger

The position to insert the items, a zero-based index. For example, to insert the items in the first position: ‘position=0` ; to insert the items in the third position: `position=2`. If omitted, the items will be appended to the playlist. Items are added in the order they appear in the uris array. For example: `[“spotify:track:4iV5W9uYEdYUVa79Axb7Rh”,“spotify:track:1301WleyT98MSxVHPZC A6M”], “position”: 3`

Returns:

  • (Integer)


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

def position
  @position
end

#urisArray[String]

A JSON array of the [Spotify URIs](/documentation/web-api/concepts/spotify-uris-ids) to add. For example: ‘[“spotify:track:4iV5W9uYEdYUVa79Axb7Rh”,“spotify:track:1301WleyT98MSxVHPZC A6M”, “spotify:episode:512ojhOuo1ktJprKbVcKyQ”]`<br/>A maximum of 100 items can be added in one request. _Note: if the `uris` parameter is present in the query string, any URIs listed here in the body will be ignored._

Returns:

  • (Array[String])


21
22
23
# File 'lib/spotify_web_api/models/playlists_tracks_request.rb', line 21

def uris
  @uris
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/spotify_web_api/models/playlists_tracks_request.rb', line 60

def self.from_hash(hash)
  return nil unless hash

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

  # Create object from extracted values.
  PlaylistsTracksRequest.new(uris,
                             position)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/spotify_web_api/models/playlists_tracks_request.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    uris
    position
  ]
end