telegram_bot_async_raw/requests/
get_chat.rs

1use crate::{requests::*, types::*};
2
3/// Use this method to get up to date information about the chat.
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
5#[must_use = "requests do nothing unless sent"]
6pub struct GetChat {
7    chat_id: ChatRef,
8}
9
10impl Request for GetChat {
11    type Type = JsonRequestType<Self>;
12    type Response = JsonIdResponse<Chat>;
13
14    fn serialize(&self) -> Result<HttpRequest, Error> {
15        Self::Type::serialize(RequestUrl::method("getChat"), self)
16    }
17}
18
19impl GetChat {
20    pub fn new<C>(chat: C) -> Self
21    where
22        C: ToChatRef,
23    {
24        GetChat {
25            chat_id: chat.to_chat_ref(),
26        }
27    }
28}
29
30/// Get up to date information about the chat.
31pub trait CanGetChat {
32    fn get_chat(&self) -> GetChat;
33}
34
35impl<C> CanGetChat for C
36where
37    C: ToChatRef,
38{
39    fn get_chat(&self) -> GetChat {
40        GetChat::new(self)
41    }
42}