1#![allow(clippy::large_enum_variant)]
2
3use derive_more::From;
4use serde::{Deserialize, Serialize};
5
6use crate::types::{
7 InlineQueryResultArticle, InlineQueryResultAudio, InlineQueryResultCachedAudio,
8 InlineQueryResultCachedDocument, InlineQueryResultCachedGif, InlineQueryResultCachedMpeg4Gif,
9 InlineQueryResultCachedPhoto, InlineQueryResultCachedSticker, InlineQueryResultCachedVideo,
10 InlineQueryResultCachedVoice, InlineQueryResultContact, InlineQueryResultDocument,
11 InlineQueryResultGame, InlineQueryResultGif, InlineQueryResultLocation,
12 InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue,
13 InlineQueryResultVideo, InlineQueryResultVoice,
14};
15
16#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, From)]
20#[serde(tag = "type")]
21#[serde(rename_all = "snake_case")]
22#[serde(from = "raw::InlineQueryResult", into = "raw::InlineQueryResult")]
23pub enum InlineQueryResult {
24 #[serde(rename = "audio")]
25 CachedAudio(InlineQueryResultCachedAudio),
26 #[serde(rename = "document")]
27 CachedDocument(InlineQueryResultCachedDocument),
28 #[serde(rename = "gif")]
29 CachedGif(InlineQueryResultCachedGif),
30 #[serde(rename = "mpeg4_gif")]
31 CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif),
32 #[serde(rename = "photo")]
33 CachedPhoto(InlineQueryResultCachedPhoto),
34 #[serde(rename = "sticker")]
35 CachedSticker(InlineQueryResultCachedSticker),
36 #[serde(rename = "video")]
37 CachedVideo(InlineQueryResultCachedVideo),
38 #[serde(rename = "voice")]
39 CachedVoice(InlineQueryResultCachedVoice),
40
41 Article(InlineQueryResultArticle),
42 Audio(InlineQueryResultAudio),
43 Contact(InlineQueryResultContact),
44 Game(InlineQueryResultGame),
45 Document(InlineQueryResultDocument),
46 Gif(InlineQueryResultGif),
47 Location(InlineQueryResultLocation),
48 #[serde(rename = "mpeg4_gif")]
49 Mpeg4Gif(InlineQueryResultMpeg4Gif),
50 Photo(InlineQueryResultPhoto),
51 Venue(InlineQueryResultVenue),
52 Video(InlineQueryResultVideo),
53 Voice(InlineQueryResultVoice),
54}
55
56mod raw {
57 use super::*;
58
59 #[derive(Serialize, Deserialize)]
60 #[serde(untagged)]
61 pub(super) enum AudioKind {
62 Cached(InlineQueryResultCachedAudio),
63 NonCached(InlineQueryResultAudio),
64 }
65
66 #[derive(Serialize, Deserialize)]
67 #[serde(untagged)]
68 pub(super) enum DocumentKind {
69 Cached(InlineQueryResultCachedDocument),
70 NonCached(InlineQueryResultDocument),
71 }
72
73 #[derive(Serialize, Deserialize)]
74 #[serde(untagged)]
75 pub(super) enum GifKind {
76 Cached(InlineQueryResultCachedGif),
77 NonCached(InlineQueryResultGif),
78 }
79
80 #[derive(Serialize, Deserialize)]
81 #[serde(untagged)]
82 pub(super) enum Mpeg4GifKind {
83 Cached(InlineQueryResultCachedMpeg4Gif),
84 NonCached(InlineQueryResultMpeg4Gif),
85 }
86
87 #[derive(Serialize, Deserialize)]
88 #[serde(untagged)]
89 pub(super) enum PhotoKind {
90 Cached(InlineQueryResultCachedPhoto),
91 NonCached(InlineQueryResultPhoto),
92 }
93
94 #[derive(Serialize, Deserialize)]
95 #[serde(untagged)]
96 pub(super) enum VideoKind {
97 Cached(InlineQueryResultCachedVideo),
98 NonCached(InlineQueryResultVideo),
99 }
100
101 #[derive(Serialize, Deserialize)]
102 #[serde(untagged)]
103 pub(super) enum VoiceKind {
104 Cached(InlineQueryResultCachedVoice),
105 NonCached(InlineQueryResultVoice),
106 }
107
108 #[derive(Serialize, Deserialize)]
109 #[serde(tag = "type")]
110 #[serde(rename_all = "snake_case")]
111 pub(super) enum InlineQueryResult {
112 Audio(AudioKind),
114 Document(DocumentKind),
115 Gif(GifKind),
116 #[serde(rename = "mpeg4_gif")]
117 Mpeg4Gif(Mpeg4GifKind),
118 Photo(PhotoKind),
119 Video(VideoKind),
120 Voice(VoiceKind),
121
122 #[serde(rename = "sticker")]
124 CachedSticker(InlineQueryResultCachedSticker),
125
126 Article(InlineQueryResultArticle),
128 Contact(InlineQueryResultContact),
129 Game(InlineQueryResultGame),
130 Location(InlineQueryResultLocation),
131 Venue(InlineQueryResultVenue),
132 }
133
134 impl From<InlineQueryResult> for super::InlineQueryResult {
135 fn from(raw: InlineQueryResult) -> Self {
136 match raw {
137 InlineQueryResult::Audio(AudioKind::Cached(audio)) => {
138 super::InlineQueryResult::CachedAudio(audio)
139 }
140 InlineQueryResult::Audio(AudioKind::NonCached(audio)) => {
141 super::InlineQueryResult::Audio(audio)
142 }
143 InlineQueryResult::Document(DocumentKind::Cached(document)) => {
144 super::InlineQueryResult::CachedDocument(document)
145 }
146 InlineQueryResult::Document(DocumentKind::NonCached(document)) => {
147 super::InlineQueryResult::Document(document)
148 }
149 InlineQueryResult::Gif(GifKind::Cached(gif)) => {
150 super::InlineQueryResult::CachedGif(gif)
151 }
152 InlineQueryResult::Gif(GifKind::NonCached(gif)) => {
153 super::InlineQueryResult::Gif(gif)
154 }
155 InlineQueryResult::Mpeg4Gif(Mpeg4GifKind::Cached(gif)) => {
156 super::InlineQueryResult::CachedMpeg4Gif(gif)
157 }
158 InlineQueryResult::Mpeg4Gif(Mpeg4GifKind::NonCached(gif)) => {
159 super::InlineQueryResult::Mpeg4Gif(gif)
160 }
161 InlineQueryResult::Photo(PhotoKind::Cached(photo)) => {
162 super::InlineQueryResult::CachedPhoto(photo)
163 }
164 InlineQueryResult::Photo(PhotoKind::NonCached(photo)) => {
165 super::InlineQueryResult::Photo(photo)
166 }
167 InlineQueryResult::Video(VideoKind::Cached(video)) => {
168 super::InlineQueryResult::CachedVideo(video)
169 }
170 InlineQueryResult::Video(VideoKind::NonCached(video)) => {
171 super::InlineQueryResult::Video(video)
172 }
173 InlineQueryResult::Voice(VoiceKind::Cached(voice)) => {
174 super::InlineQueryResult::CachedVoice(voice)
175 }
176 InlineQueryResult::Voice(VoiceKind::NonCached(voice)) => {
177 super::InlineQueryResult::Voice(voice)
178 }
179
180 InlineQueryResult::CachedSticker(sticker) => {
181 super::InlineQueryResult::CachedSticker(sticker)
182 }
183
184 InlineQueryResult::Article(article) => super::InlineQueryResult::Article(article),
185 InlineQueryResult::Contact(contact) => super::InlineQueryResult::Contact(contact),
186 InlineQueryResult::Game(game) => super::InlineQueryResult::Game(game),
187 InlineQueryResult::Location(location) => {
188 super::InlineQueryResult::Location(location)
189 }
190 InlineQueryResult::Venue(venue) => super::InlineQueryResult::Venue(venue),
191 }
192 }
193 }
194
195 impl From<super::InlineQueryResult> for InlineQueryResult {
196 fn from(raw: super::InlineQueryResult) -> Self {
197 match raw {
198 super::InlineQueryResult::CachedAudio(audio) => {
199 InlineQueryResult::Audio(AudioKind::Cached(audio))
200 }
201 super::InlineQueryResult::Audio(audio) => {
202 InlineQueryResult::Audio(AudioKind::NonCached(audio))
203 }
204 super::InlineQueryResult::CachedDocument(document) => {
205 InlineQueryResult::Document(DocumentKind::Cached(document))
206 }
207 super::InlineQueryResult::Document(document) => {
208 InlineQueryResult::Document(DocumentKind::NonCached(document))
209 }
210 super::InlineQueryResult::CachedGif(gif) => {
211 InlineQueryResult::Gif(GifKind::Cached(gif))
212 }
213 super::InlineQueryResult::Gif(gif) => {
214 InlineQueryResult::Gif(GifKind::NonCached(gif))
215 }
216 super::InlineQueryResult::CachedMpeg4Gif(gif) => {
217 InlineQueryResult::Mpeg4Gif(Mpeg4GifKind::Cached(gif))
218 }
219 super::InlineQueryResult::Mpeg4Gif(gif) => {
220 InlineQueryResult::Mpeg4Gif(Mpeg4GifKind::NonCached(gif))
221 }
222 super::InlineQueryResult::CachedPhoto(photo) => {
223 InlineQueryResult::Photo(PhotoKind::Cached(photo))
224 }
225 super::InlineQueryResult::Photo(photo) => {
226 InlineQueryResult::Photo(PhotoKind::NonCached(photo))
227 }
228 super::InlineQueryResult::CachedVideo(video) => {
229 InlineQueryResult::Video(VideoKind::Cached(video))
230 }
231 super::InlineQueryResult::Video(video) => {
232 InlineQueryResult::Video(VideoKind::NonCached(video))
233 }
234 super::InlineQueryResult::CachedVoice(voice) => {
235 InlineQueryResult::Voice(VoiceKind::Cached(voice))
236 }
237 super::InlineQueryResult::Voice(voice) => {
238 InlineQueryResult::Voice(VoiceKind::NonCached(voice))
239 }
240
241 super::InlineQueryResult::CachedSticker(sticker) => {
242 InlineQueryResult::CachedSticker(sticker)
243 }
244
245 super::InlineQueryResult::Article(article) => InlineQueryResult::Article(article),
246 super::InlineQueryResult::Contact(contact) => InlineQueryResult::Contact(contact),
247 super::InlineQueryResult::Game(game) => InlineQueryResult::Game(game),
248 super::InlineQueryResult::Location(location) => {
249 InlineQueryResult::Location(location)
250 }
251 super::InlineQueryResult::Venue(venue) => InlineQueryResult::Venue(venue),
252 }
253 }
254 }
255}
256
257#[cfg(test)]
258mod tests {
259 use crate::types::{
260 inline_keyboard_markup::InlineKeyboardMarkup, parse_mode::ParseMode, InlineQueryResult,
261 InlineQueryResultArticle, InlineQueryResultAudio, InlineQueryResultCachedAudio,
262 InlineQueryResultCachedDocument, InlineQueryResultCachedGif,
263 InlineQueryResultCachedMpeg4Gif, InlineQueryResultCachedPhoto,
264 InlineQueryResultCachedSticker, InlineQueryResultCachedVideo, InlineQueryResultCachedVoice,
265 InlineQueryResultContact, InlineQueryResultDocument, InlineQueryResultGame,
266 InlineQueryResultGif, InlineQueryResultLocation, InlineQueryResultMpeg4Gif,
267 InlineQueryResultPhoto, InlineQueryResultVenue, InlineQueryResultVideo,
268 InlineQueryResultVoice, InputMessageContent, InputMessageContentLocation,
269 InputMessageContentText, LinkPreviewOptions, Seconds,
270 };
271
272 use mime::Mime;
273 use std::str::FromStr as _;
274 use url::Url;
275
276 #[test]
277 fn cached_audio_min() {
278 let structure = InlineQueryResult::CachedAudio(InlineQueryResultCachedAudio {
279 id: String::from("id"),
280 audio_file_id: "audio_file_id".into(),
281 caption: None,
282 parse_mode: None,
283 caption_entities: None,
284 reply_markup: None,
285 input_message_content: None,
286 });
287
288 let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id"}"#;
289 let actual_json = serde_json::to_string(&structure).unwrap();
290
291 assert_eq!(expected_json, actual_json);
292 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
293 }
294
295 #[test]
296 fn cached_audio_full() {
297 let structure = InlineQueryResult::CachedAudio(InlineQueryResultCachedAudio {
298 id: String::from("id"),
299 audio_file_id: "audio_file_id".into(),
300 caption: Some(String::from("caption")),
301 parse_mode: Some(ParseMode::Html),
302 reply_markup: Some(InlineKeyboardMarkup::default()),
303 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
304 message_text: String::from("message_text"),
305 parse_mode: Some(ParseMode::MarkdownV2),
306 entities: None,
307 link_preview_options: Some(LinkPreviewOptions {
308 is_disabled: true,
309 url: None,
310 prefer_small_media: false,
311 prefer_large_media: false,
312 show_above_text: false,
313 }),
314 })),
315 caption_entities: None,
316 });
317
318 let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
319 let actual_json = serde_json::to_string(&structure).unwrap();
320
321 assert_eq!(expected_json, actual_json);
322 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
323 }
324
325 #[test]
326 fn audio_min() {
327 let structure = InlineQueryResult::Audio(InlineQueryResultAudio {
328 id: String::from("id"),
329 audio_url: reqwest::Url::parse("http://audio_url/").unwrap(),
330 title: String::from("title"),
331 caption: None,
332 parse_mode: None,
333 caption_entities: None,
334 performer: None,
335 audio_duration: None,
336 reply_markup: None,
337 input_message_content: None,
338 });
339
340 let expected_json =
341 r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title"}"#;
342 let actual_json = serde_json::to_string(&structure).unwrap();
343
344 assert_eq!(expected_json, actual_json);
345 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
346 }
347
348 #[test]
349 fn audio_full() {
350 let structure = InlineQueryResult::Audio(InlineQueryResultAudio {
351 id: String::from("id"),
352 audio_url: reqwest::Url::parse("http://audio_url/").unwrap(),
353 title: String::from("title"),
354 caption: Some(String::from("caption")),
355 parse_mode: Some(ParseMode::Html),
356 reply_markup: Some(InlineKeyboardMarkup::default()),
357 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
358 message_text: String::from("message_text"),
359 parse_mode: Some(ParseMode::MarkdownV2),
360 entities: None,
361 link_preview_options: Some(LinkPreviewOptions {
362 is_disabled: true,
363 url: None,
364 prefer_small_media: false,
365 prefer_large_media: false,
366 show_above_text: false,
367 }),
368 })),
369 caption_entities: None,
370 performer: Some(String::from("performer")),
371 audio_duration: Some(Seconds::from_seconds(1)),
372 });
373
374 let expected_json = r#"{"type":"audio","id":"id","audio_url":"http://audio_url/","title":"title","caption":"caption","parse_mode":"HTML","performer":"performer","audio_duration":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
375 let actual_json = serde_json::to_string(&structure).unwrap();
376
377 assert_eq!(expected_json, actual_json);
378 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
379 }
380
381 #[test]
382 fn cached_document_min() {
383 let structure = InlineQueryResult::CachedDocument(InlineQueryResultCachedDocument {
384 id: String::from("id"),
385 title: String::from("title"),
386 document_file_id: "document_file_id".into(),
387 description: None,
388 caption: None,
389 parse_mode: None,
390 caption_entities: None,
391 reply_markup: None,
392 input_message_content: None,
393 });
394
395 let expected_json = r#"{"type":"document","id":"id","title":"title","document_file_id":"document_file_id"}"#;
396 let actual_json = serde_json::to_string(&structure).unwrap();
397
398 assert_eq!(expected_json, actual_json);
399 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
400 }
401
402 #[test]
403 fn cached_document_full() {
404 let structure = InlineQueryResult::CachedDocument(InlineQueryResultCachedDocument {
405 id: String::from("id"),
406 title: String::from("title"),
407 document_file_id: "document_file_id".into(),
408 description: Some(String::from("description")),
409 caption: Some(String::from("caption")),
410 parse_mode: Some(ParseMode::Html),
411 reply_markup: Some(InlineKeyboardMarkup::default()),
412 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
413 message_text: String::from("message_text"),
414 parse_mode: Some(ParseMode::MarkdownV2),
415 entities: None,
416 link_preview_options: Some(LinkPreviewOptions {
417 is_disabled: true,
418 url: None,
419 prefer_small_media: false,
420 prefer_large_media: false,
421 show_above_text: false,
422 }),
423 })),
424 caption_entities: None,
425 });
426
427 let expected_json = r#"{"type":"document","id":"id","title":"title","document_file_id":"document_file_id","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
428 let actual_json = serde_json::to_string(&structure).unwrap();
429
430 assert_eq!(expected_json, actual_json);
431 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
432 }
433
434 #[test]
435 fn document_min() {
436 let structure = InlineQueryResult::Document(InlineQueryResultDocument {
437 id: String::from("id"),
438 title: String::from("title"),
439 caption: None,
440 parse_mode: None,
441 caption_entities: None,
442 document_url: reqwest::Url::parse("http://document_url/").unwrap(),
443 mime_type: Mime::from_str("application/pdf").unwrap(),
444 description: None,
445 reply_markup: None,
446 input_message_content: None,
447 thumbnail_url: None,
448 thumbnail_width: None,
449 thumbnail_height: None,
450 });
451
452 let expected_json = r#"{"type":"document","id":"id","title":"title","document_url":"http://document_url/","mime_type":"application/pdf"}"#;
453 let actual_json = serde_json::to_string(&structure).unwrap();
454
455 assert_eq!(expected_json, actual_json);
456 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
457 }
458
459 #[test]
460 fn document_full() {
461 let structure = InlineQueryResult::Document(InlineQueryResultDocument {
462 id: String::from("id"),
463 title: String::from("title"),
464 caption: Some(String::from("caption")),
465 parse_mode: Some(ParseMode::Html),
466 caption_entities: None,
467 document_url: reqwest::Url::parse("http://document_url/").unwrap(),
468 mime_type: Mime::from_str("application/pdf").unwrap(),
469 description: Some(String::from("description")),
470 reply_markup: Some(InlineKeyboardMarkup::default()),
471 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
472 message_text: String::from("message_text"),
473 parse_mode: Some(ParseMode::MarkdownV2),
474 entities: None,
475 link_preview_options: Some(LinkPreviewOptions {
476 is_disabled: true,
477 url: None,
478 prefer_small_media: false,
479 prefer_large_media: false,
480 show_above_text: false,
481 }),
482 })),
483 thumbnail_url: Some(reqwest::Url::parse("http://thumb_url/").unwrap()),
484 thumbnail_width: Some(1),
485 thumbnail_height: Some(1),
486 });
487
488 let expected_json = r#"{"type":"document","id":"id","title":"title","caption":"caption","parse_mode":"HTML","document_url":"http://document_url/","mime_type":"application/pdf","description":"description","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
489 let actual_json = serde_json::to_string(&structure).unwrap();
490
491 assert_eq!(expected_json, actual_json);
492 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
493 }
494
495 #[test]
496 fn cached_gif_min() {
497 let structure = InlineQueryResult::CachedGif(InlineQueryResultCachedGif {
498 id: String::from("id"),
499 gif_file_id: "gif_file_id".into(),
500 title: None,
501 caption: None,
502 parse_mode: None,
503 caption_entities: None,
504 show_caption_above_media: false,
505 reply_markup: None,
506 input_message_content: None,
507 });
508
509 let expected_json = r#"{"type":"gif","id":"id","gif_file_id":"gif_file_id"}"#;
510 let actual_json = serde_json::to_string(&structure).unwrap();
511
512 assert_eq!(expected_json, actual_json);
513 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
514 }
515
516 #[test]
517 fn cached_gif_full() {
518 let structure = InlineQueryResult::CachedGif(InlineQueryResultCachedGif {
519 id: String::from("id"),
520 gif_file_id: "gif_file_id".into(),
521 title: Some(String::from("title")),
522 caption: Some(String::from("caption")),
523 parse_mode: Some(ParseMode::Html),
524 caption_entities: None,
525 show_caption_above_media: false,
526 reply_markup: Some(InlineKeyboardMarkup::default()),
527 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
528 message_text: String::from("message_text"),
529 parse_mode: Some(ParseMode::MarkdownV2),
530 entities: None,
531 link_preview_options: Some(LinkPreviewOptions {
532 is_disabled: true,
533 url: None,
534 prefer_small_media: false,
535 prefer_large_media: false,
536 show_above_text: false,
537 }),
538 })),
539 });
540
541 let expected_json = r#"{"type":"gif","id":"id","gif_file_id":"gif_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
542 let actual_json = serde_json::to_string(&structure).unwrap();
543
544 assert_eq!(expected_json, actual_json);
545 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
546 }
547
548 #[test]
549 fn gif_min() {
550 let structure = InlineQueryResult::Gif(InlineQueryResultGif {
551 id: String::from("id"),
552 gif_url: Url::parse("http://gif_url/").unwrap(),
553 gif_width: None,
554 gif_height: None,
555 gif_duration: None,
556 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
557 thumbnail_mime_type: None,
558 title: None,
559 caption: None,
560 parse_mode: None,
561 caption_entities: None,
562 show_caption_above_media: false,
563 reply_markup: None,
564 input_message_content: None,
565 });
566
567 let expected_json = r#"{"type":"gif","id":"id","gif_url":"http://gif_url/","thumbnail_url":"http://thumb_url/"}"#;
568 let actual_json = serde_json::to_string(&structure).unwrap();
569
570 assert_eq!(expected_json, actual_json);
571 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
572 }
573
574 #[test]
575 fn gif_full() {
576 let structure = InlineQueryResult::Gif(InlineQueryResultGif {
577 id: String::from("id"),
578 gif_url: Url::parse("http://gif_url/").unwrap(),
579 gif_width: Some(1),
580 gif_height: Some(1),
581 gif_duration: Some(Seconds::from_seconds(1)),
582 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
583 thumbnail_mime_type: None,
584 title: Some(String::from("title")),
585 caption: Some(String::from("caption")),
586 parse_mode: Some(ParseMode::Html),
587 caption_entities: None,
588 show_caption_above_media: false,
589 reply_markup: Some(InlineKeyboardMarkup::default()),
590 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
591 message_text: String::from("message_text"),
592 parse_mode: Some(ParseMode::MarkdownV2),
593 entities: None,
594 link_preview_options: Some(LinkPreviewOptions {
595 is_disabled: true,
596 url: None,
597 prefer_small_media: false,
598 prefer_large_media: false,
599 show_above_text: false,
600 }),
601 })),
602 });
603
604 let expected_json = r#"{"type":"gif","id":"id","gif_url":"http://gif_url/","gif_width":1,"gif_height":1,"gif_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
605 let actual_json = serde_json::to_string(&structure).unwrap();
606
607 assert_eq!(expected_json, actual_json);
608 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
609 }
610
611 #[test]
612 fn cached_mpeg4_gif_min() {
613 let structure = InlineQueryResult::CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif {
614 id: String::from("id"),
615 mpeg4_file_id: "mpeg4_file_id".into(),
616 title: None,
617 caption: None,
618 parse_mode: None,
619 caption_entities: None,
620 show_caption_above_media: false,
621 reply_markup: None,
622 input_message_content: None,
623 });
624
625 let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_file_id":"mpeg4_file_id"}"#;
626 let actual_json = serde_json::to_string(&structure).unwrap();
627
628 assert_eq!(expected_json, actual_json);
629 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
630 }
631
632 #[test]
633 fn cached_mpeg4_gif_full() {
634 let structure = InlineQueryResult::CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif {
635 id: String::from("id"),
636 mpeg4_file_id: "mpeg4_file_id".into(),
637 title: Some(String::from("title")),
638 caption: Some(String::from("caption")),
639 parse_mode: Some(ParseMode::Html),
640 caption_entities: None,
641 show_caption_above_media: false,
642 reply_markup: Some(InlineKeyboardMarkup::default()),
643 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
644 message_text: String::from("message_text"),
645 parse_mode: Some(ParseMode::MarkdownV2),
646 entities: None,
647 link_preview_options: Some(LinkPreviewOptions {
648 is_disabled: true,
649 url: None,
650 prefer_small_media: false,
651 prefer_large_media: false,
652 show_above_text: false,
653 }),
654 })),
655 });
656
657 let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_file_id":"mpeg4_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
658 let actual_json = serde_json::to_string(&structure).unwrap();
659
660 assert_eq!(expected_json, actual_json);
661 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
662 }
663
664 #[test]
665 fn mpeg4_gif_min() {
666 let structure = InlineQueryResult::Mpeg4Gif(InlineQueryResultMpeg4Gif {
667 id: String::from("id"),
668 mpeg4_url: Url::parse("http://mpeg4_url/").unwrap(),
669 mpeg4_width: None,
670 mpeg4_height: None,
671 mpeg4_duration: None,
672 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
673 thumbnail_mime_type: None,
674 title: None,
675 caption: None,
676 parse_mode: None,
677 caption_entities: None,
678 show_caption_above_media: false,
679 reply_markup: None,
680 input_message_content: None,
681 });
682
683 let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_url":"http://mpeg4_url/","thumbnail_url":"http://thumb_url/"}"#;
684 let actual_json = serde_json::to_string(&structure).unwrap();
685
686 assert_eq!(expected_json, actual_json);
687 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
688 }
689
690 #[test]
691 fn mpeg4_gif_full() {
692 let structure = InlineQueryResult::Mpeg4Gif(InlineQueryResultMpeg4Gif {
693 id: String::from("id"),
694 mpeg4_url: Url::parse("http://mpeg4_url/").unwrap(),
695 mpeg4_width: Some(1),
696 mpeg4_height: Some(1),
697 mpeg4_duration: Some(Seconds::from_seconds(1)),
698 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
699 thumbnail_mime_type: None,
700 title: Some(String::from("title")),
701 caption: Some(String::from("caption")),
702 parse_mode: Some(ParseMode::Html),
703 caption_entities: None,
704 show_caption_above_media: false,
705 reply_markup: Some(InlineKeyboardMarkup::default()),
706 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
707 message_text: String::from("message_text"),
708 parse_mode: Some(ParseMode::MarkdownV2),
709 entities: None,
710 link_preview_options: Some(LinkPreviewOptions {
711 is_disabled: true,
712 url: None,
713 prefer_small_media: false,
714 prefer_large_media: false,
715 show_above_text: false,
716 }),
717 })),
718 });
719
720 let expected_json = r#"{"type":"mpeg4_gif","id":"id","mpeg4_url":"http://mpeg4_url/","mpeg4_width":1,"mpeg4_height":1,"mpeg4_duration":1,"thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
721 let actual_json = serde_json::to_string(&structure).unwrap();
722
723 assert_eq!(expected_json, actual_json);
724 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
725 }
726
727 #[test]
728 fn cached_photo_min() {
729 let structure = InlineQueryResult::CachedPhoto(InlineQueryResultCachedPhoto {
730 id: String::from("id"),
731 photo_file_id: "photo_file_id".into(),
732 title: None,
733 description: None,
734 caption: None,
735 parse_mode: None,
736 caption_entities: None,
737 show_caption_above_media: false,
738 reply_markup: None,
739 input_message_content: None,
740 });
741
742 let expected_json = r#"{"type":"photo","id":"id","photo_file_id":"photo_file_id"}"#;
743 let actual_json = serde_json::to_string(&structure).unwrap();
744
745 assert_eq!(expected_json, actual_json);
746 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
747 }
748
749 #[test]
750 fn cached_photo_full() {
751 let structure = InlineQueryResult::CachedPhoto(InlineQueryResultCachedPhoto {
752 id: String::from("id"),
753 photo_file_id: "photo_file_id".into(),
754 title: Some(String::from("title")),
755 description: Some(String::from("description")),
756 caption: Some(String::from("caption")),
757 parse_mode: Some(ParseMode::Html),
758 caption_entities: None,
759 show_caption_above_media: false,
760 reply_markup: Some(InlineKeyboardMarkup::default()),
761 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
762 message_text: String::from("message_text"),
763 parse_mode: Some(ParseMode::MarkdownV2),
764 entities: None,
765 link_preview_options: Some(LinkPreviewOptions {
766 is_disabled: true,
767 url: None,
768 prefer_small_media: false,
769 prefer_large_media: false,
770 show_above_text: false,
771 }),
772 })),
773 });
774
775 let expected_json = r#"{"type":"photo","id":"id","photo_file_id":"photo_file_id","title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
776 let actual_json = serde_json::to_string(&structure).unwrap();
777
778 assert_eq!(expected_json, actual_json);
779 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
780 }
781
782 #[test]
783 fn photo_min() {
784 let structure = InlineQueryResult::Photo(InlineQueryResultPhoto {
785 id: String::from("id"),
786 photo_url: Url::parse("http://photo_url/").unwrap(),
787 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
788 photo_width: None,
789 photo_height: None,
790 title: None,
791 description: None,
792 caption: None,
793 parse_mode: None,
794 caption_entities: None,
795 show_caption_above_media: false,
796 reply_markup: None,
797 input_message_content: None,
798 });
799
800 let expected_json = r#"{"type":"photo","id":"id","photo_url":"http://photo_url/","thumbnail_url":"http://thumb_url/"}"#;
801 let actual_json = serde_json::to_string(&structure).unwrap();
802
803 assert_eq!(expected_json, actual_json);
804 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
805 }
806
807 #[test]
808 fn photo_full() {
809 let structure = InlineQueryResult::Photo(InlineQueryResultPhoto {
810 id: String::from("id"),
811 photo_url: Url::parse("http://photo_url/").unwrap(),
812 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
813 photo_width: Some(1),
814 photo_height: Some(1),
815 title: Some(String::from("title")),
816 description: Some(String::from("description")),
817 caption: Some(String::from("caption")),
818 parse_mode: Some(ParseMode::Html),
819 caption_entities: None,
820 show_caption_above_media: false,
821 reply_markup: Some(InlineKeyboardMarkup::default()),
822 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
823 message_text: String::from("message_text"),
824 parse_mode: Some(ParseMode::MarkdownV2),
825 entities: None,
826 link_preview_options: Some(LinkPreviewOptions {
827 is_disabled: true,
828 url: None,
829 prefer_small_media: false,
830 prefer_large_media: false,
831 show_above_text: false,
832 }),
833 })),
834 });
835
836 let expected_json = r#"{"type":"photo","id":"id","photo_url":"http://photo_url/","thumbnail_url":"http://thumb_url/","photo_width":1,"photo_height":1,"title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
837 let actual_json = serde_json::to_string(&structure).unwrap();
838
839 assert_eq!(expected_json, actual_json);
840 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
841 }
842
843 #[test]
844 fn cached_sticker_min() {
845 let structure = InlineQueryResult::CachedSticker(InlineQueryResultCachedSticker {
846 id: String::from("id"),
847 sticker_file_id: "sticker_file_id".into(),
848 reply_markup: None,
849 input_message_content: None,
850 });
851
852 let expected_json = r#"{"type":"sticker","id":"id","sticker_file_id":"sticker_file_id"}"#;
853 let actual_json = serde_json::to_string(&structure).unwrap();
854
855 assert_eq!(expected_json, actual_json);
856 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
857 }
858
859 #[test]
860 fn cached_sticker_full() {
861 let structure = InlineQueryResult::CachedSticker(InlineQueryResultCachedSticker {
862 id: String::from("id"),
863 sticker_file_id: "sticker_file_id".into(),
864 reply_markup: Some(InlineKeyboardMarkup::default()),
865 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
866 message_text: String::from("message_text"),
867 entities: None,
868 parse_mode: Some(ParseMode::MarkdownV2),
869 link_preview_options: Some(LinkPreviewOptions {
870 is_disabled: true,
871 url: None,
872 prefer_small_media: false,
873 prefer_large_media: false,
874 show_above_text: false,
875 }),
876 })),
877 });
878
879 let expected_json = r#"{"type":"sticker","id":"id","sticker_file_id":"sticker_file_id","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","link_preview_options":{"is_disabled":true}}}"#;
880 let actual_json = serde_json::to_string(&structure).unwrap();
881
882 assert_eq!(expected_json, actual_json);
883 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
884 }
885
886 #[test]
887 fn cached_video_min() {
888 let structure = InlineQueryResult::CachedVideo(InlineQueryResultCachedVideo {
889 id: String::from("id"),
890 video_file_id: "video_file_id".into(),
891 title: String::from("title"),
892 description: None,
893 caption: None,
894 parse_mode: None,
895 caption_entities: None,
896 show_caption_above_media: false,
897 reply_markup: None,
898 input_message_content: None,
899 });
900
901 let expected_json =
902 r#"{"type":"video","id":"id","video_file_id":"video_file_id","title":"title"}"#;
903 let actual_json = serde_json::to_string(&structure).unwrap();
904
905 assert_eq!(expected_json, actual_json);
906 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
907 }
908
909 #[test]
910 fn cached_video_full() {
911 let structure = InlineQueryResult::CachedVideo(InlineQueryResultCachedVideo {
912 id: String::from("id"),
913 video_file_id: "video_file_id".into(),
914 title: String::from("title"),
915 description: Some(String::from("description")),
916 caption: Some(String::from("caption")),
917 parse_mode: Some(ParseMode::Html),
918 caption_entities: None,
919 show_caption_above_media: false,
920 reply_markup: Some(InlineKeyboardMarkup::default()),
921 input_message_content: Some(InputMessageContent::Location(
922 InputMessageContentLocation {
923 latitude: 1.0,
924 longitude: 1.0,
925 horizontal_accuracy: None,
926 live_period: None,
927 heading: None,
928 proximity_alert_radius: None,
929 },
930 )),
931 });
932
933 let expected_json = r#"{"type":"video","id":"id","video_file_id":"video_file_id","title":"title","description":"description","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"latitude":1.0,"longitude":1.0}}"#;
934 let actual_json = serde_json::to_string(&structure).unwrap();
935
936 assert_eq!(expected_json, actual_json);
937 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
938 }
939
940 #[test]
941 fn video_min() {
942 let structure = InlineQueryResult::Video(InlineQueryResultVideo {
943 id: String::from("id"),
944 video_url: Url::parse("http://video_url/").unwrap(),
945 mime_type: Mime::from_str("video/mp4").unwrap(),
946 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
947 title: String::from("title"),
948 caption: None,
949 parse_mode: None,
950 caption_entities: None,
951 show_caption_above_media: false,
952 video_width: None,
953 video_height: None,
954 video_duration: None,
955 description: None,
956 reply_markup: None,
957 input_message_content: None,
958 });
959
960 let expected_json = r#"{"type":"video","id":"id","video_url":"http://video_url/","mime_type":"video/mp4","thumbnail_url":"http://thumb_url/","title":"title"}"#;
961 let actual_json = serde_json::to_string(&structure).unwrap();
962
963 assert_eq!(expected_json, actual_json);
964 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
965 }
966
967 #[test]
968 fn video_full() {
969 let structure = InlineQueryResult::Video(InlineQueryResultVideo {
970 id: String::from("id"),
971 video_url: Url::parse("http://video_url/").unwrap(),
972 mime_type: Mime::from_str("video/mp4").unwrap(),
973 thumbnail_url: Url::parse("http://thumb_url/").unwrap(),
974 title: String::from("title"),
975 caption: Some(String::from("caption")),
976 parse_mode: Some(ParseMode::Html),
977 caption_entities: None,
978 show_caption_above_media: false,
979 video_width: Some(1),
980 video_height: Some(1),
981 video_duration: Some(Seconds::from_seconds(1)),
982 description: Some(String::from("description")),
983 reply_markup: Some(InlineKeyboardMarkup::default()),
984 input_message_content: Some(InputMessageContent::Location(
985 InputMessageContentLocation {
986 latitude: 1.0,
987 longitude: 1.0,
988 horizontal_accuracy: None,
989 live_period: None,
990 heading: None,
991 proximity_alert_radius: None,
992 },
993 )),
994 });
995
996 let expected_json = r#"{"type":"video","id":"id","video_url":"http://video_url/","mime_type":"video/mp4","thumbnail_url":"http://thumb_url/","title":"title","caption":"caption","parse_mode":"HTML","video_width":1,"video_height":1,"video_duration":1,"description":"description","reply_markup":{"inline_keyboard":[]},"input_message_content":{"latitude":1.0,"longitude":1.0}}"#;
997 let actual_json = serde_json::to_string(&structure).unwrap();
998
999 assert_eq!(expected_json, actual_json);
1000 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1001 }
1002
1003 #[test]
1004 fn cached_voice_min() {
1005 let structure = InlineQueryResult::CachedVoice(InlineQueryResultCachedVoice {
1006 id: String::from("id"),
1007 voice_file_id: "voice_file_id".into(),
1008 title: String::from("title"),
1009 caption: None,
1010 parse_mode: None,
1011 caption_entities: None,
1012 reply_markup: None,
1013 input_message_content: None,
1014 });
1015
1016 let expected_json =
1017 r#"{"type":"voice","id":"id","voice_file_id":"voice_file_id","title":"title"}"#;
1018 let actual_json = serde_json::to_string(&structure).unwrap();
1019
1020 assert_eq!(expected_json, actual_json);
1021 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1022 }
1023
1024 #[test]
1025 fn cached_voice_full() {
1026 let structure = InlineQueryResult::CachedVoice(InlineQueryResultCachedVoice {
1027 id: String::from("id"),
1028 voice_file_id: "voice_file_id".into(),
1029 title: String::from("title"),
1030 caption: Some(String::from("caption")),
1031 parse_mode: Some(ParseMode::Html),
1032 caption_entities: None,
1033 reply_markup: Some(InlineKeyboardMarkup::default()),
1034 input_message_content: Some(InputMessageContent::Location(
1035 InputMessageContentLocation {
1036 latitude: 1.0,
1037 longitude: 1.0,
1038 horizontal_accuracy: None,
1039 live_period: None,
1040 heading: None,
1041 proximity_alert_radius: None,
1042 },
1043 )),
1044 });
1045
1046 let expected_json = r#"{"type":"voice","id":"id","voice_file_id":"voice_file_id","title":"title","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"latitude":1.0,"longitude":1.0}}"#;
1047 let actual_json = serde_json::to_string(&structure).unwrap();
1048
1049 assert_eq!(expected_json, actual_json);
1050 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1051 }
1052
1053 #[test]
1054 fn voice_min() {
1055 let structure = InlineQueryResult::Voice(InlineQueryResultVoice {
1056 id: String::from("id"),
1057 voice_url: Url::parse("http://voice_url/").unwrap(),
1058 title: String::from("title"),
1059 caption: None,
1060 parse_mode: None,
1061 caption_entities: None,
1062 voice_duration: None,
1063 reply_markup: None,
1064 input_message_content: None,
1065 });
1066
1067 let expected_json =
1068 r#"{"type":"voice","id":"id","voice_url":"http://voice_url/","title":"title"}"#;
1069 let actual_json = serde_json::to_string(&structure).unwrap();
1070
1071 assert_eq!(expected_json, actual_json);
1072 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1073 }
1074
1075 #[test]
1076 fn voice_full() {
1077 let structure = InlineQueryResult::Voice(InlineQueryResultVoice {
1078 id: String::from("id"),
1079 voice_url: Url::parse("http://voice_url/").unwrap(),
1080 title: String::from("title"),
1081 caption: Some(String::from("caption")),
1082 parse_mode: Some(ParseMode::Html),
1083 caption_entities: None,
1084 voice_duration: Some(Seconds::from_seconds(1)),
1085 reply_markup: Some(InlineKeyboardMarkup::default()),
1086 input_message_content: Some(InputMessageContent::Location(
1087 InputMessageContentLocation {
1088 latitude: 1.0,
1089 longitude: 1.0,
1090 horizontal_accuracy: None,
1091 live_period: None,
1092 heading: None,
1093 proximity_alert_radius: None,
1094 },
1095 )),
1096 });
1097
1098 let expected_json = r#"{"type":"voice","id":"id","voice_url":"http://voice_url/","title":"title","caption":"caption","parse_mode":"HTML","voice_duration":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"latitude":1.0,"longitude":1.0}}"#;
1099 let actual_json = serde_json::to_string(&structure).unwrap();
1100
1101 assert_eq!(expected_json, actual_json);
1102 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1103 }
1104
1105 #[test]
1106 fn article_min() {
1107 let structure = InlineQueryResult::Article(InlineQueryResultArticle {
1108 id: String::from("id"),
1109 title: String::from("title"),
1110 input_message_content: InputMessageContent::Text(InputMessageContentText {
1111 message_text: String::from("message_text"),
1112 entities: None,
1113 link_preview_options: Some(LinkPreviewOptions {
1114 is_disabled: true,
1115 url: None,
1116 prefer_small_media: false,
1117 prefer_large_media: false,
1118 show_above_text: false,
1119 }),
1120 parse_mode: None,
1121 }),
1122 reply_markup: None,
1123 url: None,
1124 description: None,
1125 thumbnail_url: None,
1126 thumbnail_width: None,
1127 thumbnail_height: None,
1128 });
1129
1130 let expected_json = r#"{"type":"article","id":"id","title":"title","input_message_content":{"message_text":"message_text","link_preview_options":{"is_disabled":true}}}"#;
1131 let actual_json = serde_json::to_string(&structure).unwrap();
1132
1133 assert_eq!(expected_json, actual_json);
1134 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1135 }
1136
1137 #[test]
1138 fn article_full() {
1139 let structure = InlineQueryResult::Article(InlineQueryResultArticle {
1140 id: String::from("id"),
1141 title: String::from("title"),
1142 input_message_content: InputMessageContent::Text(InputMessageContentText {
1143 message_text: String::from("message_text"),
1144 entities: None,
1145 parse_mode: None,
1146 link_preview_options: Some(LinkPreviewOptions {
1147 is_disabled: true,
1148 url: None,
1149 prefer_small_media: false,
1150 prefer_large_media: false,
1151 show_above_text: false,
1152 }),
1153 }),
1154 reply_markup: Some(InlineKeyboardMarkup::default()),
1155 url: Some(Url::parse("http://url/").unwrap()),
1156 description: Some(String::from("description")),
1157 thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
1158 thumbnail_width: Some(1),
1159 thumbnail_height: Some(1),
1160 });
1161
1162 let expected_json = r#"{"type":"article","id":"id","title":"title","input_message_content":{"message_text":"message_text","link_preview_options":{"is_disabled":true}},"reply_markup":{"inline_keyboard":[]},"url":"http://url/","description":"description","thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
1163 let actual_json = serde_json::to_string(&structure).unwrap();
1164
1165 assert_eq!(expected_json, actual_json);
1166 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1167 }
1168
1169 #[test]
1170 fn contact_min() {
1171 let structure = InlineQueryResult::Contact(InlineQueryResultContact {
1172 id: String::from("id"),
1173 phone_number: String::from("phone_number"),
1174 first_name: String::from("first_name"),
1175 last_name: None,
1176 vcard: None,
1177 reply_markup: None,
1178 input_message_content: None,
1179 thumbnail_url: None,
1180 thumbnail_width: None,
1181 thumbnail_height: None,
1182 });
1183
1184 let expected_json = r#"{"type":"contact","id":"id","phone_number":"phone_number","first_name":"first_name"}"#;
1185 let actual_json = serde_json::to_string(&structure).unwrap();
1186
1187 assert_eq!(expected_json, actual_json);
1188 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1189 }
1190
1191 #[test]
1192 fn contact_full() {
1193 let structure = InlineQueryResult::Contact(InlineQueryResultContact {
1194 id: String::from("id"),
1195 phone_number: String::from("phone_number"),
1196 first_name: String::from("first_name"),
1197 last_name: Some(String::from("last_name")),
1198 vcard: Some(String::from("vcard")),
1199 reply_markup: Some(InlineKeyboardMarkup::default()),
1200 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
1201 message_text: String::from("message_text"),
1202 entities: None,
1203 parse_mode: None,
1204 link_preview_options: Some(LinkPreviewOptions {
1205 is_disabled: true,
1206 url: None,
1207 prefer_small_media: false,
1208 prefer_large_media: false,
1209 show_above_text: false,
1210 }),
1211 })),
1212 thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
1213 thumbnail_width: Some(1),
1214 thumbnail_height: Some(1),
1215 });
1216
1217 let expected_json = r#"{"type":"contact","id":"id","phone_number":"phone_number","first_name":"first_name","last_name":"last_name","vcard":"vcard","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","link_preview_options":{"is_disabled":true}},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
1218 let actual_json = serde_json::to_string(&structure).unwrap();
1219
1220 assert_eq!(expected_json, actual_json);
1221 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1222 }
1223
1224 #[test]
1225 fn game_min() {
1226 let structure = InlineQueryResult::Game(InlineQueryResultGame {
1227 id: String::from("id"),
1228 game_short_name: String::from("game_short_name"),
1229 reply_markup: None,
1230 });
1231
1232 let expected_json = r#"{"type":"game","id":"id","game_short_name":"game_short_name"}"#;
1233 let actual_json = serde_json::to_string(&structure).unwrap();
1234
1235 assert_eq!(expected_json, actual_json);
1236 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1237 }
1238
1239 #[test]
1240 fn game_full() {
1241 let structure = InlineQueryResult::Game(InlineQueryResultGame {
1242 id: String::from("id"),
1243 game_short_name: String::from("game_short_name"),
1244 reply_markup: Some(InlineKeyboardMarkup::default()),
1245 });
1246
1247 let expected_json = r#"{"type":"game","id":"id","game_short_name":"game_short_name","reply_markup":{"inline_keyboard":[]}}"#;
1248 let actual_json = serde_json::to_string(&structure).unwrap();
1249
1250 assert_eq!(expected_json, actual_json);
1251 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1252 }
1253
1254 #[test]
1255 fn location_min() {
1256 let structure = InlineQueryResult::Location(InlineQueryResultLocation {
1257 id: String::from("id"),
1258 latitude: 1.0,
1259 longitude: 1.0,
1260 title: String::from("title"),
1261 horizontal_accuracy: None,
1262 live_period: None,
1263 heading: None,
1264 proximity_alert_radius: None,
1265 reply_markup: None,
1266 input_message_content: None,
1267 thumbnail_url: None,
1268 thumbnail_width: None,
1269 thumbnail_height: None,
1270 });
1271
1272 let expected_json =
1273 r#"{"type":"location","id":"id","latitude":1.0,"longitude":1.0,"title":"title"}"#;
1274 let actual_json = serde_json::to_string(&structure).unwrap();
1275
1276 assert_eq!(expected_json, actual_json);
1277 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1278 }
1279
1280 #[test]
1281 fn location_full() {
1282 let structure = InlineQueryResult::Location(InlineQueryResultLocation {
1283 id: String::from("id"),
1284 latitude: 1.0,
1285 longitude: 1.0,
1286 title: String::from("title"),
1287 horizontal_accuracy: Some(1.0),
1288 live_period: Some(1.into()),
1289 heading: Some(1),
1290 proximity_alert_radius: Some(1),
1291 reply_markup: Some(InlineKeyboardMarkup::default()),
1292 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
1293 message_text: String::from("message_text"),
1294 entities: None,
1295 parse_mode: None,
1296 link_preview_options: Some(LinkPreviewOptions {
1297 is_disabled: true,
1298 url: None,
1299 prefer_small_media: false,
1300 prefer_large_media: false,
1301 show_above_text: false,
1302 }),
1303 })),
1304 thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
1305 thumbnail_width: Some(1),
1306 thumbnail_height: Some(1),
1307 });
1308
1309 let expected_json = r#"{"type":"location","id":"id","latitude":1.0,"longitude":1.0,"title":"title","horizontal_accuracy":1.0,"live_period":1,"heading":1,"proximity_alert_radius":1,"reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","link_preview_options":{"is_disabled":true}},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
1310 let actual_json = serde_json::to_string(&structure).unwrap();
1311
1312 assert_eq!(expected_json, actual_json);
1313 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1314 }
1315
1316 #[test]
1317 fn venue_min() {
1318 let structure = InlineQueryResult::Venue(InlineQueryResultVenue {
1319 id: String::from("id"),
1320 latitude: 1.0,
1321 longitude: 1.0,
1322 title: String::from("title"),
1323 address: String::from("address"),
1324 foursquare_id: None,
1325 foursquare_type: None,
1326 google_place_id: None,
1327 google_place_type: None,
1328 reply_markup: None,
1329 input_message_content: None,
1330 thumbnail_url: None,
1331 thumbnail_width: None,
1332 thumbnail_height: None,
1333 });
1334
1335 let expected_json = r#"{"type":"venue","id":"id","latitude":1.0,"longitude":1.0,"title":"title","address":"address"}"#;
1336 let actual_json = serde_json::to_string(&structure).unwrap();
1337
1338 assert_eq!(expected_json, actual_json);
1339 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1340 }
1341
1342 #[test]
1343 fn venue_full() {
1344 let structure = InlineQueryResult::Venue(InlineQueryResultVenue {
1345 id: String::from("id"),
1346 latitude: 1.0,
1347 longitude: 1.0,
1348 title: String::from("title"),
1349 address: String::from("address"),
1350 foursquare_id: Some(String::from("foursquare_id")),
1351 foursquare_type: Some(String::from("foursquare_type")),
1352 google_place_id: Some(String::from("google_place_id")),
1353 google_place_type: Some(String::from("google_place_type")),
1354 reply_markup: Some(InlineKeyboardMarkup::default()),
1355 input_message_content: Some(InputMessageContent::Text(InputMessageContentText {
1356 message_text: String::from("message_text"),
1357 entities: None,
1358 parse_mode: None,
1359 link_preview_options: Some(LinkPreviewOptions {
1360 is_disabled: true,
1361 url: None,
1362 prefer_small_media: false,
1363 prefer_large_media: false,
1364 show_above_text: false,
1365 }),
1366 })),
1367 thumbnail_url: Some(Url::parse("http://thumb_url/").unwrap()),
1368 thumbnail_width: Some(1),
1369 thumbnail_height: Some(1),
1370 });
1371
1372 let expected_json = r#"{"type":"venue","id":"id","latitude":1.0,"longitude":1.0,"title":"title","address":"address","foursquare_id":"foursquare_id","foursquare_type":"foursquare_type","google_place_id":"google_place_id","google_place_type":"google_place_type","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","link_preview_options":{"is_disabled":true}},"thumbnail_url":"http://thumb_url/","thumbnail_width":1,"thumbnail_height":1}"#;
1373 let actual_json = serde_json::to_string(&structure).unwrap();
1374
1375 assert_eq!(expected_json, actual_json);
1376 assert_eq!(structure, serde_json::from_str(&actual_json).unwrap());
1377 }
1378}