From bdae774c6210d8b171140c372f7f630900fe622a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 10 Jan 2024 14:59:41 +0600 Subject: [PATCH] add EncodeDefault for required fields in LinkPreviewOptions --- .../dev/inmo/tgbotapi/types/LinkPreviewOptions.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt index 89b067ef93..c998468b48 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/LinkPreviewOptions.kt @@ -1,9 +1,6 @@ package dev.inmo.tgbotapi.types -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Required -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -19,6 +16,7 @@ sealed interface LinkPreviewOptions { @Serializable data object Disabled : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = true override val url: String? @@ -39,9 +37,11 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false @Required + @EncodeDefault @SerialName(preferLargeMediaField) override val preferLargeMedia: Boolean = true override val preferSmallMedia: Boolean @@ -56,9 +56,11 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false @Required + @EncodeDefault @SerialName(preferSmallMediaField) override val preferSmallMedia: Boolean = true override val preferLargeMedia: Boolean @@ -73,6 +75,7 @@ sealed interface LinkPreviewOptions { override val showAboveText: Boolean ) : LinkPreviewOptions { @Required + @EncodeDefault @SerialName(isDisabledField) override val isDisabled: Boolean = false override val preferSmallMedia: Boolean