diff --git a/src/core/requests/send_venue.rs b/src/core/requests/send_venue.rs index deac9b61..4b3010b6 100644 --- a/src/core/requests/send_venue.rs +++ b/src/core/requests/send_venue.rs @@ -1,4 +1,8 @@ -use crate::core::requests::{ChatId, RequestContext}; +use crate::core::network; +use crate::core::requests::{ + ChatId, Request, RequestContext, RequestFuture, ResponseResult, +}; +use crate::core::types::{Message, ReplyMarkup}; //TODO:: need implementation ///Use this method to send information about a venue. On success, the sent @@ -9,35 +13,139 @@ struct SendVenue<'a> { 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, + pub chat_id: ChatId, /// Float number Yes Latitude of the venue - latitude: f64, + pub latitude: f64, ///Float number Yes Longitude of the venue - longitude: f64, + pub longitude: f64, /// Yes Name of the venue - title: String, + pub title: String, ///String Yes Address of the venue - address: String, + pub address: String, /// String Optional Foursquare identifier of the venue #[serde(skip_serializing_if = "Option::is_none")] - foursquare_id: Option, + pub 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, + pub 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, + pub 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, + pub 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 + pub reply_markup: Option, +} + +impl<'a> Request<'a> for SendVenue<'a> { + type ReturnValue = Message; + + fn send(self) -> RequestFuture<'a, ResponseResult> { + Box::pin(async move { + network::request_json( + &self.ctx.client, + &self.ctx.token, + "sendVenue", + Some(&self), + ) + .await + }) + } +} + +impl<'a> SendVenue<'a> { + pub fn new( + ctx: RequestContext<'a>, + chat_id: ChatId, + latitude: f64, + longitude: f64, + title: String, + address: String, + ) -> Self { + Self { + ctx, + chat_id, + latitude, + longitude, + title, + address, + foursquare_id: None, + foursquare_type: None, + disable_notification: None, + reply_to_message_id: None, + reply_markup: None, + } + } + pub fn chat_id(mut self, chat_id: T) -> Self + where + T: Into, + { + self.chat_id = chat_id.into(); + self + } + + pub fn longitude(mut self, longitude: T) -> Self + where + T: Into, + { + self.longitude = longitude.into(); + self + } + + pub fn latitude(mut self, latitude: T) -> Self + where + T: Into, + { + self.latitude = latitude.into(); + self + } + + pub fn title(mut self, title: T) -> Self + where + T: Into, + { + self.title = title.into(); + self + } + + pub fn address(mut self, address: T) -> Self + where + T: Into, + { + self.address = address.into(); + self + } + + pub fn foursquare_id(mut self, foursquare_id: T) -> Self + where + T: Into, + { + self.foursquare_id = Some(foursquare_id.into()); + self + } + + pub fn disable_notification(mut self, disable_notification: T) -> Self + where + T: Into, + { + self.disable_notification = Some(disable_notification.into()); + self + } + + pub fn foursquare_type(mut self, foursquare_type: T) -> Self + where + T: Into, + { + self.foursquare_type = Some(foursquare_type.into()); + self + } }