Use BusinessConnectionId instead of String for business_connection_id fields and parameters

This commit is contained in:
Akshett Rai Jindal 2024-08-22 23:47:20 +05:30
parent ccc2c68751
commit 2f8e62f401
28 changed files with 143 additions and 75 deletions

View file

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `title`, `username` and `photo` fields to `ChatShared` struct
- Add `format` field to `InputSticker` struct
- Add `format` parameter to `SetStickerSetThumbnail` method
- Add `BusinessConnectionId` struct
- Add `business_connection_id` parameter to `SendMessage`, `SendPhoto`, `SendVideo`, `SendAnimation`, `SendAudio`, `SendDocument`, `SendSticker`, `SendVideoNote`, `SendVoice`, `SendLocation`, `SendVenue`, `SendContact`, `SendPoll`, `SendDice`, `SendGame`, and `SendMediaGroup` methods
- Add `sender_business_bot` and `business_connection_id` fields to `Message` struct
- Add `BusinessIntro` struct and corresponding field `business_intro` to `ChatPrivate` struct

View file

@ -226,7 +226,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -527,7 +527,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -617,7 +617,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -722,7 +722,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -820,7 +820,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -936,7 +936,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1050,7 +1050,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1135,7 +1135,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1218,7 +1218,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1268,7 +1268,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1536,7 +1536,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1635,7 +1635,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1714,7 +1714,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1833,7 +1833,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -1894,7 +1894,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the action will be sent"),
),
Param(
@ -3061,7 +3061,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: String,
ty: RawTy("BusinessConnectionId"),
descr: Doc(md: "Unique identifier of the business connection"),
),
],
@ -3728,7 +3728,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(
@ -4490,7 +4490,7 @@ Schema(
params: [
Param(
name: "business_connection_id",
ty: Option(String),
ty: Option(RawTy("BusinessConnectionId")),
descr: Doc(md: "Unique identifier of the business connection on behalf of which the message will be sent"),
),
Param(

View file

@ -754,7 +754,7 @@ trait ErasableRequester<'a> {
fn get_business_connection(
&self,
business_connection_id: String,
business_connection_id: BusinessConnectionId,
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err>;
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>;
@ -1619,7 +1619,7 @@ where
fn get_business_connection(
&self,
business_connection_id: String,
business_connection_id: BusinessConnectionId,
) -> ErasedRequest<'a, GetBusinessConnection, Self::Err> {
Requester::get_business_connection(self, business_connection_id).erase()
}

View file

@ -5,8 +5,9 @@ use crate::{
prelude::Requester,
requests::{JsonRequest, MultipartRequest},
types::{
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId, UserId,
BotCommand, BusinessConnectionId, ChatId, ChatPermissions, InlineQueryResult, InputFile,
InputMedia, InputSticker, LabeledPrice, MessageId, Recipient, StickerFormat, ThreadId,
UserId,
},
Bot,
};
@ -883,10 +884,10 @@ impl Requester for Bot {
type GetBusinessConnection = JsonRequest<payloads::GetBusinessConnection>;
fn get_business_connection<B>(&self, business_connection_id: B) -> Self::GetBusinessConnection
where
B: Into<String>,
{
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> Self::GetBusinessConnection {
Self::GetBusinessConnection::new(
self.clone(),
payloads::GetBusinessConnection::new(business_connection_id),

View file

@ -1072,9 +1072,9 @@ macro_rules! requester_forward {
(@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> {
fn get_business_connection(&self, business_connection_id: BusinessConnectionId) -> Self::GetBusinessConnection {
let this = self;
$body!(get_business_connection this (business_connection_id: BCI))
$body!(get_business_connection this (business_connection_id: BusinessConnectionId))
}
};
(@method get_my_commands $body:ident $ty:ident) => {

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::BusinessConnection;
use crate::types::{BusinessConnection, BusinessConnectionId};
impl_payload! {
/// Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
@ -10,7 +10,7 @@ impl_payload! {
pub GetBusinessConnection (GetBusinessConnectionSetters) => BusinessConnection {
required {
/// Unique identifier of the business connection
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
}
}
}

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -23,7 +24,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the animation in seconds

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -26,7 +27,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Audio caption, 0-1024 characters after entities parsing

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{ChatAction, Recipient, ThreadId, True};
use crate::types::{BusinessConnectionId, ChatAction, Recipient, ThreadId, True};
impl_payload! {
/// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
@ -31,7 +31,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the action will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread; supergroups only
pub message_thread_id: ThreadId,
}

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send phone contacts. On success, the sent [`Message`] is returned.
@ -20,7 +22,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Contact's last name

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{DiceEmoji, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, DiceEmoji, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned.
@ -16,7 +18,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -23,7 +24,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. [More info on Sending Files »]

View file

@ -2,7 +2,7 @@
use serde::Serialize;
use crate::types::{ChatId, Message, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{BusinessConnectionId, ChatId, Message, ReplyMarkup, ReplyParameters, ThreadId};
impl_payload! {
/// Use this method to send a game. On success, the sent [`Message`] is returned.
@ -18,7 +18,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Sends the message [silently]. Users will receive a notification with no sound.

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send point on the map. On success, the sent [`Message`] is returned.
@ -20,7 +22,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// The radius of uncertainty for the location, measured in meters; 0-1500

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{InputMedia, Message, Recipient, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputMedia, Message, Recipient, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Message`]s that were sent is returned.
@ -27,7 +29,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Sends the message [silently]. Users will receive a notification with no sound.

View file

@ -3,8 +3,8 @@
use serde::Serialize;
use crate::types::{
LinkPreviewOptions, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters,
ThreadId,
BusinessConnectionId, LinkPreviewOptions, Message, MessageEntity, ParseMode, Recipient,
ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@ -21,7 +21,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Mode for parsing entities in the message text. See [formatting options] for more details.

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -23,7 +24,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing

View file

@ -4,7 +4,8 @@ use chrono::{DateTime, Utc};
use serde::Serialize;
use crate::types::{
Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -23,7 +24,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// True, if the poll needs to be anonymous, defaults to True

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@[multipart = sticker]
@ -21,7 +23,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Emoji associated with the sticker; only for just uploaded stickers

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
/// Use this method to send information about a venue. On success, the sent [`Message`] is returned.
@ -24,7 +26,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Foursquare identifier of the venue

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -24,7 +25,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the video in seconds

View file

@ -2,7 +2,9 @@
use serde::Serialize;
use crate::types::{InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId};
use crate::types::{
BusinessConnectionId, InputFile, Message, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
};
impl_payload! {
@[multipart = video_note, thumbnail]
@ -22,7 +24,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Duration of the video in seconds

View file

@ -3,7 +3,8 @@
use serde::Serialize;
use crate::types::{
InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup, ReplyParameters, ThreadId,
BusinessConnectionId, InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup,
ReplyParameters, ThreadId,
};
impl_payload! {
@ -25,7 +26,7 @@ impl_payload! {
}
optional {
/// Unique identifier of the business connection on behalf of which the message will be sent
pub business_connection_id: String [into],
pub business_connection_id: BusinessConnectionId,
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
pub message_thread_id: ThreadId,
/// Voice message caption, 0-1024 characters after entities parsing

View file

@ -834,9 +834,10 @@ pub trait Requester {
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>;
fn get_business_connection(
&self,
business_connection_id: BusinessConnectionId,
) -> Self::GetBusinessConnection;
type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;

View file

@ -10,6 +10,7 @@ pub use bot_description::*;
pub use bot_name::*;
pub use bot_short_description::*;
pub use business_connection::*;
pub use business_connection_id::*;
pub use business_intro::*;
pub use business_location::*;
pub use business_messages_deleted::*;
@ -171,6 +172,7 @@ mod bot_description;
mod bot_name;
mod bot_short_description;
mod business_connection;
mod business_connection_id;
mod business_intro;
mod business_location;
mod business_messages_deleted;

View file

@ -0,0 +1,42 @@
use serde::{Deserialize, Serialize};
/// A unique business connection identifier.
#[derive(Default, Clone, Debug, derive_more::Display, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(from = "BusinessConnectionIdRaw", into = "BusinessConnectionIdRaw")]
pub struct BusinessConnectionId(pub String);
#[derive(Serialize, Deserialize)]
struct BusinessConnectionIdRaw {
business_connection_id: String,
}
impl From<BusinessConnectionIdRaw> for BusinessConnectionId {
fn from(BusinessConnectionIdRaw { business_connection_id }: BusinessConnectionIdRaw) -> Self {
BusinessConnectionId(business_connection_id)
}
}
impl From<BusinessConnectionId> for BusinessConnectionIdRaw {
fn from(BusinessConnectionId(business_connection_id): BusinessConnectionId) -> Self {
BusinessConnectionIdRaw { business_connection_id }
}
}
#[cfg(test)]
mod tests {
use crate::types::BusinessConnectionId;
#[test]
fn business_connection_id_deser() {
let json = r#"{"business_connection_id": "abcd1234"}"#;
let bcid: BusinessConnectionId = serde_json::from_str(json).unwrap();
assert_eq!(bcid, BusinessConnectionId(String::from("abcd1234")));
}
#[test]
fn business_connection_id_ser() {
let bcid: BusinessConnectionId = BusinessConnectionId(String::from("abcd1234"));
let json = serde_json::to_string(&bcid).unwrap();
assert_eq!(json, r#"{"business_connection_id":"abcd1234"}"#);
}
}

View file

@ -1,13 +1,13 @@
use serde::{Deserialize, Serialize};
use crate::types::{Chat, MessageId};
use crate::types::{BusinessConnectionId, Chat, MessageId};
/// This object is received when messages are deleted from a connected business
/// account.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BusinessMessagesDeleted {
/// Unique identifier of the business connection.
pub business_connection_id: String,
pub business_connection_id: BusinessConnectionId,
/// Information about a chat in the business account. The bot may not have
/// access to the chat or the corresponding user.

View file

@ -5,10 +5,10 @@ use serde::{Deserialize, Serialize};
use url::Url;
use crate::types::{
Animation, Audio, BareChatId, Chat, ChatBoostAdded, ChatId, ChatShared, Contact, Dice,
Document, ExternalReplyInfo, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited,
ForumTopicReopened, Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden, Giveaway,
GiveawayCompleted, GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice,
Animation, Audio, BareChatId, BusinessConnectionId, Chat, ChatBoostAdded, ChatId, ChatShared,
Contact, Dice, Document, ExternalReplyInfo, ForumTopicClosed, ForumTopicCreated,
ForumTopicEdited, ForumTopicReopened, Game, GeneralForumTopicHidden, GeneralForumTopicUnhidden,
Giveaway, GiveawayCompleted, GiveawayCreated, GiveawayWinners, InlineKeyboardMarkup, Invoice,
LinkPreviewOptions, Location, MaybeInaccessibleMessage, MessageAutoDeleteTimerChanged,
MessageEntity, MessageEntityRef, MessageId, MessageOrigin, PassportData, PhotoSize, Poll,
ProximityAlertTriggered, Sticker, Story, SuccessfulPayment, TextQuote, ThreadId, True, User,
@ -63,7 +63,7 @@ pub struct Message {
/// received. If non-empty, the message belongs to a chat of the
/// corresponding business account that is independent from any potential
/// bot chat which might share the same identifier.
pub business_connection_id: Option<String>,
pub business_connection_id: Option<BusinessConnectionId>,
#[serde(flatten)]
pub kind: MessageKind,