Class: SpotifyWebApi::PlaylistObject
- Defined in:
- lib/spotify_web_api/models/playlist_object.rb
Overview
PlaylistObject Model.
Instance Attribute Summary collapse
-
#collaborative ⇒ TrueClass | FalseClass
‘true` if the owner allows other users to modify the playlist.
-
#description ⇒ String
The playlist description.
-
#external_urls ⇒ ExternalUrlObject
Known external URLs for this playlist.
-
#followers ⇒ FollowersObject
Information about the followers of the playlist.
-
#href ⇒ String
A link to the Web API endpoint providing full details of the playlist.
-
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.
-
#images ⇒ Array[ImageObject]
Images for the playlist.
-
#name ⇒ String
The name of the playlist.
-
#owner ⇒ PlaylistOwnerObject
The user who owns the playlist.
-
#public ⇒ TrueClass | FalseClass
The playlist’s public/private status: ‘true` the playlist is public, `false` the playlist is private, `null` the playlist status is not relevant.
-
#snapshot_id ⇒ String
The version identifier for the current playlist.
-
#tracks ⇒ PagingPlaylistTrackObject
The tracks of the playlist.
-
#type ⇒ String
The object type: “playlist”.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(collaborative = SKIP, description = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, owner = SKIP, public = SKIP, snapshot_id = SKIP, tracks = SKIP, type = SKIP, uri = SKIP) ⇒ PlaylistObject
constructor
A new instance of PlaylistObject.
Methods inherited from BaseModel
Constructor Details
#initialize(collaborative = SKIP, description = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, owner = SKIP, public = SKIP, snapshot_id = SKIP, tracks = SKIP, type = SKIP, uri = SKIP) ⇒ PlaylistObject
Returns a new instance of PlaylistObject.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 126 def initialize(collaborative = SKIP, description = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, owner = SKIP, public = SKIP, snapshot_id = SKIP, tracks = SKIP, type = SKIP, uri = SKIP) @collaborative = collaborative unless collaborative == SKIP @description = description unless description == SKIP @external_urls = external_urls unless external_urls == SKIP @followers = followers unless followers == SKIP @href = href unless href == SKIP @id = id unless id == SKIP @images = images unless images == SKIP @name = name unless name == SKIP @owner = owner unless owner == SKIP @public = public unless public == SKIP @snapshot_id = snapshot_id unless snapshot_id == SKIP @tracks = tracks unless tracks == SKIP @type = type unless type == SKIP @uri = uri unless uri == SKIP end |
Instance Attribute Details
#collaborative ⇒ TrueClass | FalseClass
‘true` if the owner allows other users to modify the playlist.
14 15 16 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 14 def collaborative @collaborative end |
#description ⇒ String
The playlist description. _Only returned for modified, verified playlists, otherwise_ ‘null`.
19 20 21 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 19 def description @description end |
#external_urls ⇒ ExternalUrlObject
Known external URLs for this playlist.
23 24 25 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 23 def external_urls @external_urls end |
#followers ⇒ FollowersObject
Information about the followers of the playlist.
27 28 29 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 27 def followers @followers end |
#href ⇒ String
A link to the Web API endpoint providing full details of the playlist.
31 32 33 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 31 def href @href end |
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.
36 37 38 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 36 def id @id end |
#images ⇒ Array[ImageObject]
Images for the playlist. The array may be empty or contain up to three images. The images are returned by size in descending order. See [Working with Playlists](/documentation/web-api/concepts/playlists). _Note: If returned, the source URL for the image (‘url`) is temporary and will expire in less than a day._
44 45 46 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 44 def images @images end |
#name ⇒ String
The name of the playlist.
48 49 50 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 48 def name @name end |
#owner ⇒ PlaylistOwnerObject
The user who owns the playlist
52 53 54 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 52 def owner @owner end |
#public ⇒ TrueClass | FalseClass
The playlist’s public/private status: ‘true` the playlist is public, `false` the playlist is private, `null` the playlist status is not relevant. For more about public/private status, see [Working with Playlists](/documentation/web-api/concepts/playlists)
59 60 61 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 59 def public @public end |
#snapshot_id ⇒ String
The version identifier for the current playlist. Can be supplied in other requests to target a specific playlist version
64 65 66 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 64 def snapshot_id @snapshot_id end |
#tracks ⇒ PagingPlaylistTrackObject
The tracks of the playlist.
68 69 70 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 68 def tracks @tracks end |
#type ⇒ String
The object type: “playlist”
72 73 74 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 72 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.
77 78 79 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 77 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 148 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. collaborative = hash.key?('collaborative') ? hash['collaborative'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] followers = FollowersObject.from_hash(hash['followers']) if hash['followers'] href = hash.key?('href') ? hash['href'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP # Parameter is an array, so we need to iterate through it images = nil unless hash['images'].nil? images = [] hash['images'].each do |structure| images << (ImageObject.from_hash(structure) if structure) end end images = SKIP unless hash.key?('images') name = hash.key?('name') ? hash['name'] : SKIP owner = PlaylistOwnerObject.from_hash(hash['owner']) if hash['owner'] public = hash.key?('public') ? hash['public'] : SKIP snapshot_id = hash.key?('snapshot_id') ? hash['snapshot_id'] : SKIP tracks = PagingPlaylistTrackObject.from_hash(hash['tracks']) if hash['tracks'] type = hash.key?('type') ? hash['type'] : SKIP uri = hash.key?('uri') ? hash['uri'] : SKIP # Create object from extracted values. PlaylistObject.new(collaborative, description, external_urls, followers, href, id, images, name, owner, public, snapshot_id, tracks, type, uri) end |
.names ⇒ Object
A mapping from model property names to API property names.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 80 def self.names @_hash = {} if @_hash.nil? @_hash['collaborative'] = 'collaborative' @_hash['description'] = 'description' @_hash['external_urls'] = 'external_urls' @_hash['followers'] = 'followers' @_hash['href'] = 'href' @_hash['id'] = 'id' @_hash['images'] = 'images' @_hash['name'] = 'name' @_hash['owner'] = 'owner' @_hash['public'] = 'public' @_hash['snapshot_id'] = 'snapshot_id' @_hash['tracks'] = 'tracks' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash end |
.nullables ⇒ Object
An array for nullable fields
120 121 122 123 124 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 120 def self.nullables %w[ description ] end |
.optionals ⇒ Object
An array for optional fields
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/spotify_web_api/models/playlist_object.rb', line 100 def self.optionals %w[ collaborative description external_urls followers href id images name owner public snapshot_id tracks type uri ] end |