From 278f9690b74d588b4c3d73cd314f5568c86314ef Mon Sep 17 00:00:00 2001 From: nextel Date: Thu, 12 Sep 2019 20:33:28 +0300 Subject: [PATCH] add sendVenue --- src/core/requests/get_file.rs | 9 +++- src/core/requests/get_user_profile_photos.rs | 9 +++- src/core/requests/kick_chat_member.rs | 10 +++- src/core/requests/restrict_chat_member.rs | 9 +++- src/core/requests/send_chat_action.rs | 9 +++- src/core/requests/send_contact.rs | 9 +++- src/core/requests/send_poll.rs | 9 +++- src/core/requests/send_venue.rs | 46 ++++++++++++++++++- .../requests/stop_message_live_location.rs | 5 +- src/core/requests/unban_chat_member.rs | 9 +++- 10 files changed, 104 insertions(+), 20 deletions(-) diff --git a/src/core/requests/get_file.rs b/src/core/requests/get_file.rs index e74ecbb5..496368b4 100644 --- a/src/core/requests/get_file.rs +++ b/src/core/requests/get_file.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct GetFile<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct GetFile<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/get_user_profile_photos.rs b/src/core/requests/get_user_profile_photos.rs index 857e3534..2cffec70 100644 --- a/src/core/requests/get_user_profile_photos.rs +++ b/src/core/requests/get_user_profile_photos.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct GetUserProfilePhotos<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct GetUserProfilePhotos<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/kick_chat_member.rs b/src/core/requests/kick_chat_member.rs index 636f7a9a..f8d757fc 100644 --- a/src/core/requests/kick_chat_member.rs +++ b/src/core/requests/kick_chat_member.rs @@ -1,2 +1,8 @@ -//TODO: need implementation -struct KickChatMember<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct KickChatMember<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, + +} diff --git a/src/core/requests/restrict_chat_member.rs b/src/core/requests/restrict_chat_member.rs index 18412edb..34a4bd7c 100644 --- a/src/core/requests/restrict_chat_member.rs +++ b/src/core/requests/restrict_chat_member.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct RestrictChatMember<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct RestrictChatMember<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/send_chat_action.rs b/src/core/requests/send_chat_action.rs index ce266097..aee6fd0a 100644 --- a/src/core/requests/send_chat_action.rs +++ b/src/core/requests/send_chat_action.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct SendChatAction<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct SendChatAction<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/send_contact.rs b/src/core/requests/send_contact.rs index 7c90da4c..959e7b11 100644 --- a/src/core/requests/send_contact.rs +++ b/src/core/requests/send_contact.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct SendContact<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct SendContact<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/send_poll.rs b/src/core/requests/send_poll.rs index a4eb62b5..f1f1752e 100644 --- a/src/core/requests/send_poll.rs +++ b/src/core/requests/send_poll.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct SendPoll<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct SendPoll<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +} diff --git a/src/core/requests/send_venue.rs b/src/core/requests/send_venue.rs index 6a24952a..3b11a734 100644 --- a/src/core/requests/send_venue.rs +++ b/src/core/requests/send_venue.rs @@ -1,2 +1,44 @@ -//TODO:need implementation -struct SendVenue<'a> {} +use crate::core::requests::{ChatId, RequestContext}; + +///Use this method to send information about a venue. On success, the sent +/// Message is returned. +#[derive(Debug, Clone, Serialize)] +struct SendVenue<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, + /// Integer or String Yes Unique identifier for the target chat or + /// username of the target channel (in the format @channelusername) + chat_id: ChatId, + /// Float number Yes Latitude of the venue + latitude: f64, + ///Float number Yes Longitude of the venue + longitude: f64, + /// Yes Name of the venue + title: String, + ///String Yes Address of the venue + address: String, + /// String Optional Foursquare identifier of the venue + #[serde(skip_serializing_if = "Option::is_none")] + foursquare_id: Option, + /// String Optional Foursquare type of the venue, if known. (For + /// example, “arts_entertainment/default”, “arts_entertainment/aquarium” or + /// “food/icecream”.) + #[serde(skip_serializing_if = "Option::is_none")] + foursquare_type: Option, + /// Boolean Optional Sends the message silently. Users will receive a + /// notification with no sound. + #[serde(skip_serializing_if = "Option::is_none")] + disable_notification: Option, + /// Integer Optional If the message is a reply, ID of the original + /// message + #[serde(skip_serializing_if = "Option::is_none")] + reply_to_message_id: Option, + /// InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or + /// ForceReply Optional Additional interface options. A JSON-serialized + /// object for an inline keyboard, custom reply keyboard, instructions to + /// remove reply keyboard or to force a reply from the user. + #[serde(skip_serializing_if = "Option::is_none")] + reply_markup: Option<()>, //TODO: need concrete type +} + + diff --git a/src/core/requests/stop_message_live_location.rs b/src/core/requests/stop_message_live_location.rs index e102635e..2598f4bf 100644 --- a/src/core/requests/stop_message_live_location.rs +++ b/src/core/requests/stop_message_live_location.rs @@ -14,6 +14,7 @@ use crate::core::{ /// returned, otherwise True is returned. #[derive(Debug, Clone, Serialize)] struct StopMessageLiveLocation<'a> { + #[serde(skip_serializing)] ctx: RequestContext<'a>, /// Required if inline_message_id is not specified. Unique identifier for /// the target chat or username of the target channel (in the format @@ -65,7 +66,7 @@ impl<'a> StopMessageLiveLocation<'a> { where T: Into, { - self.chat_id = chat_id.into(); + self.chat_id = Some(chat_id.into()); self } @@ -89,7 +90,7 @@ impl<'a> StopMessageLiveLocation<'a> { where T: Into, { - self.inline_message_id = Some(reply_markup.into()); + self.reply_markup = Some(reply_markup.into()); self } } diff --git a/src/core/requests/unban_chat_member.rs b/src/core/requests/unban_chat_member.rs index 9a99d4a3..a07a6086 100644 --- a/src/core/requests/unban_chat_member.rs +++ b/src/core/requests/unban_chat_member.rs @@ -1,2 +1,7 @@ -//TODO: need implementation -struct UnbanChatMember<'a> {} +use crate::core::requests::RequestContext; + +#[derive(Debug, Clone, Serialize)] +struct UnbanChatMember<'a> { + #[serde(skip_serializing)] + ctx: RequestContext<'a>, +}