Class: SpotifyWebApi::AlbumObject
- Defined in:
- lib/spotify_web_api/models/album_object.rb
Overview
AlbumObject Model.
Instance Attribute Summary collapse
-
#album_type ⇒ AlbumTypeEnum
The type of the album.
-
#artists ⇒ Array[SimplifiedArtistObject]
The artists of the album.
-
#available_markets ⇒ Array[String]
The markets in which the album is available: [ISO 3166-1 alpha-2 country codes](en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
-
#copyrights ⇒ Array[CopyrightObject]
The copyright statements of the album.
-
#external_ids ⇒ ExternalIdObject
Known external IDs for the album.
-
#external_urls ⇒ ExternalUrlObject
Known external URLs for this album.
-
#genres ⇒ Array[String]
A list of the genres the album is associated with.
-
#href ⇒ String
A link to the Web API endpoint providing full details of the album.
-
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the album.
-
#images ⇒ Array[ImageObject]
The cover art for the album in various sizes, widest first.
-
#label ⇒ String
The label associated with the album.
-
#name ⇒ String
The name of the album.
-
#popularity ⇒ Integer
The popularity of the album.
-
#release_date ⇒ String
The date the album was first released.
-
#release_date_precision ⇒ ReleaseDatePrecisionEnum
The precision with which ‘release_date` value is known.
-
#restrictions ⇒ AlbumRestrictionObject
Included in the response when a content restriction is applied.
-
#total_tracks ⇒ Integer
The number of tracks in the album.
-
#tracks ⇒ PagingSimplifiedTrackObject
The tracks of the album.
-
#type ⇒ Type2Enum
The object type.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the album.
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(album_type = nil, total_tracks = nil, available_markets = nil, external_urls = nil, href = nil, id = nil, images = nil, name = nil, release_date = nil, release_date_precision = nil, type = nil, uri = nil, artists = nil, tracks = nil, copyrights = nil, external_ids = nil, genres = nil, label = nil, popularity = nil, restrictions = SKIP) ⇒ AlbumObject
constructor
A new instance of AlbumObject.
Methods inherited from BaseModel
Constructor Details
#initialize(album_type = nil, total_tracks = nil, available_markets = nil, external_urls = nil, href = nil, id = nil, images = nil, name = nil, release_date = nil, release_date_precision = nil, type = nil, uri = nil, artists = nil, tracks = nil, copyrights = nil, external_ids = nil, genres = nil, label = nil, popularity = nil, restrictions = SKIP) ⇒ AlbumObject
Returns a new instance of AlbumObject.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/spotify_web_api/models/album_object.rb', line 139 def initialize(album_type = nil, total_tracks = nil, available_markets = nil, external_urls = nil, href = nil, id = nil, images = nil, name = nil, release_date = nil, release_date_precision = nil, type = nil, uri = nil, artists = nil, tracks = nil, copyrights = nil, external_ids = nil, genres = nil, label = nil, popularity = nil, restrictions = SKIP) @album_type = album_type @total_tracks = total_tracks @available_markets = available_markets @external_urls = external_urls @href = href @id = id @images = images @name = name @release_date = release_date @release_date_precision = release_date_precision @restrictions = restrictions unless restrictions == SKIP @type = type @uri = uri @artists = artists @tracks = tracks @copyrights = copyrights @external_ids = external_ids @genres = genres @label = label @popularity = popularity end |
Instance Attribute Details
#album_type ⇒ AlbumTypeEnum
The type of the album.
14 15 16 |
# File 'lib/spotify_web_api/models/album_object.rb', line 14 def album_type @album_type end |
#artists ⇒ Array[SimplifiedArtistObject]
The artists of the album. Each artist object includes a link in ‘href` to more detailed information about the artist.
73 74 75 |
# File 'lib/spotify_web_api/models/album_object.rb', line 73 def artists @artists end |
#available_markets ⇒ Array[String]
The markets in which the album is available: [ISO 3166-1 alpha-2 country codes](en.wikipedia.org/wiki/ISO_3166-1_alpha-2). _NOTE: an album is considered available in a market when at least 1 of its tracks is available in that market._
25 26 27 |
# File 'lib/spotify_web_api/models/album_object.rb', line 25 def available_markets @available_markets end |
#copyrights ⇒ Array[CopyrightObject]
The copyright statements of the album.
81 82 83 |
# File 'lib/spotify_web_api/models/album_object.rb', line 81 def copyrights @copyrights end |
#external_ids ⇒ ExternalIdObject
Known external IDs for the album.
85 86 87 |
# File 'lib/spotify_web_api/models/album_object.rb', line 85 def external_ids @external_ids end |
#external_urls ⇒ ExternalUrlObject
Known external URLs for this album.
29 30 31 |
# File 'lib/spotify_web_api/models/album_object.rb', line 29 def external_urls @external_urls end |
#genres ⇒ Array[String]
A list of the genres the album is associated with. If not yet classified, the array is empty.
90 91 92 |
# File 'lib/spotify_web_api/models/album_object.rb', line 90 def genres @genres end |
#href ⇒ String
A link to the Web API endpoint providing full details of the album.
33 34 35 |
# File 'lib/spotify_web_api/models/album_object.rb', line 33 def href @href end |
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the album.
38 39 40 |
# File 'lib/spotify_web_api/models/album_object.rb', line 38 def id @id end |
#images ⇒ Array[ImageObject]
The cover art for the album in various sizes, widest first.
42 43 44 |
# File 'lib/spotify_web_api/models/album_object.rb', line 42 def images @images end |
#label ⇒ String
The label associated with the album.
94 95 96 |
# File 'lib/spotify_web_api/models/album_object.rb', line 94 def label @label end |
#name ⇒ String
The name of the album. In case of an album takedown, the value may be an empty string.
47 48 49 |
# File 'lib/spotify_web_api/models/album_object.rb', line 47 def name @name end |
#popularity ⇒ Integer
The popularity of the album. The value will be between 0 and 100, with 100 being the most popular.
99 100 101 |
# File 'lib/spotify_web_api/models/album_object.rb', line 99 def popularity @popularity end |
#release_date ⇒ String
The date the album was first released.
51 52 53 |
# File 'lib/spotify_web_api/models/album_object.rb', line 51 def release_date @release_date end |
#release_date_precision ⇒ ReleaseDatePrecisionEnum
The precision with which ‘release_date` value is known.
55 56 57 |
# File 'lib/spotify_web_api/models/album_object.rb', line 55 def release_date_precision @release_date_precision end |
#restrictions ⇒ AlbumRestrictionObject
Included in the response when a content restriction is applied.
59 60 61 |
# File 'lib/spotify_web_api/models/album_object.rb', line 59 def restrictions @restrictions end |
#total_tracks ⇒ Integer
The number of tracks in the album.
18 19 20 |
# File 'lib/spotify_web_api/models/album_object.rb', line 18 def total_tracks @total_tracks end |
#tracks ⇒ PagingSimplifiedTrackObject
The tracks of the album.
77 78 79 |
# File 'lib/spotify_web_api/models/album_object.rb', line 77 def tracks @tracks end |
#type ⇒ Type2Enum
The object type.
63 64 65 |
# File 'lib/spotify_web_api/models/album_object.rb', line 63 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the album.
68 69 70 |
# File 'lib/spotify_web_api/models/album_object.rb', line 68 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/spotify_web_api/models/album_object.rb', line 169 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. album_type = hash.key?('album_type') ? hash['album_type'] : nil total_tracks = hash.key?('total_tracks') ? hash['total_tracks'] : nil available_markets = hash.key?('available_markets') ? hash['available_markets'] : nil external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] href = hash.key?('href') ? hash['href'] : nil id = hash.key?('id') ? hash['id'] : nil # 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 = nil unless hash.key?('images') name = hash.key?('name') ? hash['name'] : nil release_date = hash.key?('release_date') ? hash['release_date'] : nil release_date_precision = hash.key?('release_date_precision') ? hash['release_date_precision'] : nil type = hash.key?('type') ? hash['type'] : nil uri = hash.key?('uri') ? hash['uri'] : nil # Parameter is an array, so we need to iterate through it artists = nil unless hash['artists'].nil? artists = [] hash['artists'].each do |structure| artists << (SimplifiedArtistObject.from_hash(structure) if structure) end end artists = nil unless hash.key?('artists') tracks = PagingSimplifiedTrackObject.from_hash(hash['tracks']) if hash['tracks'] # Parameter is an array, so we need to iterate through it copyrights = nil unless hash['copyrights'].nil? copyrights = [] hash['copyrights'].each do |structure| copyrights << (CopyrightObject.from_hash(structure) if structure) end end copyrights = nil unless hash.key?('copyrights') external_ids = ExternalIdObject.from_hash(hash['external_ids']) if hash['external_ids'] genres = hash.key?('genres') ? hash['genres'] : nil label = hash.key?('label') ? hash['label'] : nil popularity = hash.key?('popularity') ? hash['popularity'] : nil restrictions = AlbumRestrictionObject.from_hash(hash['restrictions']) if hash['restrictions'] # Create object from extracted values. AlbumObject.new(album_type, total_tracks, available_markets, external_urls, href, id, images, name, release_date, release_date_precision, type, uri, artists, tracks, copyrights, external_ids, genres, label, popularity, restrictions) end |
.names ⇒ Object
A mapping from model property names to API property names.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/spotify_web_api/models/album_object.rb', line 102 def self.names @_hash = {} if @_hash.nil? @_hash['album_type'] = 'album_type' @_hash['total_tracks'] = 'total_tracks' @_hash['available_markets'] = 'available_markets' @_hash['external_urls'] = 'external_urls' @_hash['href'] = 'href' @_hash['id'] = 'id' @_hash['images'] = 'images' @_hash['name'] = 'name' @_hash['release_date'] = 'release_date' @_hash['release_date_precision'] = 'release_date_precision' @_hash['restrictions'] = 'restrictions' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash['artists'] = 'artists' @_hash['tracks'] = 'tracks' @_hash['copyrights'] = 'copyrights' @_hash['external_ids'] = 'external_ids' @_hash['genres'] = 'genres' @_hash['label'] = 'label' @_hash['popularity'] = 'popularity' @_hash end |
.nullables ⇒ Object
An array for nullable fields
135 136 137 |
# File 'lib/spotify_web_api/models/album_object.rb', line 135 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
128 129 130 131 132 |
# File 'lib/spotify_web_api/models/album_object.rb', line 128 def self.optionals %w[ restrictions ] end |