mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-05 08:09:21 +00:00
refactor: merged GiftInfo and UniqueGiftInfo into one sealed interface
This commit is contained in:
@@ -10,45 +10,62 @@ import kotlin.jvm.JvmName
|
|||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GiftInfo private constructor(
|
sealed interface GiftInfo {
|
||||||
@SerialName(giftField)
|
val ownedGiftId: GiftId?
|
||||||
val gift: Gift,
|
|
||||||
@SerialName(ownedGiftIdField)
|
@Serializable
|
||||||
val ownedGiftId: GiftId? = null,
|
data class Regular(
|
||||||
@SerialName(convertStarCountField)
|
@SerialName(giftField)
|
||||||
val convertStarCount: Int? = null,
|
val gift: Gift,
|
||||||
@SerialName(prepaidUpgradeStarCountField)
|
@SerialName(ownedGiftIdField)
|
||||||
val prepaidUpgradeStarCount: Int? = null,
|
override val ownedGiftId: GiftId? = null,
|
||||||
@SerialName(canBeUpgradedField)
|
@SerialName(convertStarCountField)
|
||||||
val canBeUpgraded: Boolean = false,
|
val convertStarCount: Int? = null,
|
||||||
@SerialName(textField)
|
@SerialName(prepaidUpgradeStarCountField)
|
||||||
val text: String? = null,
|
val prepaidUpgradeStarCount: Int? = null,
|
||||||
@SerialName(entitiesField)
|
@SerialName(canBeUpgradedField)
|
||||||
val entities: RawMessageEntities = emptyList(),
|
val canBeUpgraded: Boolean = false,
|
||||||
@SerialName(isPrivateField)
|
@SerialName(textField)
|
||||||
val isPrivate: Boolean = false
|
val text: String? = null,
|
||||||
) {
|
@SerialName(entitiesField)
|
||||||
companion object {
|
val entities: RawMessageEntities = emptyList(),
|
||||||
@JvmName("PublicConstructor")
|
@SerialName(isPrivateField)
|
||||||
operator fun invoke(
|
val isPrivate: Boolean = false
|
||||||
gift: Gift,
|
) : GiftInfo {
|
||||||
ownedGiftId: GiftId? = null,
|
companion object {
|
||||||
convertStarCount: Int? = null,
|
@JvmName("PublicConstructor")
|
||||||
prepaidUpgradeStarCount: Int? = null,
|
operator fun invoke(
|
||||||
canBeUpgraded: Boolean = false,
|
gift: Gift,
|
||||||
text: String? = null,
|
ownedGiftId: GiftId? = null,
|
||||||
textSources: TextSourcesList = emptyList(),
|
convertStarCount: Int? = null,
|
||||||
position: Int,
|
prepaidUpgradeStarCount: Int? = null,
|
||||||
isPrivate: Boolean = false
|
canBeUpgraded: Boolean = false,
|
||||||
) = GiftInfo(
|
text: String? = null,
|
||||||
gift,
|
textSources: TextSourcesList = emptyList(),
|
||||||
ownedGiftId,
|
position: Int,
|
||||||
convertStarCount,
|
isPrivate: Boolean = false
|
||||||
prepaidUpgradeStarCount,
|
) = Regular(
|
||||||
canBeUpgraded,
|
gift,
|
||||||
text,
|
ownedGiftId,
|
||||||
textSources.toRawMessageEntities(position),
|
convertStarCount,
|
||||||
isPrivate
|
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
|
||||||
}
|
}
|
||||||
|
@@ -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
|
|
||||||
)
|
|
Reference in New Issue
Block a user