@@ -5,6 +5,7 @@ import com.adamratzman.spotify.main.SpotifyAPI
55import com.adamratzman.spotify.main.SpotifyRestAction
66import kotlinx.serialization.Optional
77import kotlinx.serialization.Serializable
8+ import kotlinx.serialization.Transient
89
910/* *
1011 * @param message the featured message in "Overview"
@@ -54,10 +55,10 @@ data class Followers(val href: String?, val total: Int)
5455
5556@Serializable
5657data class SpotifyUserInformation (
57- val birthdate : String? ,
58- val country : String? ,
59- val display_name : String? ,
60- val email : String? ,
58+ @Optional val birthdate : String? = null ,
59+ @Optional val country : String? = null ,
60+ @Optional val display_name : String? = null ,
61+ @Optional val email : String? = null ,
6162 val external_urls : HashMap <String , String >,
6263 val followers : Followers ,
6364 val href : String ,
@@ -70,9 +71,9 @@ data class SpotifyUserInformation(
7071
7172@Serializable
7273data class SpotifyPublicUser (
73- val display_name : String ,
74+ @Optional val display_name : String? = null ,
7475 val external_urls : HashMap <String , String >,
75- @Optional val followers : Followers = Followers (null,-1),
76+ @Optional val followers : Followers = Followers (null, -1),
7677 val href : String ,
7778 val id : String ,
7879 @Optional val images : List <SpotifyImage > = listOf(),
@@ -137,14 +138,14 @@ data class SimpleTrack(
137138 val external_urls : HashMap <String , String >,
138139 val href : String ,
139140 val id : String ,
140- @Optional val is_playable : Boolean = true ,
141+ @Optional val is_playable : Boolean = true ,
141142 private val linked_from : LinkedTrack ? ,
142143 val name : String ,
143144 val preview_url : String ,
144145 val track_number : Int ,
145146 val type : String ,
146147 val uri : String ,
147- val is_local : Boolean
148+ val is_local : Boolean
148149) : RelinkingAvailableResponse(linked_from) {
149150 fun toFullTrack (market : Market ? = null) = api.tracks.getTrack(id, market)
150151}
@@ -153,7 +154,7 @@ data class SimpleTrack(
153154data class Track (
154155 val album : SimpleAlbum ,
155156 val artists : List <SimpleArtist >,
156- @Optional val available_markets : List <String >? = null ,
157+ @Optional val available_markets : List <String >? = null ,
157158 @Optional val is_playable : Boolean = true ,
158159 val disc_number : Int ,
159160 val duration_ms : Int ,
@@ -162,14 +163,14 @@ data class Track(
162163 val external_urls : HashMap <String , String >,
163164 val href : String ,
164165 val id : String ,
165- @Optional private val linked_from : LinkedTrack ? = null ,
166+ @Optional private val linked_from : LinkedTrack ? = null ,
166167 val name : String ,
167168 val popularity : Int ,
168169 val preview_url : String ,
169170 val track_number : Int ,
170171 val type : String ,
171172 val uri : String ,
172- val is_local : Boolean
173+ val is_local : Boolean
173174) : RelinkingAvailableResponse(linked_from)
174175
175176@Serializable
@@ -186,11 +187,20 @@ data class SimpleAlbum(
186187 val uri : String ,
187188 val release_date : String ,
188189 val release_date_precision : String ,
189- val total_tracks : Int
190+ val total_tracks : Int ,
191+ @Optional private val album_group : String? = null
190192) : Linkable() {
193+ @Transient val albumGroup: AlbumGroup ? = album_group?.let { _ -> AlbumGroup .values().find { it.id == album_group } }
191194 fun toFullAlbum (market : Market ? = null) = api.albums.getAlbum(id, market)
192195}
193196
197+ enum class AlbumGroup (internal val id : String ) {
198+ ALBUM (" album" ),
199+ SINGLE (" single" ),
200+ COMPILATION (" compilation" ),
201+ APPEARS_ON (" appears_on" )
202+ }
203+
194204@Serializable
195205data class Album (
196206 val album_type : String ,
@@ -210,7 +220,8 @@ data class Album(
210220 val release_date_precision : String ,
211221 val tracks : PagingObject <SimpleTrack >,
212222 val type : String ,
213- val uri : String
223+ val uri : String ,
224+ val total_tracks : Int
214225)
215226
216227@Serializable
@@ -223,7 +234,7 @@ data class SimplePlaylist(
223234 val name : String ,
224235 val owner : SpotifyPublicUser ,
225236 @Optional val primary_color : String? = null ,
226- val public : Boolean? ,
237+ @Optional val public : Boolean? = null ,
227238 val snapshot_id : String ,
228239 val tracks : PlaylistTrackInfo ,
229240 val type : String ,
@@ -236,7 +247,17 @@ data class SimplePlaylist(
236247 * Some parameters are timestamps and will be updated soon to reflect Spotify's use of a Timestamp string
237248 */
238249@Serializable
239- data class PlaylistTrack (val added_at : String , val added_by : SpotifyPublicUser , val is_local : Boolean , val track : Track )
250+ data class PlaylistTrack (
251+ @Optional val primary_color : String? = null ,
252+ val added_at : String ,
253+ val added_by : SpotifyPublicUser ,
254+ val is_local : Boolean ,
255+ val track : Track ,
256+ @Optional val video_thumbnail : VideoThumbnail ? = null
257+ )
258+
259+ @Serializable
260+ data class VideoThumbnail (val url : String? )
240261
241262@Serializable
242263data class Playlist (
@@ -250,7 +271,7 @@ data class Playlist(
250271 val images : List <SpotifyImage >,
251272 val name : String ,
252273 val owner : SpotifyPublicUser ,
253- val public : Boolean? ,
274+ @Optional val public : Boolean? = null ,
254275 val snapshot_id : String ,
255276 val tracks : PagingObject <PlaylistTrack >,
256277 val type : String ,
@@ -270,10 +291,13 @@ data class AudioAnalysis(
270291 val tatums : List <AudioTatum >,
271292 val track : TrackAnalysis
272293)
294+
273295@Serializable
274296data class AudioBar (val start : Float , val duration : Float , val confidence : Float )
297+
275298@Serializable
276299data class AudioBeat (val start : Float , val duration : Float , val confidence : Float )
300+
277301@Serializable
278302data class AudioTatum (val start : Float , val duration : Float , val confidence : Float )
279303
@@ -312,7 +336,7 @@ data class AudioSegment(
312336 val loudness_start : Float ,
313337 val loudness_max_time : Float ,
314338 val loudness_max : Float ,
315- @Optional val loudness_end : Float? = null ,
339+ @Optional val loudness_end : Float? = null ,
316340 val pitches : List <Float >,
317341 val timbre : List <Float >
318342)
0 commit comments