1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

make all serializers are internal

This commit is contained in:
InsanusMokrassar 2020-01-15 13:03:42 +06:00
parent 3fe7bd1382
commit 12496f8261
16 changed files with 18 additions and 16 deletions

View File

@ -14,6 +14,8 @@
* `UserForwardedMessage` -> `UserForwardInfo` * `UserForwardedMessage` -> `UserForwardInfo`
* `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo` * `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo`
* `PossiblyForwardedMessage#forwarded` field now renamed to `forwardInfo` * `PossiblyForwardedMessage#forwarded` field now renamed to `forwardInfo`
* All serializers in library now are `internal`. **If you have used some of them or I have marked as internal by a
mistake - don't hesitate to say this.**
* Most part of requests have changed return type. They are listed below: * Most part of requests have changed return type. They are listed below:
<details> <details>

View File

@ -21,7 +21,7 @@ data class FileId(
fun String.toInputFile(): InputFile = FileId(this) fun String.toInputFile(): InputFile = FileId(this)
@Serializer(InputFile::class) @Serializer(InputFile::class)
object InputFileSerializer : KSerializer<InputFile> { internal object InputFileSerializer : KSerializer<InputFile> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString())
override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId) override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId)
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())

View File

@ -51,6 +51,6 @@ fun InlineQuery.createAnswer(
switchPmParameter switchPmParameter
) )
object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer( internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
InlineQueryResultSerializer InlineQueryResultSerializer
) )

View File

@ -21,7 +21,7 @@ data class AnswerShippingQueryOk(
get() = serializer() get() = serializer()
} }
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer( internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
ShippingOption.serializer() ShippingOption.serializer()
) )

View File

@ -15,4 +15,4 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
get() = GameHighScoresSerializer get() = GameHighScoresSerializer
} }
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer()) internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())

View File

@ -6,7 +6,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
@Serializer(InlineQueryResult::class) @Serializer(InlineQueryResult::class)
object InlineQueryResultSerializer : KSerializer<InlineQueryResult> { internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString())
override fun serialize(encoder: Encoder, obj: InlineQueryResult) { override fun serialize(encoder: Encoder, obj: InlineQueryResult) {
when(obj) { when(obj) {

View File

@ -6,7 +6,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
@Serializer(InputMessageContent::class) @Serializer(InputMessageContent::class)
object InputMessageContentSerializer : KSerializer<InputMessageContent> { internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString())
override fun serialize(encoder: Encoder, obj: InputMessageContent) { override fun serialize(encoder: Encoder, obj: InputMessageContent) {
when (obj) { when (obj) {

View File

@ -4,7 +4,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
@Serializer(InputMedia::class) @Serializer(InputMedia::class)
object InputMediaSerializer : KSerializer<InputMedia> { internal object InputMediaSerializer : KSerializer<InputMedia> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString())
override fun serialize(encoder: Encoder, obj: InputMedia) { override fun serialize(encoder: Encoder, obj: InputMedia) {
when (obj) { when (obj) {

View File

@ -4,7 +4,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
@Serializer(MediaGroupMemberInputMedia::class) @Serializer(MediaGroupMemberInputMedia::class)
object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> { internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString())
override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) { override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) {
when (obj) { when (obj) {

View File

@ -13,6 +13,6 @@ data class UserProfilePhotos (
val photos: List<Photo> val photos: List<Photo>
) )
object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ArrayListSerializer( internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ArrayListSerializer(
PhotoSerializer PhotoSerializer
) )

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
import kotlinx.serialization.json.* import kotlinx.serialization.json.*
object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> { internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton") override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton")
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> { private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {

View File

@ -4,7 +4,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor import kotlinx.serialization.internal.StringDescriptor
@Serializer(KeyboardMarkup::class) @Serializer(KeyboardMarkup::class)
object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> { internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString()) override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString())
override fun serialize(encoder: Encoder, obj: KeyboardMarkup) { override fun serialize(encoder: Encoder, obj: KeyboardMarkup) {
when(obj) { when(obj) {

View File

@ -11,7 +11,7 @@ import kotlinx.serialization.json.JsonObjectSerializer
private val formatter = Json.nonstrict private val formatter = Json.nonstrict
object PreviewChatSerializer : KSerializer<Chat> { internal object PreviewChatSerializer : KSerializer<Chat> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer") override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
override fun deserialize(decoder: Decoder): Chat { override fun deserialize(decoder: Decoder): Chat {
@ -39,7 +39,7 @@ object PreviewChatSerializer : KSerializer<Chat> {
} }
} }
object ExtendedChatSerializer : KSerializer<ExtendedChat> { internal object ExtendedChatSerializer : KSerializer<ExtendedChat> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer") override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
override fun deserialize(decoder: Decoder): ExtendedChat { override fun deserialize(decoder: Decoder): ExtendedChat {

View File

@ -13,7 +13,7 @@ fun Photo.biggest(): PhotoSize? = maxBy {
it.resolution it.resolution
} }
object PhotoSerializer : KSerializer<Photo> by ArrayListSerializer( internal object PhotoSerializer : KSerializer<Photo> by ArrayListSerializer(
PhotoSize.serializer() PhotoSize.serializer()
) )

View File

@ -16,6 +16,6 @@ data class ShippingOption(
override val prices: List<LabeledPrice> override val prices: List<LabeledPrice>
) : Priced ) : Priced
object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ArrayListSerializer( internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ArrayListSerializer(
LabeledPrice.serializer() LabeledPrice.serializer()
) )

View File

@ -19,7 +19,7 @@ data class AnonymousPollOption (
override val votes: Int override val votes: Int
) : PollOption() ) : PollOption()
object PollOptionSerializer : KSerializer<PollOption> { internal object PollOptionSerializer : KSerializer<PollOption> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption") override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize( override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize(