Class: SpotifyWebApi::PlaylistsTracksRequest2

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

Overview

PlaylistsTracksRequest2 Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(tracks = nil, snapshot_id = SKIP) ⇒ PlaylistsTracksRequest2

Returns a new instance of PlaylistsTracksRequest2.



48
49
50
51
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 48

def initialize(tracks = nil, snapshot_id = SKIP)
  @tracks = tracks
  @snapshot_id = snapshot_id unless snapshot_id == SKIP
end

Instance Attribute Details

#snapshot_idString

The playlist’s snapshot ID against which you want to make the changes. The API will validate that the specified items exist and in the specified positions and make the changes, even if more recent changes have been made to the playlist.

Returns:

  • (String)


26
27
28
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 26

def snapshot_id
  @snapshot_id
end

#tracksArray[Track1]

An array of objects containing [Spotify URIs](/documentation/web-api/concepts/spotify-uris-ids) of the tracks or episodes to remove. For example: ‘{ “tracks”: [{ “uri”: “spotify:track:4iV5W9uYEdYUVa79Axb7Rh” },{ “uri”: “spotify:track:1301WleyT98MSxVHPZCA6M” }] }`. A maximum of 100 objects can be sent at once.

Returns:



19
20
21
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 19

def tracks
  @tracks
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  tracks = nil
  unless hash['tracks'].nil?
    tracks = []
    hash['tracks'].each do |structure|
      tracks << (Track1.from_hash(structure) if structure)
    end
  end

  tracks = nil unless hash.key?('tracks')
  snapshot_id = hash.key?('snapshot_id') ? hash['snapshot_id'] : SKIP

  # Create object from extracted values.
  PlaylistsTracksRequest2.new(tracks,
                              snapshot_id)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 29

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

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
# File 'lib/spotify_web_api/models/playlists_tracks_request2.rb', line 37

def self.optionals
  %w[
    snapshot_id
  ]
end