commonMain.com.xebia.functional.openai.generated.model.CreateTranslation200Response.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xef-openai-client Show documentation
Show all versions of xef-openai-client Show documentation
Building applications with LLMs through composability in Kotlin
The newest version!
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package com.xebia.functional.openai.generated.model
import com.xebia.functional.openai.generated.model.CreateTranslationResponseJson
import com.xebia.functional.openai.generated.model.CreateTranslationResponseVerboseJson
import com.xebia.functional.openai.generated.model.TranscriptionSegment
import com.xebia.functional.openai.attemptDeserialize
import kotlin.jvm.JvmInline
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
@Serializable(with = CreateTranslation200ResponseSerializer::class)
sealed interface CreateTranslation200Response {
@JvmInline
@Serializable
value class CaseCreateTranslationResponseJson(val value: CreateTranslationResponseJson): CreateTranslation200Response
@JvmInline
@Serializable
value class CaseCreateTranslationResponseVerboseJson(val value: CreateTranslationResponseVerboseJson): CreateTranslation200Response
}
object CreateTranslation200ResponseSerializer : KSerializer {
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("CreateTranslation200Response", PolymorphicKind.SEALED) {
element("1", CreateTranslationResponseJson.serializer().descriptor)
element("2", CreateTranslationResponseVerboseJson.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): CreateTranslation200Response {
val jsonSerde = Json { ignoreUnknownKeys = true }
val json = decoder.decodeSerializableValue(JsonElement.serializer())
return attemptDeserialize(json,
Pair(CreateTranslation200Response.CaseCreateTranslationResponseJson::class) {
CreateTranslation200Response.CaseCreateTranslationResponseJson(jsonSerde.decodeFromJsonElement(CreateTranslationResponseJson.serializer(), json))
},
Pair(CreateTranslation200Response.CaseCreateTranslationResponseVerboseJson::class) {
CreateTranslation200Response.CaseCreateTranslationResponseVerboseJson(jsonSerde.decodeFromJsonElement(CreateTranslationResponseVerboseJson.serializer(), json))
})
}
override fun serialize(encoder: Encoder, value: CreateTranslation200Response) =
when(value) {
is CreateTranslation200Response.CaseCreateTranslationResponseJson ->
encoder.encodeSerializableValue(CreateTranslationResponseJson.serializer(), value.value)
is CreateTranslation200Response.CaseCreateTranslationResponseVerboseJson ->
encoder.encodeSerializableValue(CreateTranslationResponseVerboseJson.serializer(), value.value)
}
}