Class: SpotifyWebApi::SimplifiedAlbumObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::SimplifiedAlbumObject
- Defined in:
- lib/spotify_web_api/models/simplified_album_object.rb
Overview
SimplifiedAlbumObject 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).
-
#external_urls ⇒ ExternalUrlObject
Known external URLs for this album.
-
#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.
-
#name ⇒ String
The name 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.
-
#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, restrictions = SKIP) ⇒ SimplifiedAlbumObject
constructor
A new instance of SimplifiedAlbumObject.
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, restrictions = SKIP) ⇒ SimplifiedAlbumObject
Returns a new instance of SimplifiedAlbumObject.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 107 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, 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 end |
Instance Attribute Details
#album_type ⇒ AlbumTypeEnum
The type of the album.
14 15 16 |
# File 'lib/spotify_web_api/models/simplified_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/simplified_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/simplified_album_object.rb', line 25 def available_markets @available_markets end |
#external_urls ⇒ ExternalUrlObject
Known external URLs for this album.
29 30 31 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 29 def external_urls @external_urls 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/simplified_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/simplified_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/simplified_album_object.rb', line 42 def images @images 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/simplified_album_object.rb', line 47 def name @name end |
#release_date ⇒ String
The date the album was first released.
51 52 53 |
# File 'lib/spotify_web_api/models/simplified_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/simplified_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/simplified_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/simplified_album_object.rb', line 18 def total_tracks @total_tracks end |
#type ⇒ Type2Enum
The object type.
63 64 65 |
# File 'lib/spotify_web_api/models/simplified_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/simplified_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.
129 130 131 132 133 134 135 136 137 138 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 129 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') restrictions = AlbumRestrictionObject.from_hash(hash['restrictions']) if hash['restrictions'] # Create object from extracted values. SimplifiedAlbumObject.new(album_type, total_tracks, available_markets, external_urls, href, id, images, name, release_date, release_date_precision, type, uri, artists, restrictions) end |
.names ⇒ Object
A mapping from model property names to API property names.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 76 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 end |
.nullables ⇒ Object
An array for nullable fields
103 104 105 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 103 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
96 97 98 99 100 |
# File 'lib/spotify_web_api/models/simplified_album_object.rb', line 96 def self.optionals %w[ restrictions ] end |