-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot API 8.0 - Gifts #237
Bot API 8.0 - Gifts #237
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1335,6 +1335,20 @@ pub struct InputSticker { | |
pub keywords: Option<Vec<String>>, | ||
} | ||
|
||
#[apply(apistruct!)] | ||
pub struct Gift { | ||
pub id: String, | ||
pub stricker: Sticker, | ||
pub star_count: u32, | ||
pub total_count: Option<u32>, | ||
pub remaining_count: Option<u32>, | ||
} | ||
|
||
#[apply(apistruct!)] | ||
pub struct Gifts { | ||
pub gifts: Vec<Gift>, | ||
} | ||
|
||
#[apply(apistruct!)] | ||
#[derive(Eq)] | ||
pub struct Story { | ||
|
@@ -2238,23 +2252,24 @@ pub struct RevenueWithdrawalStateSucceeded { | |
#[derive(Eq)] | ||
pub struct RevenueWithdrawalStateFailed {} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it not using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's enum. this macro is not applicable for enums |
||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] | ||
#[serde(tag = "type", rename_all = "snake_case")] | ||
pub enum TransactionPartner { | ||
User(TransactionPartnerUser), | ||
User(Box<TransactionPartnerUser>), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a warning from clippy that one of the variants is too large |
||
Fragment(TransactionPartnerFragment), | ||
TelegramAds(TransactionPartnerTelegramAds), | ||
TelegramApi(TransactionPartnerTelegramApi), | ||
Other(TransactionPartnerOther), | ||
} | ||
|
||
#[apply(apistruct!)] | ||
#[derive(Eq)] | ||
pub struct TransactionPartnerUser { | ||
pub user: User, | ||
pub invoice_payload: Option<String>, | ||
pub subscription_period: Option<u32>, | ||
pub paid_media: Option<Vec<PaidMedia>>, | ||
pub paid_media_payload: Option<String>, | ||
pub gift: Option<Gift>, | ||
} | ||
|
||
#[apply(apistruct!)] | ||
|
@@ -2278,7 +2293,6 @@ pub struct TransactionPartnerTelegramApi { | |
pub struct TransactionPartnerOther {} | ||
|
||
#[apply(apistruct!)] | ||
#[derive(Eq)] | ||
pxp9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub struct StarTransaction { | ||
pub id: String, | ||
pub amount: u32, | ||
|
@@ -2288,7 +2302,6 @@ pub struct StarTransaction { | |
} | ||
|
||
#[apply(apistruct!)] | ||
#[derive(Eq)] | ||
pxp9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub struct StarTransactions { | ||
pub transactions: Vec<StarTransaction>, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is an empty Vec simpler than None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to be loyal to the Telegram API spec.
https://core.telegram.org/bots/api#sendgift
According to the spec this parameter is optional.
If we use empty vec may be simpler but it will be telling the library user that this parameter is required which is not true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question is will it be able to decode as empty list if the field is not provided. for now I will merge as Option. but @EdJoPaTo you're free to submit pr changng that