Class: SpotifyWebApi::PlaylistsRequest

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

Overview

PlaylistsRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = SKIP, public = SKIP, collaborative = SKIP, description = SKIP) ⇒ PlaylistsRequest

Returns a new instance of PlaylistsRequest.



57
58
59
60
61
62
63
# File 'lib/spotify_web_api/models/playlists_request.rb', line 57

def initialize(name = SKIP, public = SKIP, collaborative = SKIP,
               description = SKIP)
  @name = name unless name == SKIP
  @public = public unless public == SKIP
  @collaborative = collaborative unless collaborative == SKIP
  @description = description unless description == SKIP
end

Instance Attribute Details

#collaborativeTrueClass | FalseClass

If ‘true`, the playlist will become collaborative and other users will be able to modify the playlist in their Spotify client. <br/> _Note: You can only set `collaborative` to `true` on non-public playlists._

Returns:

  • (TrueClass | FalseClass)


25
26
27
# File 'lib/spotify_web_api/models/playlists_request.rb', line 25

def collaborative
  @collaborative
end

#descriptionString

Value for playlist description as displayed in Spotify Clients and in the Web API.

Returns:

  • (String)


30
31
32
# File 'lib/spotify_web_api/models/playlists_request.rb', line 30

def description
  @description
end

#nameString

The new name for the playlist, for example ‘“My New Playlist Title”`

Returns:

  • (String)


14
15
16
# File 'lib/spotify_web_api/models/playlists_request.rb', line 14

def name
  @name
end

#publicTrueClass | FalseClass

If ‘true` the playlist will be public, if `false` it will be private.

Returns:

  • (TrueClass | FalseClass)


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

def public
  @public
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/spotify_web_api/models/playlists_request.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  public = hash.key?('public') ? hash['public'] : SKIP
  collaborative = hash.key?('collaborative') ? hash['collaborative'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  PlaylistsRequest.new(name,
                       public,
                       collaborative,
                       description)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['public'] = 'public'
  @_hash['collaborative'] = 'collaborative'
  @_hash['description'] = 'description'
  @_hash
end

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/spotify_web_api/models/playlists_request.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



43
44
45
46
47
48
49
50
# File 'lib/spotify_web_api/models/playlists_request.rb', line 43

def self.optionals
  %w[
    name
    public
    collaborative
    description
  ]
end