All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.model.MessageObjectAttachmentsInnerToolsInner.kt Maven / Gradle / Ivy

There is a newer version: 0.0.5-alpha.119
Show 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.AssistantToolsCode
import com.xebia.functional.openai.generated.model.AssistantToolsFileSearchTypeOnly
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 = MessageObjectAttachmentsInnerToolsInnerSerializer::class)
sealed interface MessageObjectAttachmentsInnerToolsInner {

  @JvmInline
  @Serializable
  value class CaseAssistantToolsCode(val value: AssistantToolsCode): MessageObjectAttachmentsInnerToolsInner
  @JvmInline
  @Serializable
  value class CaseAssistantToolsFileSearchTypeOnly(val value: AssistantToolsFileSearchTypeOnly): MessageObjectAttachmentsInnerToolsInner

}

object MessageObjectAttachmentsInnerToolsInnerSerializer : KSerializer {
    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
    override val descriptor: SerialDescriptor = buildSerialDescriptor("MessageObjectAttachmentsInnerToolsInner", PolymorphicKind.SEALED) { 
      element("1", AssistantToolsCode.serializer().descriptor)
      element("2", AssistantToolsFileSearchTypeOnly.serializer().descriptor)
    }

    override fun deserialize(decoder: Decoder): MessageObjectAttachmentsInnerToolsInner {
      val jsonSerde = Json { ignoreUnknownKeys = true }
      val json = decoder.decodeSerializableValue(JsonElement.serializer())
      return attemptDeserialize(json, 
        Pair(MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsCode::class) {
          MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsCode(jsonSerde.decodeFromJsonElement(AssistantToolsCode.serializer(), json))
      },
        Pair(MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsFileSearchTypeOnly::class) {
          MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsFileSearchTypeOnly(jsonSerde.decodeFromJsonElement(AssistantToolsFileSearchTypeOnly.serializer(), json))
      })
    }

    override fun serialize(encoder: Encoder, value: MessageObjectAttachmentsInnerToolsInner) =
      when(value) { 
        is MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsCode ->
        encoder.encodeSerializableValue(AssistantToolsCode.serializer(), value.value)

        is MessageObjectAttachmentsInnerToolsInner.CaseAssistantToolsFileSearchTypeOnly ->
        encoder.encodeSerializableValue(AssistantToolsFileSearchTypeOnly.serializer(), value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy