Skip to content

Commit 1941463

Browse files
committed
replace StringDescriptor with PrimitiveDescriptor
1 parent 60fbd7a commit 1941463

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/models/SpotifyUris.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import com.adamratzman.spotify.SpotifyException
55
import kotlinx.serialization.Decoder
66
import kotlinx.serialization.Encoder
77
import kotlinx.serialization.KSerializer
8+
import kotlinx.serialization.PrimitiveDescriptor
9+
import kotlinx.serialization.PrimitiveKind
810
import kotlinx.serialization.SerialDescriptor
911
import kotlinx.serialization.Serializer
10-
import kotlinx.serialization.internal.StringDescriptor
1112
import kotlinx.serialization.Serializable
1213

1314
/**
@@ -36,9 +37,9 @@ private fun String.remove(type: String): String {
3637
}
3738

3839
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)
4041
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)
4243
}
4344

4445
@PublishedApi
@@ -83,9 +84,9 @@ sealed class SpotifyUri(input: String, type: String) {
8384

8485
@Serializer(forClass = SpotifyUri::class)
8586
companion object : KSerializer<SpotifyUri> {
86-
override val descriptor: SerialDescriptor = StringDescriptor
87+
override val descriptor: SerialDescriptor = PrimitiveDescriptor("Uri", PrimitiveKind.STRING)
8788
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)
8990

9091
/**
9192
* This function safely instantiates a SpotifyUri from given constructor.
@@ -197,9 +198,9 @@ typealias PlaylistURI = PlaylistUri
197198
sealed class TrackUri(input: String, type: String) : SpotifyUri(input, type) {
198199
@Serializer(forClass = TrackUri::class)
199200
companion object : KSerializer<TrackUri> {
200-
override val descriptor: SerialDescriptor = StringDescriptor
201+
override val descriptor: SerialDescriptor = PrimitiveDescriptor("TrackUri", PrimitiveKind.STRING)
201202
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)
203204

204205
/**
205206
* Creates a abstract TrackURI of given input. Prefers SpotifyTrackUri if the input is ambiguous.

0 commit comments

Comments
 (0)