Class: SpotifyWebApi::SimplifiedPlaylistObject

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

Overview

SimplifiedPlaylistObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(collaborative = SKIP, description = SKIP, external_urls = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, owner = SKIP, public = SKIP, snapshot_id = SKIP, tracks = SKIP, type = SKIP, uri = SKIP) ⇒ SimplifiedPlaylistObject

Returns a new instance of SimplifiedPlaylistObject.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 121

def initialize(collaborative = SKIP, description = SKIP,
               external_urls = 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
  @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

#collaborativeTrueClass | FalseClass

‘true` if the owner allows other users to modify the playlist.

Returns:

  • (TrueClass | FalseClass)


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

def collaborative
  @collaborative
end

#descriptionString

The playlist description. _Only returned for modified, verified playlists, otherwise_ ‘null`.

Returns:

  • (String)


19
20
21
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 19

def description
  @description
end

#external_urlsExternalUrlObject

Known external URLs for this playlist.

Returns:



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

def external_urls
  @external_urls
end

#hrefString

A link to the Web API endpoint providing full details of the playlist.

Returns:

  • (String)


27
28
29
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 27

def href
  @href
end

#idString

The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.

Returns:

  • (String)


32
33
34
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 32

def id
  @id
end

#imagesArray[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._

Returns:



40
41
42
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 40

def images
  @images
end

#nameString

The name of the playlist.

Returns:

  • (String)


44
45
46
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 44

def name
  @name
end

#ownerPlaylistOwnerObject

The user who owns the playlist

Returns:



48
49
50
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 48

def owner
  @owner
end

#publicTrueClass | 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)

Returns:

  • (TrueClass | FalseClass)


55
56
57
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 55

def public
  @public
end

#snapshot_idString

The version identifier for the current playlist. Can be supplied in other requests to target a specific playlist version

Returns:

  • (String)


60
61
62
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 60

def snapshot_id
  @snapshot_id
end

#tracksPlaylistTracksRefObject

A collection containing a link ( ‘href` ) to the Web API endpoint where full details of the playlist’s tracks can be retrieved, along with the ‘total` number of tracks in the playlist. Note, a track object may be `null`. This can happen if a track is no longer available.



67
68
69
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 67

def tracks
  @tracks
end

#typeString

The object type: “playlist”

Returns:

  • (String)


71
72
73
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 71

def type
  @type
end

#uriString

The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the playlist.

Returns:

  • (String)


76
77
78
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 76

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 141

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']
  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 = PlaylistTracksRefObject.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.
  SimplifiedPlaylistObject.new(collaborative,
                               description,
                               external_urls,
                               href,
                               id,
                               images,
                               name,
                               owner,
                               public,
                               snapshot_id,
                               tracks,
                               type,
                               uri)
end

.namesObject

A mapping from model property names to API property names.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 79

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['collaborative'] = 'collaborative'
  @_hash['description'] = 'description'
  @_hash['external_urls'] = 'external_urls'
  @_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

.nullablesObject

An array for nullable fields



117
118
119
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 117

def self.nullables
  []
end

.optionalsObject

An array for optional fields



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/spotify_web_api/models/simplified_playlist_object.rb', line 98

def self.optionals
  %w[
    collaborative
    description
    external_urls
    href
    id
    images
    name
    owner
    public
    snapshot_id
    tracks
    type
    uri
  ]
end