rustigram-types 0.12.0

Telegram Bot API type definitions for rustigram
Documentation
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
use serde::{Deserialize, Serialize};

/// One size of a photo or file thumbnail.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PhotoSize {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Photo width in pixels.
    pub width: u32,
    /// Photo height in pixels.
    pub height: u32,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// A file ready to be downloaded.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct File {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
    /// Relative file path for constructing the download URL.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_path: Option<String>,
}

impl File {
    /// Constructs the full download URL for this file.
    #[must_use]
    pub fn url(&self, token: &str) -> Option<String> {
        self.file_path
            .as_ref()
            .map(|path| format!("https://api.telegram.org/file/bot{token}/{path}"))
    }
}

/// Audio file to be treated as music.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Audio {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Duration of the audio in seconds.
    pub duration: u32,
    /// Performer of the audio as defined by the sender or audio tags.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub performer: Option<String>,
    /// Title of the audio as defined by the sender or audio tags.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /// Original filename as defined by the sender.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_name: Option<String>,
    /// MIME type of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
    /// Thumbnail of the album cover.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<PhotoSize>,
}

/// General file (not photo, voice, audio, or video).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Document {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Document thumbnail.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<PhotoSize>,
    /// Original filename as defined by the sender.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_name: Option<String>,
    /// MIME type of the document.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// A video file of a specific quality.
///
/// Returned inside [`Video::qualities`] when multiple quality levels are available.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VideoQuality {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Video width in pixels.
    pub width: u32,
    /// Video height in pixels.
    pub height: u32,
    /// Codec used to encode the video (e.g. `"h264"`, `"h265"`, `"av01"`).
    pub codec: String,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// Video file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Video {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Video width in pixels.
    pub width: u32,
    /// Video height in pixels.
    pub height: u32,
    /// Duration of the video in seconds.
    pub duration: u32,
    /// Video thumbnail.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<PhotoSize>,
    /// Cover image for the video in the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<Vec<PhotoSize>>,
    /// Start timestamp for video chapters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_timestamp: Option<u32>,
    /// Other available quality levels for this video (Bot API 9.4).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub qualities: Option<Vec<VideoQuality>>,
    /// Original filename.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_name: Option<String>,
    /// MIME type of the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// Animation file (GIF or H.264/MPEG-4 AVC, no sound).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Animation {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Animation width in pixels.
    pub width: u32,
    /// Animation height in pixels.
    pub height: u32,
    /// Duration of the animation in seconds.
    pub duration: u32,
    /// Animation thumbnail.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<PhotoSize>,
    /// Original filename as defined by the sender.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_name: Option<String>,
    /// MIME type of the animation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// Voice note (OGG/OPUS audio).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Voice {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Duration of the voice note in seconds.
    pub duration: u32,
    /// MIME type of the voice note.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// Rounded-square MPEG4 video note.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VideoNote {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// Video width and height (diameter of the circle).
    pub length: u32,
    /// Duration of the video in seconds.
    pub duration: u32,
    /// Video thumbnail.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<PhotoSize>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// A photo with a short video (live photo).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LivePhoto {
    /// Available sizes of the corresponding static photo.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub photo: Option<Vec<PhotoSize>>,
    /// Identifier for the video file.
    pub file_id: String,
    /// Unique identifier for the video file, stable across bots and time.
    pub file_unique_id: String,
    /// Video width as defined by the sender.
    pub width: u32,
    /// Video height as defined by the sender.
    pub height: u32,
    /// Duration of the video in seconds.
    pub duration: u32,
    /// MIME type of the file as defined by the sender.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// File size in bytes.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
}

/// Represents a file to be sent.
#[derive(Debug, Clone)]
pub enum InputFile {
    /// Send an existing file by its Telegram `file_id`.
    FileId(String),
    /// Send a file from a URL (photo ≤5 MB, others ≤20 MB).
    Url(String),
    /// Upload new file bytes.
    Bytes {
        /// Original filename sent in the Content-Disposition header.
        filename: String,
        /// Raw file bytes.
        data: Vec<u8>,
        /// MIME type of the file.
        mime_type: String,
    },
    /// Reference an already-included multipart attachment by `attach://<name>`.
    Attach(String),
}

impl InputFile {
    /// Returns the string representation for JSON/query-string fields.
    #[must_use]
    pub fn as_str(&self) -> &str {
        match self {
            Self::FileId(id) => id,
            Self::Url(url) => url,
            Self::Attach(name) => name,
            Self::Bytes { filename, .. } => filename,
        }
    }

    /// Returns `true` if this variant needs multipart form upload.
    #[must_use]
    pub fn requires_multipart(&self) -> bool {
        matches!(self, Self::Bytes { .. })
    }
}

/// Encrypted passport file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PassportFile {
    /// Telegram file identifier.
    pub file_id: String,
    /// Unique file identifier, stable across bots and time.
    pub file_unique_id: String,
    /// File size in bytes.
    pub file_size: u64,
    /// Unix timestamp when the file was uploaded.
    pub file_date: i64,
}

// ─── InputMedia ───────────────────────────────────────────────────────────────
//
// Used by `sendMediaGroup` and `editMessageMedia`. The `media` field accepts a
// `file_id`, HTTP URL, or `"attach://<n>"` for a multipart attachment.

/// A photo to include in a media group or replace an existing media message.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaPhoto {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// `true` if the caption must be shown above the media.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub show_caption_above_media: Option<bool>,
    /// `true` if the photo needs a spoiler animation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_spoiler: Option<bool>,
}

/// A video to include in a media group or replace an existing media message.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaVideo {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Thumbnail: `file_id` or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<String>,
    /// Cover image: `file_id`, HTTP URL, or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<String>,
    /// Start timestamp for the video in the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_timestamp: Option<i64>,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// `true` if the caption must be shown above the media.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub show_caption_above_media: Option<bool>,
    /// Video width in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u32>,
    /// Video height in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<u32>,
    /// Video duration in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    /// `true` if the uploaded video is suitable for streaming.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_streaming: Option<bool>,
    /// `true` if the video needs a spoiler animation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_spoiler: Option<bool>,
}

/// An animation (GIF or silent H.264) to include in a media group.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaAnimation {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Thumbnail: `file_id` or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<String>,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// `true` if the caption must be shown above the media.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub show_caption_above_media: Option<bool>,
    /// Animation width in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u32>,
    /// Animation height in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<u32>,
    /// Animation duration in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    /// `true` if the animation needs a spoiler animation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_spoiler: Option<bool>,
}

/// An audio file to include in a media group.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaAudio {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Thumbnail: `file_id` or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<String>,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// Audio duration in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    /// Performer of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub performer: Option<String>,
    /// Title of the audio.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
}

/// A voice message file to be sent.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaVoiceNote {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// Duration of the voice message in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
}

/// A document (general file) to include in a media group.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaDocument {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Thumbnail: `file_id` or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<String>,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// `true` to disable automatic server-side content type detection.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disable_content_type_detection: Option<bool>,
}

/// A live photo to be sent as part of a media group or to replace an existing media message.
///
/// Sending live photos by URL is currently unsupported — use `file_id` or `attach://<n>`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaLivePhoto {
    /// Video of the live photo: `file_id` or `"attach://<n>"`.
    pub media: String,
    /// The static photo: `file_id` or `"attach://<n>"`.
    pub photo: String,
    /// Caption (0–1024 characters after entities parsing).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption: Option<String>,
    /// Parse mode for the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parse_mode: Option<crate::message::ParseMode>,
    /// Special entities in the caption.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub caption_entities: Option<Vec<crate::message::MessageEntity>>,
    /// `true` if the caption must be shown above the media.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub show_caption_above_media: Option<bool>,
    /// `true` if the live photo needs a spoiler animation.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_spoiler: Option<bool>,
}

/// A location to be sent as poll media.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaLocation {
    /// Latitude of the location.
    pub latitude: f64,
    /// Longitude of the location.
    pub longitude: f64,
    /// Radius of uncertainty in metres (0–1500).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub horizontal_accuracy: Option<f64>,
}

/// A venue to be sent as poll media.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaVenue {
    /// Latitude of the venue.
    pub latitude: f64,
    /// Longitude of the venue.
    pub longitude: f64,
    /// Name of the venue.
    pub title: String,
    /// Address of the venue.
    pub address: String,
    /// Foursquare identifier of the venue.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub foursquare_id: Option<String>,
    /// Foursquare type of the venue.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub foursquare_type: Option<String>,
    /// Google Places identifier of the venue.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub google_place_id: Option<String>,
    /// Google Places type of the venue.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub google_place_type: Option<String>,
}

/// A sticker file to be sent as poll option media.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputMediaSticker {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Emoji associated with the sticker; only for just-uploaded stickers.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub emoji: Option<String>,
}

/// The media content of a message to be sent or edited.
///
/// Serialise with `serde_json::to_value(&media)` to pass to `sendMediaGroup`
/// or `editMessageMedia` until the API methods are updated to accept this type
/// directly.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum InputMedia {
    /// A photo.
    Photo(InputMediaPhoto),
    /// A video.
    Video(InputMediaVideo),
    /// An animation (GIF or silent H.264).
    Animation(InputMediaAnimation),
    /// An audio file treated as music.
    Audio(InputMediaAudio),
    /// A general document.
    Document(InputMediaDocument),
    /// A live photo.
    LivePhoto(InputMediaLivePhoto),
    /// A voice message.
    VoiceNote(InputMediaVoiceNote),
}

// ─── InputPaidMedia ───────────────────────────────────────────────────────────

/// A photo to send as paid media.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputPaidMediaPhoto {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
}

/// A video to send as paid media.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputPaidMediaVideo {
    /// File to send: `file_id`, HTTP URL, or `"attach://<n>"`.
    pub media: String,
    /// Thumbnail: `file_id` or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<String>,
    /// Cover image: `file_id`, HTTP URL, or `"attach://<n>"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<String>,
    /// Start timestamp for the video in the message.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_timestamp: Option<i64>,
    /// Video width in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u32>,
    /// Video height in pixels.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<u32>,
    /// Video duration in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    /// `true` if the uploaded video is suitable for streaming.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_streaming: Option<bool>,
}

/// A live photo to send as paid media.
///
/// Both video and static photo must be `file_id` or `attach://<n>`.
/// Sending live photos by URL is currently unsupported.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputPaidMediaLivePhoto {
    /// Video of the live photo: `file_id` or `"attach://<n>"`.
    pub media: String,
    /// The static photo: `file_id` or `"attach://<n>"`.
    pub photo: String,
}

/// Paid media to send via `sendPaidMedia`.
///
/// Serialise with `serde_json::to_value(&media)` to pass to `sendPaidMedia`
/// until the method is updated to accept this type directly.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum InputPaidMedia {
    /// A photo.
    Photo(InputPaidMediaPhoto),
    /// A video.
    Video(InputPaidMediaVideo),
    /// A live photo.
    LivePhoto(InputPaidMediaLivePhoto),
}

// ─── InputProfilePhoto ────────────────────────────────────────────────────────

/// A static profile photo in JPEG format.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputProfilePhotoStatic {
    /// The photo file.
    ///
    /// Profile photos cannot be reused — upload as a new file using
    /// `"attach://<n>"` via multipart/form-data.
    pub photo: String,
}

/// An animated profile photo in MPEG4 format.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InputProfilePhotoAnimated {
    /// The animation file.
    ///
    /// Profile photos cannot be reused — upload as a new file using
    /// `"attach://<n>"` via multipart/form-data.
    pub animation: String,
    /// Timestamp in seconds of the frame to use as the static profile photo.
    /// Defaults to `0.0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub main_frame_timestamp: Option<f64>,
}

/// A profile photo to set via `setMyProfilePhoto` or `setBusinessAccountProfilePhoto`.
///
/// Pass this value directly; both methods serialise it themselves.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum InputProfilePhoto {
    /// A static JPEG profile photo.
    Static(InputProfilePhotoStatic),
    /// An animated MPEG4 profile photo.
    Animated(InputProfilePhotoAnimated),
}