-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47a8739
commit e02f74d
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/stars/PaidMedia.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package dev.inmo.tgbotapi.types.payments.stars | ||
|
||
import dev.inmo.tgbotapi.types.* | ||
import dev.inmo.tgbotapi.types.files.PhotoSize | ||
import kotlinx.serialization.EncodeDefault | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
|
||
sealed interface PaidMedia { | ||
val type: String | ||
|
||
@Serializable | ||
data class Preview( | ||
@SerialName(widthField) | ||
val width: Int? = null, | ||
@SerialName(heightField) | ||
val height: Int? = null, | ||
@SerialName(durationField) | ||
val duration: Int? = null | ||
) : PaidMedia { | ||
@EncodeDefault | ||
@SerialName(typeField) | ||
override val type: String = Companion.type | ||
|
||
companion object { | ||
val type: String = "preview" | ||
} | ||
} | ||
|
||
@Serializable | ||
data class Photo( | ||
@SerialName(photoField) | ||
val photo: Photo | ||
) : PaidMedia { | ||
@EncodeDefault | ||
@SerialName(typeField) | ||
override val type: String = Companion.type | ||
|
||
companion object { | ||
val type: String = "photo" | ||
} | ||
} | ||
|
||
@Serializable | ||
data class Video( | ||
@SerialName(videoField) | ||
val video: Video | ||
) : PaidMedia { | ||
@EncodeDefault | ||
@SerialName(typeField) | ||
override val type: String = Companion.type | ||
|
||
companion object { | ||
val type: String = "video" | ||
} | ||
} | ||
|
||
@Serializable | ||
data class Video( | ||
@SerialName(videoField) | ||
val video: Video | ||
) : PaidMedia { | ||
@EncodeDefault | ||
@SerialName(typeField) | ||
override val type: String = Companion.type | ||
|
||
companion object { | ||
val type: String = "video" | ||
} | ||
} | ||
|
||
companion object : KSerializer<PaidMedia> { | ||
@Serializable | ||
private class Surrogate( | ||
@SerialName(typeField) | ||
val type: String, | ||
@SerialName(widthField) | ||
val width: Int? = null, | ||
@SerialName(heightField) | ||
val height: Int? = null, | ||
@SerialName(durationField) | ||
val duration: Int? = null, | ||
@SerialName(photoField) | ||
val photo: Photo? = null, | ||
@SerialName(videoField) | ||
val video: Video? = null | ||
) | ||
|
||
override val descriptor: SerialDescriptor | ||
get() = TODO("Not yet implemented") | ||
|
||
override fun deserialize(decoder: Decoder): PaidMedia { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun serialize(encoder: Encoder, value: PaidMedia) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} | ||
} |