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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
pub enum APIEndpoint {
GetUpdates,
GetMe,
LogOut,
Close,
SendMessage,
SetMyCommands,
GetMyCommands,
ForwardMessage,
CopyMessage,
SendPhoto,
SendAudio,
SendDocument,
SendVideo,
SendAnimation,
SendVoice,
SendVideoNote,
SendMediaGroup,
SendLocation,
EditMessageLiveLocation,
StopMessageLiveLocation,
SendVenue,
SendContact,
SendPoll,
SendDice,
SendChatAction,
GetUserProfilePhotos,
GetFile,
KickChatMember,
UnbanChatMember,
RestrictChatMember,
PromoteChatMember,
SetChatAdministratorCustomTitle,
SetChatPermissions,
ExportChatInviteLink,
CreateChatInviteLink,
EditChatInviteLink,
RevokeChatInviteLink,
SetChatPhoto,
DeleteChatPhoto,
SetChatTitle,
SetChatDescription,
PinChatMessage,
UnpinChatMessage,
UnpinAllChatMessages,
LeaveChat,
GetChat,
GetChatAdministrators,
GetChatMembersCount,
GetChatMember,
SetChatStickerSet,
DeleteChatStickerSet,
AnswerCallbackQuery,
EditMessageText,
EditMessageCaption,
EditMessageMedia,
EditMessageReplyMarkup,
StopPoll,
DeleteMessage,
SendSticker,
GetStickerSet,
UploadStickerFile,
CreateNewStickerSet,
AddStickerToSet,
SetStickerPositionInSet,
DeleteStickerFromSet,
SetStickerSetThumb,
AnswerInlineQuery,
SendInvoice,
AnswerShippingQuery,
AnswerPreCheckoutQuery,
SendGame,
SetGameScore,
GetGameHighScores,
SetWebhook,
SetPassportDataErrors,
DeleteWebhook,
GetWebhookInfo,
Other(String),
}
impl APIEndpoint {
pub fn as_str(&self) -> &str {
match *self {
Self::GetUpdates => "getUpdates",
Self::GetMe => "getMe",
Self::LogOut => "logOut",
Self::Close => "close",
Self::SendMessage => "sendMessage",
Self::SetMyCommands => "setMyCommands",
Self::GetMyCommands => "getMyCommands",
Self::CopyMessage => "copyMessage",
Self::ForwardMessage => "forwardMessage",
Self::SendPhoto => "sendPhoto",
Self::SendAudio => "sendAudio",
Self::SendDocument => "sendDocument",
Self::SendVideo => "sendVideo",
Self::SendAnimation => "sendAnimation",
Self::SendVoice => "sendVoice",
Self::SendVideoNote => "sendVideoNote",
Self::SendMediaGroup => "sendMediaGroup",
Self::SendLocation => "sendLocation",
Self::EditMessageLiveLocation => "editMessageLiveLocation",
Self::StopMessageLiveLocation => "stopMessageLiveLocation",
Self::SendVenue => "sendVenue",
Self::SendContact => "sendContact",
Self::SendPoll => "sendPoll",
Self::SendDice => "sendDice",
Self::SendChatAction => "sendChatAction",
Self::GetUserProfilePhotos => "getUserProfilePhotos",
Self::GetFile => "getFile",
Self::KickChatMember => "kickChatMember",
Self::UnbanChatMember => "unbanChatMember",
Self::RestrictChatMember => "restrictChatMember",
Self::PromoteChatMember => "promoteChatMember",
Self::SetChatAdministratorCustomTitle => "setChatAdministratorCustomTitle",
Self::SetChatPermissions => "setChatPermissions",
Self::ExportChatInviteLink => "exportChatInviteLink",
Self::CreateChatInviteLink => "createChatInviteLink",
Self::EditChatInviteLink => "editChatInviteLink",
Self::RevokeChatInviteLink => "revokeChatInviteLink",
Self::SetChatPhoto => "setChatPhoto",
Self::DeleteChatPhoto => "deleteChatPhoto",
Self::SetChatTitle => "setChatTitle",
Self::SetChatDescription => "setChatDescription",
Self::PinChatMessage => "pinChatMessage",
Self::UnpinChatMessage => "unpinChatMessage",
Self::UnpinAllChatMessages => "unpinAllChatMessages",
Self::LeaveChat => "leaveChat",
Self::GetChat => "getChat",
Self::GetChatAdministrators => "getChatAdministrators",
Self::GetChatMembersCount => "getChatMembersCount",
Self::GetChatMember => "getChatMember",
Self::SetChatStickerSet => "setChatStickerSet",
Self::DeleteChatStickerSet => "deleteChatStickerSet",
Self::AnswerCallbackQuery => "answerCallbackQuery",
Self::EditMessageText => "editMessageText",
Self::EditMessageCaption => "editMessageCaption",
Self::EditMessageMedia => "editMessageMedia",
Self::EditMessageReplyMarkup => "editMessageReplyMarkup",
Self::StopPoll => "stopPoll",
Self::DeleteMessage => "deleteMessage",
Self::SendSticker => "sendSticker",
Self::GetStickerSet => "getStickerSet",
Self::UploadStickerFile => "uploadStickerFile",
Self::CreateNewStickerSet => "createNewStickerSet",
Self::AddStickerToSet => "addStickerToSet",
Self::SetStickerPositionInSet => "setStickerPositionInSet",
Self::DeleteStickerFromSet => "deleteStickerFromSet",
Self::SetStickerSetThumb => "setStickerSetThumb",
Self::AnswerInlineQuery => "answerInlineQuery",
Self::SendGame => "sendGame",
Self::SetGameScore => "setGameScore",
Self::GetGameHighScores => "getGameHighScores",
Self::SendInvoice => "sendInvoice",
Self::AnswerShippingQuery => "answerShippingQuery",
Self::AnswerPreCheckoutQuery => "answerPreCheckoutQuery",
Self::SetWebhook => "setWebHook",
Self::SetPassportDataErrors => "setPassportDataErrors",
Self::DeleteWebhook => "deleteWebhook",
Self::GetWebhookInfo => "getWebhookInfo",
Self::Other(ref e) => e,
}
}
}
impl std::fmt::Display for APIEndpoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl std::fmt::Debug for APIEndpoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("telegram::APIEndpoint")
.field(&self.as_str().to_owned())
.finish()
}
}
impl From<String> for APIEndpoint {
fn from(string: String) -> APIEndpoint {
APIEndpoint::Other(string)
}
}