1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use crate::{
methods::method::*,
types::{ChatId, Float, Integer, Message, ReplyMarkup},
};
use failure::Error;
use serde::Serialize;
#[derive(Clone, Debug, Serialize)]
pub struct SendLocation {
chat_id: ChatId,
latitude: Float,
longitude: Float,
#[serde(skip_serializing_if = "Option::is_none")]
live_period: Option<Integer>,
#[serde(skip_serializing_if = "Option::is_none")]
disable_notification: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
reply_to_message_id: Option<Integer>,
#[serde(skip_serializing_if = "Option::is_none")]
reply_markup: Option<ReplyMarkup>,
}
impl SendLocation {
pub fn new<C: Into<ChatId>>(chat_id: C, latitude: Float, longitude: Float) -> Self {
SendLocation {
chat_id: chat_id.into(),
latitude,
longitude,
live_period: None,
disable_notification: None,
reply_to_message_id: None,
reply_markup: None,
}
}
pub fn live_period(mut self, live_period: Integer) -> Self {
self.live_period = Some(live_period);
self
}
pub fn disable_notification(mut self, disable_notification: bool) -> Self {
self.disable_notification = Some(disable_notification);
self
}
pub fn reply_to_message_id(mut self, reply_to_message_id: Integer) -> Self {
self.reply_to_message_id = Some(reply_to_message_id);
self
}
pub fn reply_markup<R: Into<ReplyMarkup>>(mut self, reply_markup: R) -> Self {
self.reply_markup = Some(reply_markup.into());
self
}
}
impl Method for SendLocation {
type Response = Message;
fn get_request(&self) -> Result<RequestBuilder, Error> {
RequestBuilder::json("sendLocation", &self)
}
}