diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index c463ffe322..f6d2ca98d0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -530,6 +530,12 @@ const val xShiftField = "x_shift" const val yShiftField = "y_shift" const val scaleField = "scale" +const val xPercentageField = "x_percentage" +const val yPercentageField = "y_percentage" +const val widthPercentageField = "width_percentage" +const val heightPercentageField = "height_percentage" +const val cornerRadiusPercentageField = "corner_radius_percentage" + const val maxTipAmountField = "max_tip_amount" const val suggestedTipAmountsField = "suggested_tip_amounts" const val chatTypeField = "chat_type" @@ -572,6 +578,7 @@ const val totalCountField = "total_count" const val remainingCountField = "remaining_count" const val stateField = "state" const val cityField = "city" +const val streetField = "street" const val firstStreetLineField = "street_line1" const val secondStreetLineField = "street_line2" const val postCodeField = "post_code" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/LocationAddress.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/LocationAddress.kt new file mode 100644 index 0000000000..5a1e5d01e3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/location/LocationAddress.kt @@ -0,0 +1,17 @@ +package dev.inmo.tgbotapi.types.location + +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class LocationAddress( + @SerialName(countryCodeField) + val countryCode: String, + @SerialName(stateField) + val state: String, + @SerialName(cityField) + val city: String, + @SerialName(streetField) + val street: String, +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/StoryAreaPosition.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/StoryAreaPosition.kt new file mode 100644 index 0000000000..8dab4f74e6 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/StoryAreaPosition.kt @@ -0,0 +1,28 @@ +package dev.inmo.tgbotapi.types.stories + +import dev.inmo.micro_utils.common.Percentage +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.Percentage0_100Serializer +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class StoryAreaPosition( + @Serializable(Percentage0_100Serializer::class) + @SerialName(xPercentageField) + val x: Percentage, + @Serializable(Percentage0_100Serializer::class) + @SerialName(yPercentageField) + val y: Percentage, + @Serializable(Percentage0_100Serializer::class) + @SerialName(widthPercentageField) + val width: Percentage, + @Serializable(Percentage0_100Serializer::class) + @SerialName(heightPercentageField) + val height: Percentage, + @SerialName(rotationAngleField) + val rotationAngle: Double, + @Serializable(Percentage0_100Serializer::class) + @SerialName(cornerRadiusPercentageField) + val cornerRadius: Percentage, +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Percentage0_100Serializer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Percentage0_100Serializer.kt new file mode 100644 index 0000000000..c1ea811c14 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Percentage0_100Serializer.kt @@ -0,0 +1,23 @@ +package dev.inmo.tgbotapi.utils + +import dev.inmo.micro_utils.common.Percentage +import kotlinx.serialization.KSerializer +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +object Percentage0_100Serializer : KSerializer { + override val descriptor: SerialDescriptor + get() = Double.serializer().descriptor + + override fun deserialize(decoder: Decoder): Percentage { + return decoder.decodeDouble().let(Percentage::of100) + } + + override fun serialize(encoder: Encoder, value: Percentage) { + encoder.encodeDouble(value.of100) + } + +} \ No newline at end of file