From f028a66ee43e1c66c09050e04b85e09ff6b26547 Mon Sep 17 00:00:00 2001 From: Simon Mueller Date: Wed, 6 Nov 2024 17:50:26 +0100 Subject: [PATCH] Add SignatureResponse classes --- .../kotlin/at/asitplus/rqes/SignatureResponse.kt | 1 + .../rqes/serializers/SignatureResponseSerializer.kt | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/SignatureResponse.kt b/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/SignatureResponse.kt index 62e7ae29..d97a7a5b 100644 --- a/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/SignatureResponse.kt +++ b/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/SignatureResponse.kt @@ -16,6 +16,7 @@ sealed class SignatureResponse { val responseId: String?, ): SignatureResponse() + @Serializable data class SignDocResponse( @SerialName("DocumentWithSignature") val documentWithSignature: List?, diff --git a/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/serializers/SignatureResponseSerializer.kt b/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/serializers/SignatureResponseSerializer.kt index 60fb70a7..fb19f43a 100644 --- a/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/serializers/SignatureResponseSerializer.kt +++ b/rqes-data-classes/src/commonMain/kotlin/at/asitplus/rqes/serializers/SignatureResponseSerializer.kt @@ -1,16 +1,14 @@ package at.asitplus.rqes.serializers -import at.asitplus.dif.DifInputDescriptor -import at.asitplus.dif.InputDescriptor -import at.asitplus.rqes.QesInputDescriptor import at.asitplus.rqes.SignatureResponse +import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.json.JsonContentPolymorphicSerializer import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.jsonObject object SignatureResponseSerializer : JsonContentPolymorphicSerializer(SignatureResponse::class) { - override fun selectDeserializer(element: JsonElement) = when { - "DocumentWithSignature" in element.jsonObject || "SignatureObject" in element.jsonObject || "validationInfo" in element.jsonObject -> SignatureResponse.SignDocResponse.serializer() + override fun selectDeserializer(element: JsonElement): DeserializationStrategy = when { + "DocumentWithSignature" in element.jsonObject || "SignatureObject" in element.jsonObject || "validationInfo" in element.jsonObject -> SignatureResponse.SignDocResponse.serializer() as DeserializationStrategy else -> SignatureResponse.SignHashResponse.serializer() } } \ No newline at end of file