@@ -3,7 +3,6 @@ package com.adamratzman.spotify.models.serialization
3
3
4
4
import com.adamratzman.spotify.SpotifyAPI
5
5
import com.adamratzman.spotify.models.Album
6
- import com.adamratzman.spotify.models.AlbumURI
7
6
import com.adamratzman.spotify.models.FeaturedPlaylists
8
7
import com.adamratzman.spotify.models.Followers
9
8
import com.adamratzman.spotify.models.Playlist
@@ -21,21 +20,21 @@ internal fun getPublicUserConverter(api: SpotifyAPI) = object : Converter {
21
20
return jv.obj?.let { obj ->
22
21
if (obj.string(" id" )?.isNotBlank() == true ) {
23
22
SpotifyPublicUser (
24
- obj.string(" display_name" ),
25
23
obj.obj(" external_urls" )!! .map.mapValues { it.value as String },
26
- obj.obj(" followers" )?.let { api.klaxon.parseFromJsonObject<Followers >(it) }
27
- ? : Followers (null , - 1 ),
28
24
obj.string(" href" )!! ,
29
25
obj.string(" id" )!! ,
26
+ obj.string(" uri" )!! ,
27
+ obj.string(" display_name" ),
28
+ obj.obj(" followers" )?.let { api.klaxon.parseFromJsonObject<Followers >(it) }
29
+ ? : Followers (null , - 1 ),
30
30
obj.array(" images" ) ? : listOf (),
31
- obj.string(" type" )!! ,
32
- obj.string(" uri" )!!
33
- )
31
+ obj.string(" type" )!!
32
+ )
34
33
} else {
35
34
// this is the *Spotify* user, and is SOMEHOW broken
36
35
SpotifyPublicUser (
37
- externalUrls = hashMapOf(), href = " https://api.spotify.com/v1/users/spotify" ,
38
- id = " spotify" , type = " user" , _uri = " spotify:user:spotify"
36
+ _externalUrls = hashMapOf(), _href = " https://api.spotify.com/v1/users/spotify" ,
37
+ _id = " spotify" , type = " user" , _uri = " spotify:user:spotify"
39
38
)
40
39
}
41
40
}
@@ -70,14 +69,15 @@ internal fun getAlbumConverter(api: SpotifyAPI) = object : Converter {
70
69
return jv.obj?.let { obj ->
71
70
return Album (
72
71
obj.string(" album_type" )!! ,
73
- obj.array(" artists" )!! ,
74
72
obj.array(" available_markets" ) ? : listOf (),
75
- obj.array(" copyrights" )!! ,
76
- obj.obj(" external_ids" )!! .map.mapValues { it.value as String },
77
73
obj.obj(" external_urls" )!! .map.mapValues { it.value as String },
78
- obj.array( " genres " )!! ,
74
+ obj.obj( " external_ids " )!! .map.mapValues { it.value as String } ,
79
75
obj.string(" href" )!! ,
80
76
obj.string(" id" )!! ,
77
+ obj.string(" uri" )!! ,
78
+ obj.array(" artists" )!! ,
79
+ obj.array(" copyrights" )!! ,
80
+ obj.array(" genres" )!! ,
81
81
obj.array(" images" )!! ,
82
82
obj.string(" label" )!! ,
83
83
obj.string(" name" )!! ,
@@ -86,8 +86,6 @@ internal fun getAlbumConverter(api: SpotifyAPI) = object : Converter {
86
86
obj.string(" release_date_precision" )!! ,
87
87
obj.obj(" tracks" )!! .toJsonString().toPagingObject(endpoint = api.tracks),
88
88
obj.string(" type" )!! ,
89
- obj.string(" uri" )!! ,
90
- AlbumURI (obj.string(" uri" )!! ),
91
89
obj.int(" total_tracks" )!!
92
90
)
93
91
}
@@ -121,21 +119,21 @@ internal fun getPlaylistConverter(api: SpotifyAPI) = object : Converter {
121
119
override fun fromJson (jv : JsonValue ): Any? {
122
120
return jv.obj?.let { obj ->
123
121
return Playlist (
124
- obj.boolean(" collaborative" )!! ,
125
- obj.string(" description" )!! ,
126
122
obj.obj(" external_urls" )!! .map.mapValues { it.value as String },
127
- api.klaxon.parseFromJsonObject(obj.obj(" followers" )!! )!! ,
128
123
obj.string(" href" )!! ,
129
124
obj.string(" id" )!! ,
125
+ obj.string(" uri" )!! ,
126
+ obj.boolean(" collaborative" )!! ,
127
+ obj.string(" description" )!! ,
128
+ api.klaxon.parseFromJsonObject(obj.obj(" followers" )!! )!! ,
130
129
obj.string(" primary_color" ),
131
130
obj.array(" images" )!! ,
132
131
obj.string(" name" )!! ,
133
132
api.klaxon.parseFromJsonObject(obj.obj(" owner" )!! )!! ,
134
133
obj.boolean(" public" ),
135
134
obj.string(" snapshot_id" )!! ,
136
135
obj.obj(" tracks" )!! .toJsonString().toPagingObject(endpoint = api.tracks),
137
- obj.string(" type" )!! ,
138
- obj.string(" uri" )!!
136
+ obj.string(" type" )!!
139
137
)
140
138
}
141
139
}
0 commit comments