Add UserChatBoosts struct

This commit is contained in:
Andrey Brusnik 2024-07-19 19:06:55 +04:00
parent dbf138a5b3
commit 48b7c7b24b
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
2 changed files with 45 additions and 0 deletions

View file

@ -132,6 +132,7 @@ pub use unit_false::*;
pub use unit_true::*;
pub use update::*;
pub use user::*;
pub use user_chat_boosts::*;
pub use user_profile_photos::*;
pub use users_shared::*;
pub use venue::*;
@ -252,6 +253,7 @@ mod unit_false;
mod unit_true;
mod update;
mod user;
mod user_chat_boosts;
mod user_profile_photos;
mod users_shared;
mod venue;

View file

@ -0,0 +1,43 @@
use serde::{Deserialize, Serialize};
use crate::types::ChatBoost;
/// This object represents a list of boosts added to a chat by a user.
#[serde_with::skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UserChatBoosts {
/// The list of boosts added to the chat by the user.
pub boosts: Vec<ChatBoost>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn deserialize() {
let data = r#"
{
"boosts": [
{
"boost_id": "4506e1b7e866e33fcbde78fe1746ec3a",
"add_date": 1721399621,
"expiration_date": 1745088963,
"source": {
"source": "premium",
"user": {
"id": 1459074222,
"is_bot": false,
"first_name": "shadowchain",
"username": "shdwchn10",
"language_code": "en",
"is_premium": true
}
}
}
]
}
"#;
serde_json::from_str::<UserChatBoosts>(data).unwrap();
}
}