1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
use super::utils::unix_date_formatting; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; /// Contains information about Telegram Passport data shared with the bot by the /// user. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct PassportData { /// Vec with information about documents and other Telegram Passport /// elements that was shared with the bot pub data: Vec<EncryptedCredentials>, /// Encrypted credentials required to decrypt the data pub credentials: EncryptedCredentials, } /// This object represents a file uploaded to Telegram Passport. /// Currently all Telegram Passport files are in JPEG format when decrypted and /// don't exceed 10MB. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct PassportFile { /// Identifier for this file, which can be used to download or reuse the /// file pub file_id: String, /// Unique identifier for this file, which is supposed to be the same over /// time and for different bots. Can't be used to download or reuse the /// file. pub file_unique_id: String, /// File size pub file_size: i64, /// Unix time when the file was uploaded #[serde(with = "unix_date_formatting")] pub file_date: DateTime<Utc>, } /// Contains information about documents or other Telegram Passport elements /// shared with the bot by the user. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct EncryptedPassportElement { /// Element type. pub element_type: TelegramPassportElement, /// Base64-encoded encrypted Telegram Passport element data provided by the /// user, available for “personal_details”, “passport”, /// “driver_license”, “identity_card”, “internal_passport” and “address” /// types. Can be decrypted and verified using the accompanying /// [EncryptedCredentials]. pub data: Option<String>, /// User's verified phone number, available only for “phone_number” type pub phone_number: Option<String>, /// Array of encrypted files with documents provided by the user, available /// for “utility_bill”, “bank_statement”, “rental_agreement”, /// “passport_registration” and “temporary_registration” types. /// Files can be decrypted and verified using the accompanying /// [EncryptedCredentials]. pub files: Vec<PassportFile>, /// Encrypted file with the front side of the document, provided by the /// user. Available for “passport”, “driver_license”, “identity_card” /// and “internal_passport”. The file can be decrypted and verified /// using the accompanying [EncryptedCredentials]. pub front_side: PassportFile, /// Encrypted file with the reverse side of the document, provided by the /// user. Available for “driver_license” and “identity_card”. /// The file can be decrypted and verified using the accompanying /// [EncryptedCredentials]. pub reverse_side: PassportFile, /// Encrypted file with the selfie of the user holding a document, provided /// by the user; available for “passport”, “driver_license”, /// “identity_card” and “internal_passport”. The file can be decrypted /// and verified using the accompanying [EncryptedCredentials]. pub selfie: PassportFile, /// Array of encrypted files with translated versions of documents provided /// by the user. Available if requested for “passport”, /// “driver_license”, “identity_card”, “internal_passport”, /// "utility_bill”, “bank_statement”, “rental_agreement”, /// “passport_registration” and “temporary_registration” types. /// Files can be decrypted and verified using the accompanying /// [EncryptedCredentials]. pub translation: Vec<PassportFile>, /// Base64-encoded element hash for using in /// [PassportElementErrorUnspecified] /// /// [PassportElementErrorUnspecified]: /// ../api/types/struct.PassportElementErrorUnspecified.html pub hash: String, } /// Contains data required for decrypting and authenticating /// [`EncryptedPassportElement`]. See the [Telegram Passport Documentation](https://core.telegram.org/passport#receiving-information) /// for a complete description of the data decryption and authentication /// processes. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct EncryptedCredentials { /// Base64-encoded encrypted JSON-serialized data with unique user's /// payload, data hashes and secrets required for /// [EncryptedPassportElement] decryption and authentication pub data: String, /// Base64-encoded data hash for data authentication pub hash: String, /// Base64-encoded secret, encrypted with the bot's public RSA key, required /// for data decryption pub secret: String, } /// The type of a telegram passport element #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub enum TelegramPassportElement { #[serde(rename = "personal_details")] PersonalDetails, #[serde(rename = "passport")] Passport, #[serde(rename = "driver_license")] DriverLicense, #[serde(rename = "identity_card")] IdentityCard, #[serde(rename = "internal_passport")] InternalPassport, #[serde(rename = "address")] Address, #[serde(rename = "utility_bill")] UtilityBill, #[serde(rename = "bank_statement")] BankStatement, #[serde(rename = "rental_agreement")] RentalAgreement, #[serde(rename = "passport_registration")] PassportRegistration, #[serde(rename = "temporary_registration")] TemporaryRegistration, #[serde(rename = "phone_number")] PhoneNumber, #[serde(rename = "email")] Email, }