From 1891976650bee19811e162b07e61aa4c3e0f9cce Mon Sep 17 00:00:00 2001 From: P0lunin Date: Tue, 3 Sep 2019 10:55:29 +0300 Subject: [PATCH] add struct --- src/core/types/chosen_inline_result.rs | 11 +++++ src/core/types/input_message_content.rs | 55 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/core/types/chosen_inline_result.rs create mode 100644 src/core/types/input_message_content.rs diff --git a/src/core/types/chosen_inline_result.rs b/src/core/types/chosen_inline_result.rs new file mode 100644 index 00000000..bd479fa5 --- /dev/null +++ b/src/core/types/chosen_inline_result.rs @@ -0,0 +1,11 @@ +use serde::Deserialize; +use crate::core::types::user::User; + +#[derive(Debug, Deserealize)] +pub struct ChosenInlineResult { + pub result_id: String, + pub from: User, + pub location: Option, + pub inline_message_id: Option, + pub query: String, +} diff --git a/src/core/types/input_message_content.rs b/src/core/types/input_message_content.rs new file mode 100644 index 00000000..14e4b142 --- /dev/null +++ b/src/core/types/input_message_content.rs @@ -0,0 +1,55 @@ +use serde::Serialize; +use crate::core::parse_mode::ParseMode; + +pub enum InputMessageContent { + Text(InputTextMessageContent), + Location(InputLocationMessageContent), + Venue(InputVenueMessageContent), + Contact(InputContactMessageContent), +} + +#[derive(Debug, Serialize)] +pub struct InputTextMessageContent { + pub message_text: String, + + #[serde(skip_serializing_if = "Option::is_none")] + pub parse_mode: Option, + + #[serde(skip_serializing_if = "Not::not")] + pub disable_web_page_preview: bool, +} + +#[derive(Debug, Serialize)] +pub struct InputLocationMessageContent { + pub latitude: f64, + pub longitude: f64, + + #[serde(skip_serializing_if = "Option::is_none")] + pub live_period: Option // should be between 60 and 86400 +} + +#[derive(Debug, Serialize)] +pub struct InputVenueMessageContent { + pub latitude: f64, + pub longitude: f64, + pub title: String, + pub address: String, + + #[serde(skip_serializing_if = "Option::is_none")] + pub foursquare_id: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub foursquare_type: Option, +} + +#[derive(Debug, Serialize)] +pub struct InputContactMessageContent { + pub phone_number: String, + pub first_name: String, + + #[serde(skip_serializing_if = "Option::is_none")] + pub last_name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub vcard: Option, +}