mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-05 16:19:26 +00:00
add LocationAddress and StoryAreaPosition
This commit is contained in:
@@ -530,6 +530,12 @@ const val xShiftField = "x_shift"
|
|||||||
const val yShiftField = "y_shift"
|
const val yShiftField = "y_shift"
|
||||||
const val scaleField = "scale"
|
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 maxTipAmountField = "max_tip_amount"
|
||||||
const val suggestedTipAmountsField = "suggested_tip_amounts"
|
const val suggestedTipAmountsField = "suggested_tip_amounts"
|
||||||
const val chatTypeField = "chat_type"
|
const val chatTypeField = "chat_type"
|
||||||
@@ -572,6 +578,7 @@ const val totalCountField = "total_count"
|
|||||||
const val remainingCountField = "remaining_count"
|
const val remainingCountField = "remaining_count"
|
||||||
const val stateField = "state"
|
const val stateField = "state"
|
||||||
const val cityField = "city"
|
const val cityField = "city"
|
||||||
|
const val streetField = "street"
|
||||||
const val firstStreetLineField = "street_line1"
|
const val firstStreetLineField = "street_line1"
|
||||||
const val secondStreetLineField = "street_line2"
|
const val secondStreetLineField = "street_line2"
|
||||||
const val postCodeField = "post_code"
|
const val postCodeField = "post_code"
|
||||||
|
@@ -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,
|
||||||
|
)
|
@@ -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,
|
||||||
|
)
|
@@ -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<Percentage> {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user