From 9b1aa8375341e9d93027eb098f20297bf95dcad1 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Mon, 27 Jul 2020 20:28:16 +0600 Subject: [PATCH] Add setters to InlineQueryResultLocation --- src/types/inline_query_result_location.rs | 80 +++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/types/inline_query_result_location.rs b/src/types/inline_query_result_location.rs index fdaf5784..1d6d9270 100644 --- a/src/types/inline_query_result_location.rs +++ b/src/types/inline_query_result_location.rs @@ -46,3 +46,83 @@ pub struct InlineQueryResultLocation { /// Thumbnail height. pub thumb_height: Option, } + +impl InlineQueryResultLocation { + pub fn new(id: S1, title: S2, latitude: f64, longitude: f64) -> Self + where + S1: Into, + S2: Into, + { + Self { + id: id.into(), + title: title.into(), + latitude, + longitude, + live_period: None, + reply_markup: None, + input_message_content: None, + thumb_url: None, + thumb_width: None, + thumb_height: None, + } + } + + pub fn id(mut self, val: S) -> Self + where + S: Into, + { + self.id = val.into(); + self + } + + pub fn latitude(mut self, val: f64) -> Self { + self.latitude = val; + self + } + + pub fn longitude(mut self, val: f64) -> Self { + self.longitude = val; + self + } + + pub fn title(mut self, val: S) -> Self + where + S: Into, + { + self.title = val.into(); + self + } + + pub fn live_period(mut self, val: i32) -> Self { + self.live_period = Some(val); + self + } + + pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self { + self.reply_markup = Some(val); + self + } + + pub fn input_message_content(mut self, val: InputMessageContent) -> Self { + self.input_message_content = Some(val); + self + } + + pub fn thumb_url(mut self, val: S) -> Self + where + S: Into, + { + self.thumb_url = Some(val.into()); + self + } + + pub fn thumb_width(mut self, val: i32) -> Self { + self.thumb_width = Some(val); + self + } + + pub fn thumb_height(mut self, val: i32) -> Self { + self.thumb_height = Some(val); + self + } +}