telegram_bot2/models/passport.rs
1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Clone, Debug)]
4#[serde(rename_all = "snake_case", tag = "source")]
5/// This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user
6pub enum PassportElementError {
7 /// Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
8 Data {
9 /// The section of the user's Telegram Passport which has the error
10 #[serde(rename = "type")]
11 _type: DataErrorType,
12 /// Name of the data field which has the error
13 field_name: String,
14 /// Base64-encoded data hash
15 data_hash: String,
16 /// Error message
17 message: String,
18 },
19
20 /// Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
21 FrontSide {
22 /// The section of the user's Telegram Passport which has the issue
23 #[serde(rename = "type")]
24 _type: FrontSideErrorType,
25 /// Base64-encoded hash of the file with the front side of the document
26 file_hash: String,
27 /// Error message
28 message: String,
29 },
30
31 /// Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
32 ReverseSide {
33 /// The section of the user's Telegram Passport which has the issue
34 #[serde(rename = "type")]
35 _type: ReverseSideErrorType,
36 /// Base64-encoded hash of the file with the reverse side of the document
37 file_hash: String,
38 /// Error message
39 message: String,
40 },
41
42 /// Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
43 Selfie {
44 /// The section of the user's Telegram Passport which has the issue
45 #[serde(rename = "type")]
46 _type: SelfieErrorType,
47 /// Base64-encoded hash of the file with the selfie
48 file_hash: String,
49 /// Error message
50 message: String,
51 },
52
53 /// Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
54 File {
55 /// The section of the user's Telegram Passport which has the issue
56 #[serde(rename = "type")]
57 _type: FileErrorType,
58 /// Base64-encoded file hash
59 file_hash: String,
60 /// Error message
61 message: String,
62 },
63
64 /// Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
65 Files {
66 /// The section of the user's Telegram Passport which has the issue
67 #[serde(rename = "type")]
68 _type: FilesErrorType,
69 /// List of base64-encoded file hashes
70 #[serde(skip_serializing_if = "Vec::is_empty")]
71 file_hashes: Vec<String>,
72 /// Error message
73 message: String,
74 },
75
76 /// Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
77 TranslationFile {
78 /// Type of element of the user's Telegram Passport which has the issue
79 #[serde(rename = "type")]
80 _type: TranslationFileErrorType,
81 /// Base64-encoded file hash
82 file_hash: String,
83 /// Error message
84 message: String,
85 },
86
87 /// Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
88 TranslationFiles {
89 /// Type of element of the user's Telegram Passport which has the issue
90 #[serde(rename = "type")]
91 _type: TranslationFilesErrorType,
92 /// List of base64-encoded file hashes
93 #[serde(skip_serializing_if = "Vec::is_empty")]
94 file_hashes: Vec<String>,
95 /// Error message
96 message: String,
97 },
98
99 /// Represents an issue in an unspecified place. The error is considered resolved when new data is added.
100 Unspecified {
101 /// Type of element of the user's Telegram Passport which has the issue
102 #[serde(rename = "type")]
103 _type: String,
104 /// Base64-encoded element hash
105 element_hash: String,
106 /// Error message
107 message: String,
108 },
109}
110
111#[derive(Serialize, Deserialize, Clone, Debug)]
112#[serde(rename_all = "snake_case")]
113#[allow(missing_docs)]
114pub enum DataErrorType {
115 PersonalDetails,
116 Passport,
117 DriverLicense,
118 IdentityCard,
119 InternalPassport,
120 Address,
121}
122
123#[derive(Serialize, Deserialize, Clone, Debug)]
124#[serde(rename_all = "snake_case")]
125#[allow(missing_docs)]
126pub enum FrontSideErrorType {
127 Passport,
128 DriverLicense,
129 IdentityCard,
130 InternalPassport,
131}
132
133#[derive(Serialize, Deserialize, Clone, Debug)]
134#[serde(rename_all = "snake_case")]
135#[allow(missing_docs)]
136pub enum ReverseSideErrorType {
137 DriverLicense,
138 IdentityCard,
139}
140
141#[derive(Serialize, Deserialize, Clone, Debug)]
142#[serde(rename_all = "snake_case")]
143#[allow(missing_docs)]
144pub enum SelfieErrorType {
145 Passport,
146 DriverLicense,
147 IdentityCard,
148 InternalPassport,
149}
150
151#[derive(Serialize, Deserialize, Clone, Debug)]
152#[serde(rename_all = "snake_case")]
153#[allow(missing_docs)]
154pub enum FileErrorType {
155 UtilityBill,
156 BankStatement,
157 RentalAgreement,
158 PassportRegistration,
159 TemporaryRegistration,
160}
161
162#[derive(Serialize, Deserialize, Clone, Debug)]
163#[serde(rename_all = "snake_case")]
164#[allow(missing_docs)]
165pub enum FilesErrorType {
166 UtilityBill,
167 BankStatement,
168 RentalAgreement,
169 PassportRegistration,
170 TemporaryRegistration,
171}
172
173#[derive(Serialize, Deserialize, Clone, Debug)]
174#[serde(rename_all = "snake_case")]
175#[allow(missing_docs)]
176pub enum TranslationFileErrorType {
177 Passport,
178 DriverLicense,
179 IdentityCard,
180 InternalPassport,
181 UtilityBill,
182 BankStatement,
183 RentalAgreement,
184 PassportRegistration,
185 TemporaryRegistration,
186}
187
188#[derive(Serialize, Deserialize, Clone, Debug)]
189#[serde(rename_all = "snake_case")]
190#[allow(missing_docs)]
191pub enum TranslationFilesErrorType {
192 Passport,
193 DriverLicense,
194 IdentityCard,
195 InternalPassport,
196 UtilityBill,
197 BankStatement,
198 RentalAgreement,
199 PassportRegistration,
200 TemporaryRegistration,
201}
202
203/// Describes Telegram Passport data shared with the bot by the user.
204#[derive(Serialize, Deserialize, Clone, Debug)]
205pub struct PassportData {
206 /// Array with information about documents and other Telegram Passport elements that was shared with the bot
207 pub data: Vec<EncryptedPassportElement>,
208 /// Encrypted credentials required to decrypt the data
209 pub credentials: EncryptedCredentials,
210}
211
212/// 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.
213#[derive(Serialize, Deserialize, Clone, Debug)]
214#[allow(missing_docs)]
215pub struct PassportFile {
216 /// Identifier for this file, which can be used to download or reuse the file
217 pub file_id: String,
218 /// 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.
219 pub file_unique_id: String,
220 /// File size in bytes
221 pub file_size: i64,
222 /// Unix time when the file was uploaded
223 pub file_date: i64,
224}
225
226/// Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
227#[derive(Serialize, Deserialize, Clone, Debug)]
228pub struct EncryptedCredentials {
229 /// Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication
230 pub data: String,
231 /// Base64-encoded data hash for data authentication
232 pub hash: String,
233 /// Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
234 pub secret: String,
235}
236
237/// Describes documents or other Telegram Passport elements shared with the bot by the user.
238#[derive(Serialize, Deserialize, Clone, Debug)]
239pub struct EncryptedPassportElement {
240 #[serde(flatten)]
241 #[allow(missing_docs)]
242 details: EncryptedPassportElementDetails,
243
244 /// Base64-encoded element hash for using in PassportElementErrorUnspecified
245 pub hash: String,
246}
247
248#[derive(Serialize, Deserialize, Clone, Debug)]
249#[serde(rename_all = "snake_case")]
250#[allow(missing_docs)]
251pub enum EncryptedPassportElementDetails {
252 PersonalDetails {
253 /// Base64-encoded encrypted Telegram Passport element data provided by the user
254 data: String,
255 },
256 Passport {
257 /// Base64-encoded encrypted Telegram Passport element data provided by the user
258 data: String,
259 /// Encrypted file with the front side of the document, provided by the user
260 #[serde(skip_serializing_if = "Option::is_none")]
261 front_side: Option<PassportFile>,
262 /// Encrypted file with the selfie of the user holding a document
263 selfie: PassportFile,
264 /// Array of encrypted files with translated versions of documents provided by the user
265 #[serde(skip_serializing_if = "Vec::is_empty")]
266 translation: Vec<PassportFile>,
267 },
268 DriverLicense {
269 /// Base64-encoded encrypted Telegram Passport element data provided by the user
270 data: String,
271 /// Encrypted file with the front side of the document, provided by the user
272 #[serde(skip_serializing_if = "Option::is_none")]
273 front_side: Option<PassportFile>,
274 /// Encrypted file with the selfie of the user holding a document
275 selfie: PassportFile,
276 /// Array of encrypted files with translated versions of documents provided by the user
277 #[serde(skip_serializing_if = "Vec::is_empty")]
278 translation: Vec<PassportFile>,
279 },
280 IdentityCard {
281 /// Base64-encoded encrypted Telegram Passport element data provided by the user
282 data: String,
283 /// Encrypted file with the front side of the document, provided by the user
284 #[serde(skip_serializing_if = "Option::is_none")]
285 front_side: Option<PassportFile>,
286 /// Encrypted file with the selfie of the user holding a document
287 selfie: PassportFile,
288 /// Array of encrypted files with translated versions of documents provided by the user
289 #[serde(skip_serializing_if = "Vec::is_empty")]
290 translation: Vec<PassportFile>,
291 },
292 InternalPassport {
293 /// Base64-encoded encrypted Telegram Passport element data provided by the user
294 data: String,
295 /// Encrypted file with the front side of the document, provided by the user
296 #[serde(skip_serializing_if = "Option::is_none")]
297 front_side: Option<PassportFile>,
298 /// Encrypted file with the selfie of the user holding a document
299 selfie: PassportFile,
300 /// Array of encrypted files with translated versions of documents provided by the user
301 #[serde(skip_serializing_if = "Vec::is_empty")]
302 translation: Vec<PassportFile>,
303 },
304 Address {
305 /// Base64-encoded encrypted Telegram Passport element data provided by the user
306 data: String,
307 },
308 UtilityBill {
309 /// Array of encrypted files with documents provided by the user
310 #[serde(skip_serializing_if = "Vec::is_empty")]
311 files: Vec<PassportFile>,
312 /// Array of encrypted files with translated versions of documents provided by the user
313 #[serde(skip_serializing_if = "Vec::is_empty")]
314 translation: Vec<PassportFile>,
315 },
316 BankStatement {
317 /// Array of encrypted files with documents provided by the user
318 #[serde(skip_serializing_if = "Vec::is_empty")]
319 files: Vec<PassportFile>,
320 /// Array of encrypted files with translated versions of documents provided by the user
321 #[serde(skip_serializing_if = "Vec::is_empty")]
322 translation: Vec<PassportFile>,
323 },
324 RentalAgreement {
325 /// Array of encrypted files with documents provided by the user
326 #[serde(skip_serializing_if = "Vec::is_empty")]
327 files: Vec<PassportFile>,
328 /// Array of encrypted files with translated versions of documents provided by the user
329 #[serde(skip_serializing_if = "Vec::is_empty")]
330 translation: Vec<PassportFile>,
331 },
332 PassportRegistration {
333 /// Array of encrypted files with documents provided by the user
334 #[serde(skip_serializing_if = "Vec::is_empty")]
335 files: Vec<PassportFile>,
336 /// Array of encrypted files with translated versions of documents provided by the user
337 #[serde(skip_serializing_if = "Vec::is_empty")]
338 translation: Vec<PassportFile>,
339 },
340 TemporaryRegistration {
341 /// Array of encrypted files with documents provided by the user
342 #[serde(skip_serializing_if = "Vec::is_empty")]
343 files: Vec<PassportFile>,
344 /// Array of encrypted files with translated versions of documents provided by the user
345 #[serde(skip_serializing_if = "Vec::is_empty")]
346 translation: Vec<PassportFile>,
347 },
348 PhoneNumber {
349 /// User's verified phone number
350 phone_number: String,
351 },
352 Email {
353 /// User's verified email address
354 email: String,
355 },
356}