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`
* `ForwardedFromChannelMessage` -> `ForwardFromChannelInfo`
* `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:
<details>

View File

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

View File

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

View File

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

View File

@ -15,4 +15,4 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
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
@Serializer(InlineQueryResult::class)
object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString())
override fun serialize(encoder: Encoder, obj: InlineQueryResult) {
when(obj) {

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
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")
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {

View File

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

View File

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

View File

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

View File

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

View File

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