Fix a few things and format the code

This commit is contained in:
Temirkhan Myrzamadi 2019-09-03 13:04:07 +06:00
parent 47d56c7ddd
commit 23b94bab01
2 changed files with 18 additions and 7 deletions

View file

@ -9,6 +9,11 @@ where
{
value.map_or_else(
|| form,
|value| form.text(name.to_owned(), serde_json::to_string(value).expect("Failed to serialize a value to JSON")),
|value| {
form.text(
name.to_owned(),
serde_json::to_string(value).expect("serde_json::to_string failed"),
)
},
)
}

View file

@ -32,18 +32,24 @@ impl Request for SendMessage {
}
fn params(self) -> Option<Form> {
let params = Form::new()
.text("chat_id", format!("{}", self.chat_id))
.text("chat_id", serde_json::to_string(&self.chat_id).unwrap())
.text("text", self.text);
let params = helpers::add_to_form_if_some(params, "parse_mode",self.parse_mode.as_ref());
let params = helpers::add_to_form_if_some(params, "parse_mode", self.parse_mode.as_ref());
let params = helpers::add_to_form_if_some(
params,
"disable_web_page_preview",
self.disable_web_page_preview.as_ref(),
);
let params =
helpers::add_to_form_if_some(params, "disable_notification", self.disable_notification.as_ref());
let params =
helpers::add_to_form_if_some(params, "reply_to_message_id", self.reply_to_message_id.as_ref());
let params = helpers::add_to_form_if_some(
params,
"disable_notification",
self.disable_notification.as_ref(),
);
let params = helpers::add_to_form_if_some(
params,
"reply_to_message_id",
self.reply_to_message_id.as_ref(),
);
// TODO:
// helpers::add_to_form_if_some(