mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-01-09 09:19:55 +00:00
add upgrade_star_count to Gift and fix serialization of gift
This commit is contained in:
parent
840c6b02a4
commit
9952b6c6ae
@ -654,6 +654,7 @@ const val giveawayMessageField = "giveaway_message"
|
|||||||
const val wasRefundedField = "was_refunded"
|
const val wasRefundedField = "was_refunded"
|
||||||
const val isManualField = "is_manual"
|
const val isManualField = "is_manual"
|
||||||
const val starCountField = "star_count"
|
const val starCountField = "star_count"
|
||||||
|
const val upgradeStarCountField = "upgrade_star_count"
|
||||||
const val paidMediaField = "paid_media"
|
const val paidMediaField = "paid_media"
|
||||||
|
|
||||||
const val businessConnectionIdField = "business_connection_id"
|
const val businessConnectionIdField = "business_connection_id"
|
||||||
|
@ -15,6 +15,7 @@ sealed interface Gift {
|
|||||||
val sticker: Sticker
|
val sticker: Sticker
|
||||||
val starCount: Int
|
val starCount: Int
|
||||||
val totalCount: Int?
|
val totalCount: Int?
|
||||||
|
val upgradeStarCount: Int?
|
||||||
val remainingCount: Int?
|
val remainingCount: Int?
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -24,7 +25,9 @@ sealed interface Gift {
|
|||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
override val sticker: Sticker,
|
override val sticker: Sticker,
|
||||||
@SerialName(starCountField)
|
@SerialName(starCountField)
|
||||||
override val starCount: Int
|
override val starCount: Int,
|
||||||
|
@SerialName(upgradeStarCountField)
|
||||||
|
override val upgradeStarCount: Int? = null
|
||||||
) : Gift {
|
) : Gift {
|
||||||
override val totalCount: Int?
|
override val totalCount: Int?
|
||||||
get() = null
|
get() = null
|
||||||
@ -44,6 +47,8 @@ sealed interface Gift {
|
|||||||
override val totalCount: Int,
|
override val totalCount: Int,
|
||||||
@SerialName(remainingCountField)
|
@SerialName(remainingCountField)
|
||||||
override val remainingCount: Int,
|
override val remainingCount: Int,
|
||||||
|
@SerialName(upgradeStarCountField)
|
||||||
|
override val upgradeStarCount: Int? = null,
|
||||||
) : Gift
|
) : Gift
|
||||||
|
|
||||||
companion object : KSerializer<Gift> {
|
companion object : KSerializer<Gift> {
|
||||||
@ -54,6 +59,7 @@ sealed interface Gift {
|
|||||||
val star_count: Int,
|
val star_count: Int,
|
||||||
val total_count: Int? = null,
|
val total_count: Int? = null,
|
||||||
val remaining_count: Int? = null,
|
val remaining_count: Int? = null,
|
||||||
|
val upgrade_star_count: Int? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
override val descriptor: SerialDescriptor
|
override val descriptor: SerialDescriptor
|
||||||
@ -64,29 +70,33 @@ sealed interface Gift {
|
|||||||
|
|
||||||
return if (surrogate.total_count != null && surrogate.remaining_count != null) {
|
return if (surrogate.total_count != null && surrogate.remaining_count != null) {
|
||||||
Limited(
|
Limited(
|
||||||
surrogate.id,
|
id = surrogate.id,
|
||||||
surrogate.sticker,
|
sticker = surrogate.sticker,
|
||||||
surrogate.star_count,
|
starCount = surrogate.star_count,
|
||||||
surrogate.total_count,
|
totalCount = surrogate.total_count,
|
||||||
surrogate.remaining_count
|
remainingCount = surrogate.remaining_count,
|
||||||
|
upgradeStarCount = surrogate.upgrade_star_count,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Unlimited(
|
Unlimited(
|
||||||
surrogate.id,
|
id = surrogate.id,
|
||||||
surrogate.sticker,
|
sticker = surrogate.sticker,
|
||||||
surrogate.star_count,
|
starCount = surrogate.star_count,
|
||||||
|
upgradeStarCount = surrogate.upgrade_star_count,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: Gift) {
|
override fun serialize(encoder: Encoder, value: Gift) {
|
||||||
val surrogate = GiftSurrogate(
|
val surrogate = GiftSurrogate(
|
||||||
value.id,
|
id = value.id,
|
||||||
value.sticker,
|
sticker = value.sticker,
|
||||||
value.starCount,
|
star_count = value.starCount,
|
||||||
value.totalCount,
|
total_count = value.totalCount,
|
||||||
value.remainingCount
|
remaining_count = value.remainingCount,
|
||||||
|
upgrade_star_count = value.upgradeStarCount
|
||||||
)
|
)
|
||||||
|
GiftSurrogate.serializer().serialize(encoder, surrogate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user