@@ -3,6 +3,7 @@ package com.adamratzman.spotify.utils
33
44import com.adamratzman.spotify.main.SpotifyAPI
55import com.adamratzman.spotify.main.SpotifyRestAction
6+ import kotlinx.serialization.Optional
67import kotlinx.serialization.Serializable
78
89/* *
@@ -36,12 +37,17 @@ data class RecommendationSeed(
3637@Serializable
3738data class SpotifyCategory (val href : String , val icons : List <SpotifyImage >, val id : String , val name : String )
3839
40+ @Serializable
3941data class SpotifyCopyright (val text : String , val type : String )
4042
43+ @Serializable
4144data class PlaylistTrackInfo (val href : String , val total : Int )
4245
4346/* *
44- * @param href Will always be null, per the Spotify documentation, until the Web API is updated to support this.
47+ * @param href Will always be null, per the Spotify documentation,
48+ * until the Web API is updated to support this.
49+ *
50+ * @param total -1 if the user object does not contain followers, otherwise the amount of followers the user has
4551 */
4652@Serializable
4753data class Followers (val href : String? , val total : Int )
@@ -66,16 +72,16 @@ data class SpotifyUserInformation(
6672data class SpotifyPublicUser (
6773 val display_name : String ,
6874 val external_urls : HashMap <String , String >,
69- val followers : Followers ,
75+ @Optional val followers : Followers = Followers (null,-1) ,
7076 val href : String ,
7177 val id : String ,
72- val images : List <SpotifyImage >,
78+ @Optional val images : List <SpotifyImage > = listOf() ,
7379 val type : String ,
7480 val uri : String
7581)
7682
7783@Serializable
78- data class SpotifyImage (val height : Int , val url : String , val width : Int )
84+ data class SpotifyImage (val height : Int? , val url : String , val width : Int? )
7985
8086abstract class Linkable {
8187 @Transient
@@ -131,13 +137,14 @@ data class SimpleTrack(
131137 val external_urls : HashMap <String , String >,
132138 val href : String ,
133139 val id : String ,
134- val is_playable : Boolean? ,
140+ @Optional val is_playable : Boolean = true ,
135141 private val linked_from : LinkedTrack ? ,
136142 val name : String ,
137143 val preview_url : String ,
138144 val track_number : Int ,
139145 val type : String ,
140- val uri : String
146+ val uri : String ,
147+ val is_local : Boolean
141148) : RelinkingAvailableResponse(linked_from) {
142149 fun toFullTrack (market : Market ? = null) = api.tracks.getTrack(id, market)
143150}
@@ -146,36 +153,40 @@ data class SimpleTrack(
146153data class Track (
147154 val album : SimpleAlbum ,
148155 val artists : List <SimpleArtist >,
149- val available_markets : List <String >,
156+ @Optional val available_markets : List <String >? = null ,
157+ @Optional val is_playable : Boolean = true ,
150158 val disc_number : Int ,
151159 val duration_ms : Int ,
152160 val explicit : Boolean ,
153161 val external_ids : HashMap <String , String >,
154162 val external_urls : HashMap <String , String >,
155163 val href : String ,
156164 val id : String ,
157- val is_playable : Boolean? ,
158- private val linked_from : LinkedTrack ? ,
165+ @Optional private val linked_from : LinkedTrack ? =null ,
159166 val name : String ,
160167 val popularity : Int ,
161168 val preview_url : String ,
162169 val track_number : Int ,
163170 val type : String ,
164- val uri : String
171+ val uri : String ,
172+ val is_local : Boolean
165173) : RelinkingAvailableResponse(linked_from)
166174
167175@Serializable
168176data class SimpleAlbum (
169177 val album_type : String ,
170178 val artists : List <SimpleArtist >,
171- val available_markets : List <String >,
179+ @Optional val available_markets : List <String >? = null ,
172180 val external_urls : HashMap <String , String >,
173181 val href : String ,
174182 val id : String ,
175183 val images : List <SpotifyImage >,
176184 val name : String ,
177185 val type : String ,
178- val uri : String
186+ val uri : String ,
187+ val release_date : String ,
188+ val release_date_precision : String ,
189+ val total_tracks : Int
179190) : Linkable() {
180191 fun toFullAlbum (market : Market ? = null) = api.albums.getAlbum(id, market)
181192}
@@ -211,6 +222,7 @@ data class SimplePlaylist(
211222 val images : List <SpotifyImage >,
212223 val name : String ,
213224 val owner : SpotifyPublicUser ,
225+ @Optional val primary_color : String? = null ,
214226 val public : Boolean? ,
215227 val snapshot_id : String ,
216228 val tracks : PlaylistTrackInfo ,
@@ -234,6 +246,7 @@ data class Playlist(
234246 val followers : Followers ,
235247 val href : String ,
236248 val id : String ,
249+ @Optional val primary_color : String? = null ,
237250 val images : List <SpotifyImage >,
238251 val name : String ,
239252 val owner : SpotifyPublicUser ,
@@ -257,9 +270,11 @@ data class AudioAnalysis(
257270 val tatums : List <AudioTatum >,
258271 val track : TrackAnalysis
259272)
260-
273+ @Serializable
261274data class AudioBar (val start : Float , val duration : Float , val confidence : Float )
275+ @Serializable
262276data class AudioBeat (val start : Float , val duration : Float , val confidence : Float )
277+ @Serializable
263278data class AudioTatum (val start : Float , val duration : Float , val confidence : Float )
264279
265280@Serializable
@@ -297,7 +312,7 @@ data class AudioSegment(
297312 val loudness_start : Float ,
298313 val loudness_max_time : Float ,
299314 val loudness_max : Float ,
300- val loudness_end : Float ,
315+ @Optional val loudness_end : Float? = null ,
301316 val pitches : List <Float >,
302317 val timbre : List <Float >
303318)
@@ -327,9 +342,9 @@ data class TrackAnalysis(
327342 val echoprintstring : String ,
328343 val echoprint_version : Float ,
329344 val synchstring : String ,
330- val synch_version : Int ,
345+ val synch_version : Float ,
331346 val rhythmstring : String ,
332- val rhythm_version : Int
347+ val rhythm_version : Float
333348)
334349
335350@Serializable
@@ -382,6 +397,7 @@ data class CurrentlyPlayingContext(
382397 val context : Context
383398)
384399
400+ @Serializable
385401data class Context (val external_urls : HashMap <String , String >)
386402
387403@Serializable
@@ -393,6 +409,7 @@ data class CurrentlyPlayingObject(
393409 val item : Track
394410)
395411
412+ @Serializable
396413data class PlayHistoryContext (
397414 val type : String ,
398415 val href : String ,
0 commit comments