commonMain.com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.UploadStickerFile.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TelegramBotAPI-js Show documentation
Show all versions of TelegramBotAPI-js Show documentation
Library for Object-Oriented and type-safe work with Telegram Bot API
package com.github.insanusmokrassar.TelegramBotAPI.requests.stickers
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.files.File
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.*
import kotlinx.serialization.json.JsonObject
@Serializable
data class UploadStickerFile(
@SerialName(userIdField)
val userId: UserId,
@Transient
val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized")
): MultipartRequest {
init {
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
}
override fun method(): String = "uploadStickerFile"
@Transient
override val mediaMap: Map = mapOf(pngStickerField to sticker)
@Transient
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
override val resultDeserializer: DeserializationStrategy
get() = File.serializer()
}