All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.UploadStickerFile.kt Maven / Gradle / Ivy

There is a newer version: 0.28.3
Show newest version
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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy