Class: SpotifyWebApi::UsersPlaylistsRequest

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

Overview

UsersPlaylistsRequest 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 = nil, public = SKIP, collaborative = SKIP, description = SKIP) ⇒ UsersPlaylistsRequest

Returns a new instance of UsersPlaylistsRequest.



62
63
64
65
66
67
68
# File 'lib/spotify_web_api/models/users_playlists_request.rb', line 62

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

Instance Attribute Details

#collaborativeTrueClass | FalseClass

Defaults to false. If true the playlist will be collaborative. _Note: to create a collaborative playlist you must also set public to false. To create collaborative playlists you must have granted playlist-modify-private and playlist-modify-public [scopes](/documentation/web-api/concepts/scopes/#list-of-scopes)._

Returns:

  • (TrueClass | FalseClass)


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

def collaborative
  @collaborative
end

#descriptionString

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

Returns:

  • (String)


36
37
38
# File 'lib/spotify_web_api/models/users_playlists_request.rb', line 36

def description
  @description
end

#nameString

The name for the new playlist, for example ‘“Your Coolest Playlist”`. This name does not need to be unique; a user may have several playlists with the same name.

Returns:

  • (String)


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

def name
  @name
end

#publicTrueClass | FalseClass

Defaults to true. If true the playlist will be public, if false it will be private. To be able to create private playlists, the user must have granted the playlist-modify-private [scope](/documentation/web-api/concepts/scopes/#list-of-scopes)

Returns:

  • (TrueClass | FalseClass)


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

def public
  @public
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  name = hash.key?('name') ? hash['name'] : nil
  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.

  UsersPlaylistsRequest.new(name,
                            public,
                            collaborative,
                            description)
end

.namesObject

A mapping from model property names to API property names.



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

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



58
59
60
# File 'lib/spotify_web_api/models/users_playlists_request.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
# File 'lib/spotify_web_api/models/users_playlists_request.rb', line 49

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