@@ -5,9 +5,10 @@ import com.adamratzman.spotify.SpotifyException
5
5
import kotlinx.serialization.Decoder
6
6
import kotlinx.serialization.Encoder
7
7
import kotlinx.serialization.KSerializer
8
+ import kotlinx.serialization.PrimitiveDescriptor
9
+ import kotlinx.serialization.PrimitiveKind
8
10
import kotlinx.serialization.SerialDescriptor
9
11
import kotlinx.serialization.Serializer
10
- import kotlinx.serialization.internal.StringDescriptor
11
12
import kotlinx.serialization.Serializable
12
13
13
14
/* *
@@ -36,9 +37,9 @@ private fun String.remove(type: String): String {
36
37
}
37
38
38
39
private class SimpleUriSerializer <T : SpotifyUri >(val ctor : (String ) -> T ) : KSerializer<T> {
39
- override val descriptor: SerialDescriptor = StringDescriptor
40
+ override val descriptor: SerialDescriptor = PrimitiveDescriptor ( " SimpleUri " , PrimitiveKind . STRING )
40
41
override fun deserialize (decoder : Decoder ): T = ctor(decoder.decodeString())
41
- override fun serialize (encoder : Encoder , obj : T ) = encoder.encodeString(obj .uri)
42
+ override fun serialize (encoder : Encoder , value : T ) = encoder.encodeString(value .uri)
42
43
}
43
44
44
45
@PublishedApi
@@ -83,9 +84,9 @@ sealed class SpotifyUri(input: String, type: String) {
83
84
84
85
@Serializer(forClass = SpotifyUri ::class )
85
86
companion object : KSerializer <SpotifyUri > {
86
- override val descriptor: SerialDescriptor = StringDescriptor
87
+ override val descriptor: SerialDescriptor = PrimitiveDescriptor ( " Uri " , PrimitiveKind . STRING )
87
88
override fun deserialize (decoder : Decoder ): SpotifyUri = SpotifyUri (decoder.decodeString())
88
- override fun serialize (encoder : Encoder , obj : SpotifyUri ) = encoder.encodeString(obj .uri)
89
+ override fun serialize (encoder : Encoder , value : SpotifyUri ) = encoder.encodeString(value .uri)
89
90
90
91
/* *
91
92
* This function safely instantiates a SpotifyUri from given constructor.
@@ -197,9 +198,9 @@ typealias PlaylistURI = PlaylistUri
197
198
sealed class TrackUri (input : String , type : String ) : SpotifyUri(input, type) {
198
199
@Serializer(forClass = TrackUri ::class )
199
200
companion object : KSerializer <TrackUri > {
200
- override val descriptor: SerialDescriptor = StringDescriptor
201
+ override val descriptor: SerialDescriptor = PrimitiveDescriptor ( " TrackUri " , PrimitiveKind . STRING )
201
202
override fun deserialize (decoder : Decoder ): TrackUri = TrackUri (decoder.decodeString())
202
- override fun serialize (encoder : Encoder , obj : TrackUri ) = encoder.encodeString(obj .uri)
203
+ override fun serialize (encoder : Encoder , value : TrackUri ) = encoder.encodeString(value .uri)
203
204
204
205
/* *
205
206
* Creates a abstract TrackURI of given input. Prefers SpotifyTrackUri if the input is ambiguous.
0 commit comments