mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Add method getBusinessConnection
This commit is contained in:
parent
7fe9278ce8
commit
68b7aba836
13 changed files with 127 additions and 19 deletions
|
@ -3052,6 +3052,20 @@ Schema(
|
|||
),
|
||||
],
|
||||
),
|
||||
Method(
|
||||
names: ("getBusinessConnection", "GetBusinessConnection", "get_business_connection"),
|
||||
return_ty: RawTy("BusinessConnection"),
|
||||
doc: Doc(md: "Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success."),
|
||||
tg_doc: "https://core.telegram.org/bots/api#getbusinessconnection",
|
||||
tg_category: "Available methods",
|
||||
params: [
|
||||
Param(
|
||||
name: "business_connection_id",
|
||||
ty: String,
|
||||
descr: Doc(md: "Unique identifier of the business connection"),
|
||||
),
|
||||
],
|
||||
),
|
||||
Method(
|
||||
names: ("getMyCommands", "GetMyCommands", "get_my_commands"),
|
||||
return_ty: ArrayOf(RawTy("BotCommand")),
|
||||
|
|
|
@ -163,6 +163,7 @@ where
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
|
|
@ -262,6 +262,7 @@ where
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
@ -751,6 +752,11 @@ trait ErasableRequester<'a> {
|
|||
commands: Vec<BotCommand>,
|
||||
) -> ErasedRequest<'a, SetMyCommands, Self::Err>;
|
||||
|
||||
fn get_business_connection(
|
||||
&self,
|
||||
business_connection_id: String,
|
||||
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err>;
|
||||
|
||||
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>;
|
||||
|
||||
fn set_my_name(&self) -> ErasedRequest<'a, SetMyName, Self::Err>;
|
||||
|
@ -1603,6 +1609,13 @@ where
|
|||
Requester::set_my_commands(self, commands).erase()
|
||||
}
|
||||
|
||||
fn get_business_connection(
|
||||
&self,
|
||||
business_connection_id: String,
|
||||
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err> {
|
||||
Requester::get_business_connection(self, business_connection_id).erase()
|
||||
}
|
||||
|
||||
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err> {
|
||||
Requester::get_my_commands(self).erase()
|
||||
}
|
||||
|
|
|
@ -244,6 +244,7 @@ where
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
|
|
@ -146,6 +146,7 @@ where
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
|
|
@ -192,6 +192,7 @@ where
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
|
|
@ -881,6 +881,18 @@ impl Requester for Bot {
|
|||
Self::SetMyCommands::new(self.clone(), payloads::SetMyCommands::new(commands))
|
||||
}
|
||||
|
||||
type GetBusinessConnection = JsonRequest<payloads::GetBusinessConnection>;
|
||||
|
||||
fn get_business_connection<B>(&self, business_connection_id: B) -> Self::GetBusinessConnection
|
||||
where
|
||||
B: Into<String>,
|
||||
{
|
||||
Self::GetBusinessConnection::new(
|
||||
self.clone(),
|
||||
payloads::GetBusinessConnection::new(business_connection_id),
|
||||
)
|
||||
}
|
||||
|
||||
type GetMyCommands = JsonRequest<payloads::GetMyCommands>;
|
||||
|
||||
fn get_my_commands(&self) -> Self::GetMyCommands {
|
||||
|
|
|
@ -1069,6 +1069,14 @@ macro_rules! requester_forward {
|
|||
$body!(set_my_commands this (commands: C))
|
||||
}
|
||||
};
|
||||
(@method get_business_connection $body:ident $ty:ident) => {
|
||||
type GetBusinessConnection = $ty![GetBusinessConnection];
|
||||
|
||||
fn get_business_connection<BCI>(&self, business_connection_id: BCI) -> Self::GetBusinessConnection where BCI: Into<String> {
|
||||
let this = self;
|
||||
$body!(get_business_connection this (business_connection_id: BCI))
|
||||
}
|
||||
};
|
||||
(@method get_my_commands $body:ident $ty:ident) => {
|
||||
type GetMyCommands = $ty![GetMyCommands];
|
||||
|
||||
|
@ -1524,7 +1532,7 @@ fn codegen_requester_forward() {
|
|||
|
||||
convert_params.sort_unstable();
|
||||
|
||||
let prefixes: IndexMap<_, _> = convert_params
|
||||
let mut prefixes: IndexMap<_, _> = convert_params
|
||||
.iter()
|
||||
.copied()
|
||||
// Workaround to output the last type as the first letter
|
||||
|
@ -1533,6 +1541,18 @@ fn codegen_requester_forward() {
|
|||
.map(|(l, r)| (l, min_prefix(l, r)))
|
||||
.collect();
|
||||
|
||||
// FIXME: This hard-coded value has been set to avoid conflicting generic
|
||||
// parameter 'B' with impl<B> Requester... in all the adaptors and other places
|
||||
//
|
||||
// One fix could be to take full abbrevation for all the parameters instead of
|
||||
// just the first character. Other fix is to change the generic parameter name
|
||||
// in all the impl blocks to something like 'Z' because that is very less likely
|
||||
// to conflict in future.
|
||||
if prefixes.contains_key("business_connection_id") {
|
||||
prefixes["business_connection_id"] = "BCI";
|
||||
}
|
||||
let prefixes = prefixes;
|
||||
|
||||
let args = m
|
||||
.params
|
||||
.iter()
|
||||
|
|
|
@ -59,6 +59,7 @@ mod edit_message_text_inline;
|
|||
mod export_chat_invite_link;
|
||||
mod forward_message;
|
||||
mod forward_messages;
|
||||
mod get_business_connection;
|
||||
mod get_chat;
|
||||
mod get_chat_administrators;
|
||||
mod get_chat_member;
|
||||
|
@ -193,6 +194,7 @@ pub use edit_message_text_inline::{EditMessageTextInline, EditMessageTextInlineS
|
|||
pub use export_chat_invite_link::{ExportChatInviteLink, ExportChatInviteLinkSetters};
|
||||
pub use forward_message::{ForwardMessage, ForwardMessageSetters};
|
||||
pub use forward_messages::{ForwardMessages, ForwardMessagesSetters};
|
||||
pub use get_business_connection::{GetBusinessConnection, GetBusinessConnectionSetters};
|
||||
pub use get_chat::{GetChat, GetChatSetters};
|
||||
pub use get_chat_administrators::{GetChatAdministrators, GetChatAdministratorsSetters};
|
||||
pub use get_chat_member::{GetChatMember, GetChatMemberSetters};
|
||||
|
|
16
crates/teloxide-core/src/payloads/get_business_connection.rs
Normal file
16
crates/teloxide-core/src/payloads/get_business_connection.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
//! Generated by `codegen_payloads`, do not edit by hand.
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::BusinessConnection;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
|
||||
pub GetBusinessConnection (GetBusinessConnectionSetters) => BusinessConnection {
|
||||
required {
|
||||
/// Unique identifier of the business connection
|
||||
pub business_connection_id: String [into],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,20 +19,21 @@ pub use crate::payloads::{
|
|||
EditMessageReplyMarkupInlineSetters as _, EditMessageReplyMarkupSetters as _,
|
||||
EditMessageTextInlineSetters as _, EditMessageTextSetters as _,
|
||||
ExportChatInviteLinkSetters as _, ForwardMessageSetters as _, ForwardMessagesSetters as _,
|
||||
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
|
||||
GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _,
|
||||
GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _,
|
||||
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
|
||||
GetMyDefaultAdministratorRightsSetters as _, GetMyDescriptionSetters as _,
|
||||
GetMyNameSetters as _, GetMyShortDescriptionSetters as _, GetStickerSetSetters as _,
|
||||
GetUpdatesSetters as _, GetUserChatBoostsSetters as _, GetUserProfilePhotosSetters as _,
|
||||
GetWebhookInfoSetters as _, HideGeneralForumTopicSetters as _, KickChatMemberSetters as _,
|
||||
LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _,
|
||||
PromoteChatMemberSetters as _, ReopenForumTopicSetters as _,
|
||||
ReopenGeneralForumTopicSetters as _, ReplaceStickerInSetSetters as _,
|
||||
RestrictChatMemberSetters as _, RevokeChatInviteLinkSetters as _, SendAnimationSetters as _,
|
||||
SendAudioSetters as _, SendChatActionSetters as _, SendContactSetters as _,
|
||||
SendDiceSetters as _, SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,
|
||||
GetBusinessConnectionSetters as _, GetChatAdministratorsSetters as _,
|
||||
GetChatMemberCountSetters as _, GetChatMemberSetters as _, GetChatMembersCountSetters as _,
|
||||
GetChatMenuButtonSetters as _, GetChatSetters as _, GetCustomEmojiStickersSetters as _,
|
||||
GetFileSetters as _, GetForumTopicIconStickersSetters as _, GetGameHighScoresSetters as _,
|
||||
GetMeSetters as _, GetMyCommandsSetters as _, GetMyDefaultAdministratorRightsSetters as _,
|
||||
GetMyDescriptionSetters as _, GetMyNameSetters as _, GetMyShortDescriptionSetters as _,
|
||||
GetStickerSetSetters as _, GetUpdatesSetters as _, GetUserChatBoostsSetters as _,
|
||||
GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _,
|
||||
HideGeneralForumTopicSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _,
|
||||
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _,
|
||||
ReopenForumTopicSetters as _, ReopenGeneralForumTopicSetters as _,
|
||||
ReplaceStickerInSetSetters as _, RestrictChatMemberSetters as _,
|
||||
RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _,
|
||||
SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _,
|
||||
SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,
|
||||
SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _,
|
||||
SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _,
|
||||
SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _,
|
||||
|
|
|
@ -831,6 +831,13 @@ pub trait Requester {
|
|||
where
|
||||
C: IntoIterator<Item = BotCommand>;
|
||||
|
||||
type GetBusinessConnection: Request<Payload = GetBusinessConnection, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetBusinessConnection`].
|
||||
fn get_business_connection<B>(&self, business_connection_id: B) -> Self::GetBusinessConnection
|
||||
where
|
||||
B: Into<String>;
|
||||
|
||||
type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetMyCommands`].
|
||||
|
@ -1386,6 +1393,7 @@ macro_rules! forward_all {
|
|||
answer_callback_query,
|
||||
get_user_chat_boosts,
|
||||
set_my_commands,
|
||||
get_business_connection,
|
||||
get_my_commands,
|
||||
set_my_name,
|
||||
get_my_name,
|
||||
|
|
|
@ -168,10 +168,28 @@ mod tests {
|
|||
for update in allowed_updates_reference {
|
||||
match update {
|
||||
// CAUTION: Don't forget to add new `UpdateKind` to `allowed_updates_reference`!
|
||||
Message | EditedMessage | ChannelPost | EditedChannelPost | MessageReaction
|
||||
| MessageReactionCount | InlineQuery | ChosenInlineResult | CallbackQuery
|
||||
| ShippingQuery | PreCheckoutQuery | Poll | PollAnswer | MyChatMember
|
||||
| ChatMember | ChatJoinRequest | ChatBoost | RemovedChatBoost => {
|
||||
Message
|
||||
| EditedMessage
|
||||
| ChannelPost
|
||||
| EditedChannelPost
|
||||
| MessageReaction
|
||||
| MessageReactionCount
|
||||
| InlineQuery
|
||||
| ChosenInlineResult
|
||||
| CallbackQuery
|
||||
| ShippingQuery
|
||||
| PreCheckoutQuery
|
||||
| Poll
|
||||
| PollAnswer
|
||||
| MyChatMember
|
||||
| ChatMember
|
||||
| ChatJoinRequest
|
||||
| ChatBoost
|
||||
| RemovedChatBoost
|
||||
| BusinessMessage
|
||||
| BusinessConnection
|
||||
| EditedBusinessMessage
|
||||
| DeletedBusinessMessages => {
|
||||
assert!(full_set.contains(&Kind(update)))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue