1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 12:08:43 +00:00

update passport data to use Base64StringSerializer

This commit is contained in:
InsanusMokrassar 2021-01-15 16:02:16 +06:00
parent ef22735894
commit 5d87b86afe
10 changed files with 56 additions and 34 deletions

View File

@ -1,20 +1,23 @@
package dev.inmo.tgbotapi.types.passport
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
typealias Base64EncodedData = String
typealias EncryptedAndBase64EncodedData = String
typealias EncryptedByBotRSAAndBase64EncodedData = String
typealias EncryptedByBotPublicKeyData = String
typealias EncryptedData = String
@Serializable
data class EncryptedCredentials(
@SerialName(dataField)
val data: EncryptedAndBase64EncodedData,
@Serializable(Base64StringSerializer::class)
val data: EncryptedData,
@SerialName(hashField)
val hash: Base64EncodedData,
@Serializable(Base64StringSerializer::class)
val hash: String,
@SerialName(secretField)
val secret: EncryptedByBotRSAAndBase64EncodedData
@Serializable(Base64StringSerializer::class)
val secret: EncryptedByBotPublicKeyData
)

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithEmail
@ -11,6 +12,7 @@ data class Email(
@SerialName(emailField)
override val email: String,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : WithEmail {
}

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.dataField
import dev.inmo.tgbotapi.types.hashField
import dev.inmo.tgbotapi.types.passport.*
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
import kotlinx.serialization.SerialName
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
data class EncryptedAddress(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
@SerialName(hashField)
override val hash: Base64EncodedData
override val data: EncryptedData,
@Serializable(Base64StringSerializer::class)
override val hash: String
) : WithData

View File

@ -1,9 +1,8 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.dataField
import dev.inmo.tgbotapi.types.hashField
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.EncryptedAndBase64EncodedData
import dev.inmo.tgbotapi.types.passport.*
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -11,7 +10,8 @@ import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
data class EncryptedPersonalDetails(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val data: EncryptedData,
@Serializable(Base64StringSerializer::class)
override val hash: String
) : WithData

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.*
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
@ -12,7 +13,7 @@ sealed class Passport : WithData, WithFrontSide, WithSelfie, Translatable
@Serializable(EncryptedElementSerializer::class)
data class CommonPassport(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
override val data: EncryptedData,
@SerialName(frontSideField)
override val frontSide: PassportFile?,
@SerialName(selfieField)
@ -20,12 +21,13 @@ data class CommonPassport(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : Passport()
@Serializable(EncryptedElementSerializer::class)
data class InternalPassport(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
override val data: EncryptedData,
@SerialName(frontSideField)
override val frontSide: PassportFile?,
@SerialName(selfieField)
@ -33,5 +35,6 @@ data class InternalPassport(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : Passport()

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.hashField
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithPhoneNumber
@ -12,6 +13,7 @@ data class PhoneNumber(
@SerialName(phoneNumberField)
override val phoneNumber: String,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : WithPhoneNumber {
}

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.FilesCollection
@ -17,7 +18,8 @@ data class UtilityBill(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableFilesCollection()
@Serializable(EncryptedElementSerializer::class)
data class BankStatement(
@ -26,7 +28,8 @@ data class BankStatement(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableFilesCollection()
@Serializable(EncryptedElementSerializer::class)
data class RentalAgreement(
@ -35,7 +38,8 @@ data class RentalAgreement(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableFilesCollection()
@Serializable(EncryptedElementSerializer::class)
data class PassportRegistration(
@ -44,7 +48,8 @@ data class PassportRegistration(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableFilesCollection()
@Serializable(EncryptedElementSerializer::class)
data class TemporaryRegistration(
@ -53,6 +58,7 @@ data class TemporaryRegistration(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableFilesCollection()

View File

@ -1,8 +1,9 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.EncryptedAndBase64EncodedData
import dev.inmo.tgbotapi.types.passport.EncryptedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@ -13,7 +14,7 @@ sealed class TranslatableIDDocument : WithData, WithFrontSide, WithReverseSide,
@Serializable(EncryptedElementSerializer::class)
data class DriverLicense(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
override val data: EncryptedData,
@SerialName(frontSideField)
override val frontSide: PassportFile?,
@SerialName(reverseSideField)
@ -23,13 +24,14 @@ data class DriverLicense(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableIDDocument()
@Serializable(EncryptedElementSerializer::class)
data class IdentityCard(
@SerialName(dataField)
override val data: EncryptedAndBase64EncodedData,
override val data: EncryptedData,
@SerialName(frontSideField)
override val frontSide: PassportFile?,
@SerialName(reverseSideField)
@ -39,5 +41,6 @@ data class IdentityCard(
@SerialName(translationField)
override val translations: List<PassportFile>,
@SerialName(hashField)
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : TranslatableIDDocument()

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
import dev.inmo.tgbotapi.types.passport.Base64EncodedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
import kotlinx.serialization.Serializable
@ -7,11 +8,12 @@ import kotlinx.serialization.json.JsonObject
@Serializable(EncryptedElementSerializer::class)
interface EncryptedPassportElement {
val hash: Base64EncodedData
val hash: String
}
@Serializable(EncryptedElementSerializer::class)
data class UnknownEncryptedPassportElement(
val rawJson: JsonObject,
override val hash: Base64EncodedData
@Serializable(Base64StringSerializer::class)
override val hash: String
) : EncryptedPassportElement

View File

@ -1,10 +1,11 @@
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
import dev.inmo.tgbotapi.types.passport.EncryptedAndBase64EncodedData
import dev.inmo.tgbotapi.types.passport.EncryptedData
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
import kotlinx.serialization.Serializable
@Serializable(EncryptedElementSerializer::class)
interface WithData : EncryptedPassportElement {
val data: EncryptedAndBase64EncodedData
val data: EncryptedData
}