telegram_bot_raw/requests/
get_chat_member.rs1use crate::requests::*;
2use crate::types::*;
3
4#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
6#[must_use = "requests do nothing unless sent"]
7pub struct GetChatMember {
8 chat_id: ChatRef,
9 user_id: UserId,
10}
11
12impl Request for GetChatMember {
13 type Type = JsonRequestType<Self>;
14 type Response = JsonIdResponse<ChatMember>;
15
16 fn serialize(&self) -> Result<HttpRequest, Error> {
17 Self::Type::serialize(RequestUrl::method("getChatMember"), self)
18 }
19}
20
21impl GetChatMember {
22 pub fn new<C, U>(chat: C, user: U) -> Self
23 where
24 C: ToChatRef,
25 U: ToUserId,
26 {
27 GetChatMember {
28 chat_id: chat.to_chat_ref(),
29 user_id: user.to_user_id(),
30 }
31 }
32}
33
34pub trait CanGetChatMemberForChat {
36 fn get_member<O>(&self, other: O) -> GetChatMember
37 where
38 O: ToUserId;
39}
40
41impl<C> CanGetChatMemberForChat for C
42where
43 C: ToChatRef,
44{
45 fn get_member<O>(&self, other: O) -> GetChatMember
46 where
47 O: ToUserId,
48 {
49 GetChatMember::new(self, other)
50 }
51}
52
53pub trait CanGetChatMemberForUser {
55 fn get_member_from<O>(&self, other: O) -> GetChatMember
56 where
57 O: ToChatRef;
58}
59
60impl<U> CanGetChatMemberForUser for U
61where
62 U: ToUserId,
63{
64 fn get_member_from<O>(&self, other: O) -> GetChatMember
65 where
66 O: ToChatRef,
67 {
68 GetChatMember::new(other, self)
69 }
70}