diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt index 9f413c1bc8..64a3966406 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/GiftInfo.kt @@ -10,45 +10,62 @@ import kotlin.jvm.JvmName @Serializable -data class GiftInfo private constructor( - @SerialName(giftField) - val gift: Gift, - @SerialName(ownedGiftIdField) - val ownedGiftId: GiftId? = null, - @SerialName(convertStarCountField) - val convertStarCount: Int? = null, - @SerialName(prepaidUpgradeStarCountField) - val prepaidUpgradeStarCount: Int? = null, - @SerialName(canBeUpgradedField) - val canBeUpgraded: Boolean = false, - @SerialName(textField) - val text: String? = null, - @SerialName(entitiesField) - val entities: RawMessageEntities = emptyList(), - @SerialName(isPrivateField) - val isPrivate: Boolean = false -) { - companion object { - @JvmName("PublicConstructor") - operator fun invoke( - gift: Gift, - ownedGiftId: GiftId? = null, - convertStarCount: Int? = null, - prepaidUpgradeStarCount: Int? = null, - canBeUpgraded: Boolean = false, - text: String? = null, - textSources: TextSourcesList = emptyList(), - position: Int, - isPrivate: Boolean = false - ) = GiftInfo( - gift, - ownedGiftId, - convertStarCount, - prepaidUpgradeStarCount, - canBeUpgraded, - text, - textSources.toRawMessageEntities(position), - isPrivate - ) +sealed interface GiftInfo { + val ownedGiftId: GiftId? + + @Serializable + data class Regular( + @SerialName(giftField) + val gift: Gift, + @SerialName(ownedGiftIdField) + override val ownedGiftId: GiftId? = null, + @SerialName(convertStarCountField) + val convertStarCount: Int? = null, + @SerialName(prepaidUpgradeStarCountField) + val prepaidUpgradeStarCount: Int? = null, + @SerialName(canBeUpgradedField) + val canBeUpgraded: Boolean = false, + @SerialName(textField) + val text: String? = null, + @SerialName(entitiesField) + val entities: RawMessageEntities = emptyList(), + @SerialName(isPrivateField) + val isPrivate: Boolean = false + ) : GiftInfo { + companion object { + @JvmName("PublicConstructor") + operator fun invoke( + gift: Gift, + ownedGiftId: GiftId? = null, + convertStarCount: Int? = null, + prepaidUpgradeStarCount: Int? = null, + canBeUpgraded: Boolean = false, + text: String? = null, + textSources: TextSourcesList = emptyList(), + position: Int, + isPrivate: Boolean = false + ) = Regular( + gift, + ownedGiftId, + convertStarCount, + prepaidUpgradeStarCount, + canBeUpgraded, + text, + textSources.toRawMessageEntities(position), + isPrivate + ) + } } + + @Serializable + data class Unique( + @SerialName(giftField) + val gift: UniqueGift, + @SerialName(originField) + val origin: String? = null, + @SerialName(ownedGiftIdField) + override val ownedGiftId: GiftId? = null, + @SerialName(transferStarCountField) + val transferStarCount: Int? = null + ): GiftInfo } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt deleted file mode 100644 index ae68159dd5..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/gifts/UniqueGiftInfo.kt +++ /dev/null @@ -1,17 +0,0 @@ -package dev.inmo.tgbotapi.types.gifts - -import dev.inmo.tgbotapi.types.* -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class UniqueGiftInfo( - @SerialName(giftField) - val gift: UniqueGift, - @SerialName(originField) - val origin: String? = null, - @SerialName(ownedGiftIdField) - val ownedGiftId: GiftId? = null, - @SerialName(transferStarCountField) - val transferStarCount: Int? = null -)