diff --git a/src/core/network/mod.rs b/src/core/network/mod.rs index 35561c40..da42bd36 100644 --- a/src/core/network/mod.rs +++ b/src/core/network/mod.rs @@ -40,11 +40,9 @@ pub async fn request( ) -> ResponseResult { let mut response = client .post(&method_url(TELEGRAM_API_URL, token, method_name)) - .apply(|request_builder| { - params.map_or_else( - || request_builder, - |params| request_builder.multipart(params), - ) + .apply(|request_builder| match params { + Some(params) => request_builder.multipart(params), + None => request_builder, }) .send() .compat() diff --git a/src/core/requests/get_me.rs b/src/core/requests/get_me.rs index 87a20e85..5f5a14fe 100644 --- a/src/core/requests/get_me.rs +++ b/src/core/requests/get_me.rs @@ -1,5 +1,6 @@ -use crate::core::requests::ResponseResult; -use crate::core::{network::request, network::request, types::User}; +use crate::core::network; +use crate::core::requests::{Request, RequestFuture, RequestInfo, ResponseResult}; +use crate::core::types::User; #[derive(Debug, Constructor)] pub struct GetMe { @@ -10,6 +11,8 @@ impl Request for GetMe { type ReturnValue = User; fn send(self) -> RequestFuture> { - Box::new(async move { request(&self.info.client, &self.info.token, "getMe", None).await }) + Box::new(async move { + network::request(&self.info.client, &self.info.token, "getMe", None).await + }) } } diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index 5d4b4414..e767d32a 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -1,5 +1,6 @@ -use crate::core::requests::ResponseResult; -use crate::core::{network::request, network::request, types::Message}; +use crate::core::requests::form_builder::FormBuilder; +use crate::core::requests::{ChatId, Request, RequestFuture, RequestInfo, ResponseResult}; +use crate::core::{network, types::Message}; #[derive(Debug, TypedBuilder)] pub struct SendMessage { @@ -37,7 +38,7 @@ impl Request for SendMessage { .add_if_some("reply_to_message_id", self.reply_to_message_id.as_ref()) .build(); - request( + network::request( &self.info.client, &self.info.token, "sendMessage",