From b53fb8da36cc91c1aad83a6f7582ccea8b15c9be Mon Sep 17 00:00:00 2001 From: bpavuk <75901693+bpavuk@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:42:28 +0300 Subject: [PATCH] feat: added constructor to GiftInfo --- .../dev/inmo/tgbotapi/types/gifts/GiftInfo.kt | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) 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 d85df96526..03f37347f4 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 @@ -2,25 +2,45 @@ package dev.inmo.tgbotapi.types.gifts import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.message.RawMessageEntities +import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList +import dev.inmo.tgbotapi.types.message.toRawMessageEntities import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +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, - @SerialName(isPrivateField) - val isPrivate: Boolean = false -) + @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, + @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 + ) + } +}