From 16c9f716aa5def5f0a3e44c21df9f8a2f45f5a83 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 5 Dec 2024 07:44:22 +0000 Subject: [PATCH] feat(schema): update TDLib to the latest layer --- _schema/tdapi.tl | 333 +- tdapi/tl_affiliate_info_gen.go | 263 + tdapi/tl_affiliate_program_info_gen.go | 263 + tdapi/tl_affiliate_program_parameters_gen.go | 228 + tdapi/tl_affiliate_program_sort_order_gen.go | 577 ++ tdapi/tl_bot_info_gen.go | 194 +- tdapi/tl_bot_transaction_purpose_gen.go | 852 --- tdapi/tl_chat_affiliate_program_gen.go | 398 ++ tdapi/tl_chat_affiliate_programs_gen.go | 289 + tdapi/tl_chat_transaction_purpose_gen.go | 933 --- .../tl_connect_chat_affiliate_program_gen.go | 239 + tdapi/tl_create_video_chat_gen.go | 3 +- ...l_disconnect_chat_affiliate_program_gen.go | 237 + tdapi/tl_file_type_gen.go | 584 ++ tdapi/tl_found_affiliate_program_gen.go | 227 + tdapi/tl_found_affiliate_programs_gen.go | 289 + tdapi/tl_get_chat_affiliate_program_gen.go | 239 + tdapi/tl_get_chat_affiliate_programs_gen.go | 274 + tdapi/tl_get_owned_bots_gen.go | 169 + tdapi/tl_internal_link_type_gen.go | 215 + tdapi/tl_registry_gen.go | 288 +- tdapi/tl_search_affiliate_programs_gen.go | 318 + tdapi/tl_search_chat_affiliate_program_gen.go | 237 + tdapi/tl_search_stickers_gen.go | 171 +- tdapi/tl_set_chat_affiliate_program_gen.go | 239 + tdapi/tl_star_amount_gen.go | 227 + tdapi/tl_star_revenue_status_gen.go | 148 +- tdapi/tl_star_subscriptions_gen.go | 78 +- tdapi/tl_star_transaction_gen.go | 118 +- tdapi/tl_star_transaction_partner_gen.go | 2166 ------- tdapi/tl_star_transaction_type_gen.go | 5531 +++++++++++++++++ tdapi/tl_star_transactions_gen.go | 74 +- tdapi/tl_update_gen.go | 66 +- tdapi/tl_user_transaction_purpose_gen.go | 682 -- 34 files changed, 11980 insertions(+), 5169 deletions(-) create mode 100644 tdapi/tl_affiliate_info_gen.go create mode 100644 tdapi/tl_affiliate_program_info_gen.go create mode 100644 tdapi/tl_affiliate_program_parameters_gen.go create mode 100644 tdapi/tl_affiliate_program_sort_order_gen.go delete mode 100644 tdapi/tl_bot_transaction_purpose_gen.go create mode 100644 tdapi/tl_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_chat_affiliate_programs_gen.go delete mode 100644 tdapi/tl_chat_transaction_purpose_gen.go create mode 100644 tdapi/tl_connect_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_disconnect_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_found_affiliate_program_gen.go create mode 100644 tdapi/tl_found_affiliate_programs_gen.go create mode 100644 tdapi/tl_get_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_get_chat_affiliate_programs_gen.go create mode 100644 tdapi/tl_get_owned_bots_gen.go create mode 100644 tdapi/tl_search_affiliate_programs_gen.go create mode 100644 tdapi/tl_search_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_set_chat_affiliate_program_gen.go create mode 100644 tdapi/tl_star_amount_gen.go delete mode 100644 tdapi/tl_star_transaction_partner_gen.go create mode 100644 tdapi/tl_star_transaction_type_gen.go delete mode 100644 tdapi/tl_user_transaction_purpose_gen.go diff --git a/_schema/tdapi.tl b/_schema/tdapi.tl index f4db946ce9..c157fd5237 100644 --- a/_schema/tdapi.tl +++ b/_schema/tdapi.tl @@ -1,7 +1,7 @@ // Code generated by ./cmd/dltl, DO NOT EDIT. // // Source: https://raw.githubusercontent.com/tdlib/td/master/td/generate/scheme/td_api.tl -// SHA256: 0fcb92aaada422c71a42f164ed2442828a83f00df27e87f78f0ca9a5de34a9bb +// SHA256: 9f8a1f4b86142b42e249caf673b963ee9b7b24d64c9c87ce1ed6d86bedb116b9 double#2210c154 ? = Double; @@ -821,6 +821,11 @@ chatPermissions#f8f25a79 can_send_basic_messages:Bool can_send_audios:Bool can_s //@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only chatAdministratorRights#5f4f9044 can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_manage_topics:Bool can_promote_members:Bool can_manage_video_chats:Bool can_post_stories:Bool can_edit_stories:Bool can_delete_stories:Bool is_anonymous:Bool = ChatAdministratorRights; +//@description Describes a possibly non-integer amount of Telegram Stars +//@star_count The integer amount of Telegram Stars rounded to 0 +//@nanostar_count The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999 +starAmount#6f0e6d80 star_count:int53 nanostar_count:int32 = StarAmount; + //@class StarSubscriptionType @description Describes type of subscription paid in Telegram Stars //@description Describes a subscription to a channel chat @@ -851,11 +856,66 @@ starSubscriptionPricing#96a28856 period:int32 star_count:int53 = StarSubscriptio starSubscription#3a3811f5 id:string chat_id:int53 expiration_date:int32 is_canceled:Bool is_expiring:Bool pricing:starSubscriptionPricing type:StarSubscriptionType = StarSubscription; //@description Represents a list of Telegram Star subscriptions -//@star_count The amount of owned Telegram Stars +//@star_amount The amount of owned Telegram Stars //@subscriptions List of subscriptions for Telegram Stars //@required_star_count The number of Telegram Stars required to buy to extend subscriptions expiring soon //@next_offset The offset for the next request. If empty, then there are no more results -starSubscriptions#f7a7ae44 star_count:int53 subscriptions:vector required_star_count:int53 next_offset:string = StarSubscriptions; +starSubscriptions#a2f27c8d star_amount:starAmount subscriptions:vector required_star_count:int53 next_offset:string = StarSubscriptions; + +//@class AffiliateProgramSortOrder @description Describes the order of the found affiliate programs + +//@description The affiliate programs must be sorted by the profitability +affiliateProgramSortOrderProfitability#8afaaf67 = AffiliateProgramSortOrder; + +//@description The affiliate programs must be sorted by creation date +affiliateProgramSortOrderCreationDate#a319390d = AffiliateProgramSortOrder; + +//@description The affiliate programs must be sorted by the expected revenue +affiliateProgramSortOrderRevenue#72a2c2b8 = AffiliateProgramSortOrder; + +//@description Describes parameters of an affiliate program +//@commission_per_mille The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the program owner; +//@month_count Number of months the program will be active; 0-36. If 0, then the program is eternal +affiliateProgramParameters#61e90c54 commission_per_mille:int32 month_count:int32 = AffiliateProgramParameters; + +//@description Contains information about an active affiliate program +//@parameters Parameters of the affiliate program +//@end_date Point in time (Unix timestamp) when the affiliate program will be closed; 0 if the affiliate program isn't scheduled to be closed. +//@daily_revenue_per_user_amount The amount of daily revenue per user in Telegram Stars of the bot that created the affiliate program +affiliateProgramInfo#96fce8b5 parameters:affiliateProgramParameters end_date:int32 daily_revenue_per_user_amount:starAmount = AffiliateProgramInfo; + +//@description Contains information about an affiliate that received commission from a Telegram Star transaction +//@commission_per_mille The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the program owner +//@affiliate_chat_id Identifier of the chat which received the commission +//@star_amount The amount of Telegram Stars that were received by the affiliate; can be negative for refunds +affiliateInfo#b1c1dcfa commission_per_mille:int32 affiliate_chat_id:int53 star_amount:starAmount = AffiliateInfo; + +//@description Describes a found affiliate program +//@bot_user_id User identifier of the bot created the program +//@parameters Information about the affiliate program +foundAffiliateProgram#80bf7012 bot_user_id:int53 parameters:affiliateProgramInfo = FoundAffiliateProgram; + +//@description Represents a list of found affiliate programs +//@total_count The total number of found affiliate programs +//@programs The list of affiliate programs +//@next_offset The offset for the next request. If empty, then there are no more results +foundAffiliatePrograms#b6228108 total_count:int32 programs:vector next_offset:string = FoundAffiliatePrograms; + +//@description Describes an affiliate program that was connected to a chat +//@url The link that can be used to refer users if the program is still active +//@bot_user_id User identifier of the bot created the program +//@parameters The parameters of the affiliate program +//@connection_date Point in time (Unix timestamp) when the affiliate program was connected +//@is_disconnected True, if the program was canceled by the bot, or disconnected by the chat owner and isn't available anymore +//@user_count The number of users that used the affiliate program +//@revenue_star_count The number of Telegram Stars that were earned by the affiliate program +chatAffiliateProgram#ab9c1136 url:string bot_user_id:int53 parameters:affiliateProgramParameters connection_date:int32 is_disconnected:Bool user_count:int64 revenue_star_count:int64 = ChatAffiliateProgram; + +//@description Represents a list of affiliate programs that were connected to a chat +//@total_count The total number of affiliate programs that were connected to the chat +//@programs The list of connected affiliate programs +//@next_offset The offset for the next request. If empty, then there are no more results +chatAffiliatePrograms#74f423e2 total_count:int32 programs:vector next_offset:string = ChatAffiliatePrograms; //@description Contains information about a product that can be paid with invoice //@title Product title @@ -978,115 +1038,142 @@ starTransactionDirectionIncoming#b2cabe46 = StarTransactionDirection; //@description The transaction is outgoing and decreases the number of owned Telegram Stars starTransactionDirectionOutgoing#6e83b5a0 = StarTransactionDirection; -//@class BotTransactionPurpose @description Describes purpose of a transaction with a bot +//@class StarTransactionType @description Describes type of transaction with Telegram Stars -//@description Paid media were bought -//@media The bought media if the transaction wasn't refunded -//@payload Bot-provided payload; for bots only -botTransactionPurposePaidMedia#62952496 media:vector payload:string = BotTransactionPurpose; +//@description The transaction is a deposit of Telegram Stars from the Premium bot; for regular users only +starTransactionTypePremiumBotDeposit#d879090e = StarTransactionType; -//@description User bought a product from the bot -//@product_info Information about the bought product; may be null if not applicable -//@invoice_payload Invoice payload; for bots only -botTransactionPurposeInvoicePayment#699860ac product_info:productInfo invoice_payload:bytes = BotTransactionPurpose; +//@description The transaction is a deposit of Telegram Stars from App Store; for regular users only +starTransactionTypeAppStoreDeposit#8283941 = StarTransactionType; -//@description User bought a subscription in a bot or a business account -//@period The number of seconds between consecutive Telegram Star debiting -//@product_info Information about the bought subscription; may be null if not applicable -//@invoice_payload Invoice payload; for bots only -botTransactionPurposeSubscription#e5796205 period:int32 product_info:productInfo invoice_payload:bytes = BotTransactionPurpose; +//@description The transaction is a deposit of Telegram Stars from Google Play; for regular users only +starTransactionTypeGooglePlayDeposit#ecbdb656 = StarTransactionType; -//@class ChatTransactionPurpose @description Describes purpose of a transaction with a supergroup or a channel +//@description The transaction is a deposit of Telegram Stars from Fragment; for regular users and bots only +starTransactionTypeFragmentDeposit#7625e44 = StarTransactionType; -//@description Paid media were bought -//@message_id Identifier of the corresponding message with paid media; can be 0 or an identifier of a deleted message -//@media The bought media if the transaction wasn't refunded -chatTransactionPurposePaidMedia#d35febb message_id:int53 media:vector = ChatTransactionPurpose; +//@description The transaction is a deposit of Telegram Stars by another user; for regular users only +//@user_id Identifier of the user that gifted Telegram Stars; 0 if the user was anonymous +//@sticker The sticker to be shown in the transaction information; may be null if unknown +starTransactionTypeUserDeposit#c2a18e9 user_id:int53 sticker:sticker = StarTransactionType; -//@description User joined the channel and subscribed to regular payments in Telegram Stars -//@period The number of seconds between consecutive Telegram Star debiting -chatTransactionPurposeJoin#5b31327a period:int32 = ChatTransactionPurpose; +//@description The transaction is a deposit of Telegram Stars from a giveaway; for regular users only +//@chat_id Identifier of a supergroup or a channel chat that created the giveaway +//@giveaway_message_id Identifier of the message with the giveaway; can be 0 or an identifier of a deleted message +starTransactionTypeGiveawayDeposit#b16200c6 chat_id:int53 giveaway_message_id:int53 = StarTransactionType; -//@description User paid for a reaction -//@message_id Identifier of the reacted message; can be 0 or an identifier of a deleted message -chatTransactionPurposeReaction#7a5f9888 message_id:int53 = ChatTransactionPurpose; +//@description The transaction is a withdrawal of earned Telegram Stars to Fragment; for bots and channel chats only +//@withdrawal_state State of the withdrawal; may be null for refunds from Fragment +starTransactionTypeFragmentWithdrawal#af3a2992 withdrawal_state:RevenueWithdrawalState = StarTransactionType; -//@description User received Telegram Stars from a giveaway -//@giveaway_message_id Identifier of the message with giveaway; can be 0 or an identifier of a deleted message -chatTransactionPurposeGiveaway#384c8b7f giveaway_message_id:int53 = ChatTransactionPurpose; +//@description The transaction is a withdrawal of earned Telegram Stars to Telegram Ad platform; for bots and channel chats only +starTransactionTypeTelegramAdsWithdrawal#a58e8469 = StarTransactionType; -//@class UserTransactionPurpose @description Describes purpose of a transaction with a user - -//@description A user gifted Telegram Stars -//@sticker A sticker to be shown in the transaction information; may be null if unknown -userTransactionPurposeGiftedStars#1fb3401 sticker:sticker = UserTransactionPurpose; +//@description The transaction is a payment for Telegram API usage; for bots only +//@request_count The number of billed requests +starTransactionTypeTelegramApiUsage#27a82afe request_count:int32 = StarTransactionType; -//@description The user sold a gift received from another user or bot -//@gift The gift -userTransactionPurposeGiftSell#195fcd8e gift:gift = UserTransactionPurpose; +//@description The transaction is a purchase of paid media from a bot or a business account by the current user; for regular users only +//@user_id Identifier of the bot or the business account user that sent the paid media +//@media The bought media if the transaction wasn't refunded +starTransactionTypeBotPaidMediaPurchase#7f48cc6a user_id:int53 media:vector = StarTransactionType; -//@description The user or the bot sent a gift to a user -//@gift The gift -userTransactionPurposeGiftSend#b36e54df gift:gift = UserTransactionPurpose; +//@description The transaction is a sale of paid media by the bot or a business account managed by the bot; for bots only +//@user_id Identifier of the user that bought the media +//@media The bought media +//@payload Bot-provided payload +//@affiliate Information about the affiliate which received commission from the transaction; may be null if none +starTransactionTypeBotPaidMediaSale#6e07eeb2 user_id:int53 media:vector payload:string affiliate:affiliateInfo = StarTransactionType; -//@class StarTransactionPartner @description Describes source or recipient of a transaction with Telegram Stars +//@description The transaction is a purchase of paid media from a channel by the current user; for regular users only +//@chat_id Identifier of the channel chat that sent the paid media +//@message_id Identifier of the corresponding message with paid media; can be 0 or an identifier of a deleted message +//@media The bought media if the transaction wasn't refunded +starTransactionTypeChannelPaidMediaPurchase#9016d4f5 chat_id:int53 message_id:int53 media:vector = StarTransactionType; -//@description The transaction is a transaction with Telegram through a bot -starTransactionPartnerTelegram#7a899cc0 = StarTransactionPartner; +//@description The transaction is a sale of paid media by the channel chat; for channel chats only +//@user_id Identifier of the user that bought the media +//@message_id Identifier of the corresponding message with paid media; can be 0 or an identifier of a deleted message +//@media The bought media +starTransactionTypeChannelPaidMediaSale#eace92ef user_id:int53 message_id:int53 media:vector = StarTransactionType; -//@description The transaction is a transaction with App Store -starTransactionPartnerAppStore#e34026dc = StarTransactionPartner; +//@description The transaction is a purchase of a product from a bot or a business account by the current user; for regular users only +//@user_id Identifier of the bot or the business account user that created the invoice +//@product_info Information about the bought product +starTransactionTypeBotInvoicePurchase#1dddac0c user_id:int53 product_info:productInfo = StarTransactionType; -//@description The transaction is a transaction with Google Play -starTransactionPartnerGooglePlay#f229f2a0 = StarTransactionPartner; +//@description The transaction is a sale of a product by the bot; for bots only +//@user_id Identifier of the user that bought the product +//@product_info Information about the bought product +//@invoice_payload Invoice payload +//@affiliate Information about the affiliate which received commission from the transaction; may be null if none +starTransactionTypeBotInvoiceSale#5b7d8d2f user_id:int53 product_info:productInfo invoice_payload:bytes affiliate:affiliateInfo = StarTransactionType; + +//@description The transaction is a purchase of a subscription from a bot or a business account by the current user; for regular users only +//@user_id Identifier of the bot or the business account user that created the subscription link +//@subscription_period The number of seconds between consecutive Telegram Star debitings +//@product_info Information about the bought subscription +starTransactionTypeBotSubscriptionPurchase#40bf1355 user_id:int53 subscription_period:int32 product_info:productInfo = StarTransactionType; + +//@description The transaction is a sale of a subscription by the bot; for bots only +//@user_id Identifier of the user that bought the subscription +//@subscription_period The number of seconds between consecutive Telegram Star debitings +//@product_info Information about the bought subscription +//@invoice_payload Invoice payload +//@affiliate Information about the affiliate which received commission from the transaction; may be null if none +starTransactionTypeBotSubscriptionSale#1f686889 user_id:int53 subscription_period:int32 product_info:productInfo invoice_payload:bytes affiliate:affiliateInfo = StarTransactionType; -//@description The transaction is a transaction with Fragment -//@withdrawal_state State of the withdrawal; may be null for refunds from Fragment or for Telegram Stars bought on Fragment -starTransactionPartnerFragment#da1849b5 withdrawal_state:RevenueWithdrawalState = StarTransactionPartner; +//@description The transaction is a purchase of a subscription to a channel chat by the current user; for regular users only +//@chat_id Identifier of the channel chat that created the subscription +//@subscription_period The number of seconds between consecutive Telegram Star debitings +starTransactionTypeChannelSubscriptionPurchase#380eb3d1 chat_id:int53 subscription_period:int32 = StarTransactionType; -//@description The transaction is a transaction with Telegram Ad platform -starTransactionPartnerTelegramAds#91f9c6b = StarTransactionPartner; +//@description The transaction is a sale of a subscription by the channel chat; for channel chats only +//@user_id Identifier of the user that bought the subscription +//@subscription_period The number of seconds between consecutive Telegram Star debitings +starTransactionTypeChannelSubscriptionSale#fe127c82 user_id:int53 subscription_period:int32 = StarTransactionType; -//@description The transaction is a transaction with Telegram for API usage -//@request_count The number of billed requests -starTransactionPartnerTelegramApi#543cc9fd request_count:int32 = StarTransactionPartner; +//@description The transaction is a purchase of a gift to another user; for regular users and bots only +//@user_id Identifier of the user that received the gift +//@gift The gift +starTransactionTypeGiftPurchase#ef5f1d52 user_id:int53 gift:gift = StarTransactionType; -//@description The transaction is a transaction with a bot -//@user_id Identifier of the bot -//@purpose Purpose of the transaction -starTransactionPartnerBot#4ece3a40 user_id:int53 purpose:BotTransactionPurpose = StarTransactionPartner; +//@description The transaction is a sale of a gift received from another user or bot; for regular users only +//@user_id Identifier of the user that sent the gift +//@gift The gift +starTransactionTypeGiftSale#64d61157 user_id:int53 gift:gift = StarTransactionType; -//@description The transaction is a transaction with a business account -//@user_id Identifier of the business account user -//@media The bought media if the transaction wasn't refunded -starTransactionPartnerBusiness#7af9fb52 user_id:int53 media:vector = StarTransactionPartner; +//@description The transaction is a sending of a paid reaction to a message in a channel chat by the current user; for regular users only +//@chat_id Identifier of the channel chat +//@message_id Identifier of the reacted message; can be 0 or an identifier of a deleted message +starTransactionTypeChannelPaidReactionSend#c02667c0 chat_id:int53 message_id:int53 = StarTransactionType; -//@description The transaction is a transaction with a supergroup or a channel chat -//@chat_id Identifier of the chat -//@purpose Purpose of the transaction -starTransactionPartnerChat#71db4d40 chat_id:int53 purpose:ChatTransactionPurpose = StarTransactionPartner; +//@description The transaction is a receiving of a paid reaction to a message by the channel chat; for channel chats only +//@user_id Identifier of the user that added the paid reaction +//@message_id Identifier of the reacted message; can be 0 or an identifier of a deleted message +starTransactionTypeChannelPaidReactionReceive#23d6f9eb user_id:int53 message_id:int53 = StarTransactionType; -//@description The transaction is a transaction with another user -//@user_id Identifier of the user; 0 if the user was anonymous -//@purpose Purpose of the transaction -starTransactionPartnerUser#6f4d43d1 user_id:int53 purpose:UserTransactionPurpose = StarTransactionPartner; +//@description The transaction is a receiving of a commission from an affiliate program; for regular users, bots and channel chats only +//@chat_id Identifier of the chat that created the affiliate program +//@commission_per_mille The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the program owner +starTransactionTypeAffiliateProgramCommission#9a637573 chat_id:int53 commission_per_mille:int32 = StarTransactionType; -//@description The transaction is a transaction with unknown partner -starTransactionPartnerUnsupported#c4b20d73 = StarTransactionPartner; +//@description The transaction is a transaction of an unsupported type +starTransactionTypeUnsupported#76cfcab2 = StarTransactionType; //@description Represents a transaction changing the amount of owned Telegram Stars //@id Unique identifier of the transaction -//@star_count The amount of added owned Telegram Stars; negative for outgoing transactions +//@star_amount The amount of added owned Telegram Stars; negative for outgoing transactions //@is_refund True, if the transaction is a refund of a previous transaction //@date Point in time (Unix timestamp) when the transaction was completed -//@partner Source of the incoming transaction, or its recipient for outgoing transactions -starTransaction#ce1084a8 id:string star_count:int53 is_refund:Bool date:int32 partner:StarTransactionPartner = StarTransaction; +//@type Type of the transaction +starTransaction#7f820a90 id:string star_amount:starAmount is_refund:Bool date:int32 type:StarTransactionType = StarTransaction; //@description Represents a list of Telegram Star transactions -//@star_count The amount of owned Telegram Stars +//@star_amount The amount of owned Telegram Stars //@transactions List of transactions with Telegram Stars //@next_offset The offset for the next request. If empty, then there are no more results -starTransactions#306a010e star_count:int53 transactions:vector next_offset:string = StarTransactions; +starTransactions#b5f5820b star_amount:starAmount transactions:vector next_offset:string = StarTransactions; //@class GiveawayParticipantStatus @description Contains information about status of a user in a giveaway @@ -1215,6 +1302,7 @@ user#18552c62 id:int53 first_name:string last_name:string usernames:usernames ph //@privacy_policy_url The HTTP link to the privacy policy of the bot. If empty, then /privacy command must be used if supported by the bot. If the command isn't supported, then https://telegram.org/privacy-tpa must be opened //@default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null //@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null +//@affiliate_program Information about the affiliate program of the bot; may be null if none //@web_app_background_light_color Default light background color for bot Web Apps; -1 if not specified //@web_app_background_dark_color Default dark background color for bot Web Apps; -1 if not specified //@web_app_header_light_color Default light header color for bot Web Apps; -1 if not specified @@ -1226,7 +1314,7 @@ user#18552c62 id:int53 first_name:string last_name:string usernames:usernames ph //@edit_description_link The internal link, which can be used to edit bot description; may be null //@edit_description_media_link The internal link, which can be used to edit the photo or animation shown in the chat with the bot if the chat is empty; may be null //@edit_settings_link The internal link, which can be used to edit bot settings; may be null -botInfo#15e58682 short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector privacy_policy_url:string default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights web_app_background_light_color:int32 web_app_background_dark_color:int32 web_app_header_light_color:int32 web_app_header_dark_color:int32 can_get_revenue_statistics:Bool can_manage_emoji_status:Bool has_media_previews:Bool edit_commands_link:InternalLinkType edit_description_link:InternalLinkType edit_description_media_link:InternalLinkType edit_settings_link:InternalLinkType = BotInfo; +botInfo#80eb0e42 short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector privacy_policy_url:string default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights affiliate_program:affiliateProgramInfo web_app_background_light_color:int32 web_app_background_dark_color:int32 web_app_header_light_color:int32 web_app_header_dark_color:int32 can_get_revenue_statistics:Bool can_manage_emoji_status:Bool has_media_previews:Bool edit_commands_link:InternalLinkType edit_description_link:InternalLinkType edit_description_media_link:InternalLinkType edit_settings_link:InternalLinkType = BotInfo; //@description Contains full information about a user //@personal_photo User profile photo set by the current user for the contact; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown. @@ -5428,7 +5516,7 @@ targetChatTypes#5a300e51 allow_user_chats:Bool allow_bot_chats:Bool allow_group_ //@class TargetChat @description Describes the target chat to be opened -//@description The currently opened chat needs to be kept +//@description The currently opened chat and forum topic must be kept targetChatCurrent#e729d110 = TargetChat; //@description The chat needs to be chosen by the user among chats of the specified types @@ -7223,6 +7311,11 @@ internalLinkTypeBuyStars#a94cc347 star_count:int53 purpose:string = InternalLink //@description The link is a link to the change phone number section of the application internalLinkTypeChangePhoneNumber#f0275b01 = InternalLinkType; +//@description The link is an affiliate program link. Call searchChatAffiliateProgram with the given username and referrer to process the link +//@username Username to be passed to searchChatAffiliateProgram +//@referrer Referrer to be passed to searchChatAffiliateProgram +internalLinkTypeChatAffiliateProgram#25ac5024 username:string referrer:string = InternalLinkType; + //@description The link is a link to boost a Telegram chat. Call getChatBoostLinkInfo with the given URL to process the link. //@url URL to be passed to getChatBoostLinkInfo internalLinkTypeChatBoost#d549fd40 url:string = InternalLinkType; @@ -7447,6 +7540,18 @@ fileTypeSecretThumbnail#ac797636 = FileType; //@description The file is a file from Secure storage used for storing Telegram Passport files fileTypeSecure#ab69bf26 = FileType; +//@description The file is a self-destructing photo in a private chat +fileTypeSelfDestructingPhoto#7bcf329b = FileType; + +//@description The file is a self-destructing video in a private chat +fileTypeSelfDestructingVideo#b70cc425 = FileType; + +//@description The file is a self-destructing video note in a private chat +fileTypeSelfDestructingVideoNote#592012c1 = FileType; + +//@description The file is a self-destructing voice note in a private chat +fileTypeSelfDestructingVoiceNote#64d0db1d = FileType; + //@description The file is a sticker fileTypeSticker#1c537c69 = FileType; @@ -7957,12 +8062,12 @@ chatRevenueTransaction#4c7a4ff cryptocurrency:string cryptocurrency_amount:int64 chatRevenueTransactions#95e61144 total_count:int32 transactions:vector = ChatRevenueTransactions; //@description Contains information about Telegram Stars earned by a bot or a chat -//@total_count Total number of Telegram Stars earned -//@current_count The number of Telegram Stars that aren't withdrawn yet -//@available_count The number of Telegram Stars that are available for withdrawal +//@total_amount Total amount of Telegram Stars earned +//@current_amount The amount of Telegram Stars that aren't withdrawn yet +//@available_amount The amount of Telegram Stars that are available for withdrawal //@withdrawal_enabled True, if Telegram Stars can be withdrawn now or later //@next_withdrawal_in Time left before the next withdrawal can be started, in seconds; 0 if withdrawal can be started now -starRevenueStatus#e85bd5fb total_count:int53 current_count:int53 available_count:int53 withdrawal_enabled:Bool next_withdrawal_in:int32 = StarRevenueStatus; +starRevenueStatus#779532e8 total_amount:starAmount current_amount:starAmount available_amount:starAmount withdrawal_enabled:Bool next_withdrawal_in:int32 = StarRevenueStatus; //@description A detailed statistics about Telegram Stars earned by a bot or a chat //@revenue_by_day_graph A graph containing amount of revenue in a given day @@ -8632,8 +8737,8 @@ updateSavedMessagesTags#7386424a saved_messages_topic_id:int53 tags:savedMessage updateActiveLiveLocationMessages#a20b9b1f messages:vector = Update; //@description The number of Telegram Stars owned by the current user has changed -//@star_count The new number of Telegram Stars owned -updateOwnedStarCount#de995b79 star_count:int53 = Update; +//@star_amount The new amount of owned Telegram Stars +updateOwnedStarCount#af7ebf88 star_amount:starAmount = Update; //@description The revenue earned from sponsored messages in a chat has changed. If chat revenue screen is opened, then getChatRevenueTransactions may be called to fetch new transactions //@chat_id Identifier of the chat @@ -10133,7 +10238,7 @@ answerInlineQuery#ac7cc5e6 inline_query_id:int64 is_personal:Bool button:inlineQ //@chat_types Types of the chats to which the message can be sent savePreparedInlineMessage#c71468d9 user_id:int53 result:InputInlineQueryResult chat_types:targetChatTypes = PreparedInlineMessageId; -//@description Saves an inline message to be sent by the given user; for bots only +//@description Saves an inline message to be sent by the given user //@bot_user_id Identifier of the bot that created the message //@prepared_message_id Identifier of the prepared message getPreparedInlineMessage#fb0ac74b bot_user_id:int53 prepared_message_id:string = PreparedInlineMessage; @@ -11220,7 +11325,7 @@ setVideoChatDefaultParticipant#f1a672b3 chat_id:int53 default_participant_id:Mes //@chat_id Identifier of a chat in which the video chat will be created //@title Group call title; if empty, chat title will be used //@start_date Point in time (Unix timestamp) when the group call is expected to be started by an administrator; 0 to start the video chat immediately. The date must be at least 10 seconds and at most 8 days in the future -//@is_rtmp_stream Pass true to create an RTMP stream instead of an ordinary video chat; requires owner privileges +//@is_rtmp_stream Pass true to create an RTMP stream instead of an ordinary video chat createVideoChat#7ea4958d chat_id:int53 title:string start_date:int32 is_rtmp_stream:Bool = GroupCallId; //@description Returns RTMP URL for streaming to the chat; requires can_manage_video_chats administrator right @@ -11476,9 +11581,12 @@ getAllStickerEmojis#11ad2e30 sticker_type:StickerType query:string chat_id:int53 //@description Searches for stickers from public sticker sets that correspond to any of the given emoji //@sticker_type Type of the stickers to return -//@emojis Space-separated list of emojis to search for; must be non-empty +//@emojis Space-separated list of emojis to search for +//@query Query to search for; may be empty to search for emoji only +//@input_language_codes List of possible IETF language tags of the user's input language; may be empty if unknown +//@offset The offset from which to return the stickers; must be non-negative //@limit The maximum number of stickers to be returned; 0-100 -searchStickers#9a19e90b sticker_type:StickerType emojis:string limit:int32 = Stickers; +searchStickers#66428c3a sticker_type:StickerType emojis:string query:string input_language_codes:vector offset:int32 limit:int32 = Stickers; //@description Returns greeting stickers from regular sticker sets that can be used for the start page of other users getGreetingStickers#16581d1c = Stickers; @@ -11628,6 +11736,9 @@ removeSavedAnimation#e275a919 animation:InputFile = Ok; //@description Returns up to 20 recently used inline bots in the order of their last usage getRecentInlineBots#55b3723c = Users; +//@description Returns the list of owned by the current user bots +getOwnedBots#8b87c7fd = Users; + //@description Searches for recently used hashtags by their prefix //@prefix Hashtag prefix to search for //@limit The maximum number of hashtags to be returned @@ -12694,6 +12805,44 @@ editUserStarSubscription#51b16e89 user_id:int53 telegram_payment_charge_id:strin //@subscription_id Identifier of the subscription reuseStarSubscription#2e677441 subscription_id:string = Ok; +//@description Changes affiliate program for a bot +//@chat_id Identifier of the chat with an owned bot for which affiliate program is changed +//@parameters Parameters of the affiliate program; pass null to close the currently active program. If there is an active program, then commission and program duration can only be increased. +setChatAffiliateProgram#e00237 chat_id:int53 parameters:affiliateProgramParameters = Ok; + +//@description Searches a chat with an affiliate program. Returns the chat if found and the program is active +//@username Username of the chat +//@referrer The referrer from an internalLinkTypeChatAffiliateProgram link +searchChatAffiliateProgram#b02c09ba username:string referrer:string = Chat; + +//@description Searches affiliate programs that can be applied to the given chat +//@chat_id Identifier of the chat for which affiliate programs are searched for. Can be an identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel chat with can_post_messages administrator right +//@sort_order Sort order for the results +//@offset Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of results +//@limit The maximum number of affiliate programs to return +searchAffiliatePrograms#617c974c chat_id:int53 sort_order:AffiliateProgramSortOrder offset:string limit:int32 = FoundAffiliatePrograms; + +//@description Connects an affiliate program to the given chat. Returns information about the connected affiliate program +//@chat_id Identifier of the chat to which the affiliate program will be connected. Can be an identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel chat with can_post_messages administrator right +//@bot_user_id Identifier of the bot, which affiliate program is connected +connectChatAffiliateProgram#75b163c4 chat_id:int53 bot_user_id:int53 = ChatAffiliateProgram; + +//@description Disconnects an affiliate program from the given chat and immediately deactivates its referral link. Returns updated information about the disconnected affiliate program +//@chat_id Identifier of the chat for which the affiliate program is connected +//@url The referral link of the affiliate program +disconnectChatAffiliateProgram#48ef7257 chat_id:int53 url:string = ChatAffiliateProgram; + +//@description Returns an affiliate program that were connected to the given chat by identifier of the bot that created the program +//@chat_id Identifier of the chat for which the affiliate program was connected. Can be an identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel chat with can_post_messages administrator right +//@bot_user_id Identifier of the bot that created the program +getChatAffiliateProgram#6ec8a39a chat_id:int53 bot_user_id:int53 = ChatAffiliateProgram; + +//@description Returns affiliate programs that were connected to the given chat +//@chat_id Identifier of the chat for which the affiliate programs were connected. Can be an identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel chat with can_post_messages administrator right +//@offset Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of results +//@limit The maximum number of affiliate programs to return +getChatAffiliatePrograms#f9df5251 chat_id:int53 offset:string limit:int32 = ChatAffiliatePrograms; + //@description Returns information about features, available to Business users //@source Source of the request; pass null if the method is called from settings or some non-standard source getBusinessFeatures#c4906001 source:BusinessFeature = BusinessFeatures; diff --git a/tdapi/tl_affiliate_info_gen.go b/tdapi/tl_affiliate_info_gen.go new file mode 100644 index 0000000000..ceeba40bc7 --- /dev/null +++ b/tdapi/tl_affiliate_info_gen.go @@ -0,0 +1,263 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AffiliateInfo represents TL type `affiliateInfo#b1c1dcfa`. +type AffiliateInfo struct { + // The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars + // received by the program owner + CommissionPerMille int32 + // Identifier of the chat which received the commission + AffiliateChatID int64 + // The amount of Telegram Stars that were received by the affiliate; can be negative for + // refunds + StarAmount StarAmount +} + +// AffiliateInfoTypeID is TL type id of AffiliateInfo. +const AffiliateInfoTypeID = 0xb1c1dcfa + +// Ensuring interfaces in compile-time for AffiliateInfo. +var ( + _ bin.Encoder = &AffiliateInfo{} + _ bin.Decoder = &AffiliateInfo{} + _ bin.BareEncoder = &AffiliateInfo{} + _ bin.BareDecoder = &AffiliateInfo{} +) + +func (a *AffiliateInfo) Zero() bool { + if a == nil { + return true + } + if !(a.CommissionPerMille == 0) { + return false + } + if !(a.AffiliateChatID == 0) { + return false + } + if !(a.StarAmount.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateInfo) String() string { + if a == nil { + return "AffiliateInfo(nil)" + } + type Alias AffiliateInfo + return fmt.Sprintf("AffiliateInfo%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateInfo) TypeID() uint32 { + return AffiliateInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateInfo) TypeName() string { + return "affiliateInfo" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateInfo", + ID: AffiliateInfoTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CommissionPerMille", + SchemaName: "commission_per_mille", + }, + { + Name: "AffiliateChatID", + SchemaName: "affiliate_chat_id", + }, + { + Name: "StarAmount", + SchemaName: "star_amount", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateInfo) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateInfo#b1c1dcfa as nil") + } + b.PutID(AffiliateInfoTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateInfo) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateInfo#b1c1dcfa as nil") + } + b.PutInt32(a.CommissionPerMille) + b.PutInt53(a.AffiliateChatID) + if err := a.StarAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode affiliateInfo#b1c1dcfa: field star_amount: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateInfo) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateInfo#b1c1dcfa to nil") + } + if err := b.ConsumeID(AffiliateInfoTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateInfo) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateInfo#b1c1dcfa to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field commission_per_mille: %w", err) + } + a.CommissionPerMille = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field affiliate_chat_id: %w", err) + } + a.AffiliateChatID = value + } + { + if err := a.StarAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field star_amount: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateInfo) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateInfo#b1c1dcfa as nil") + } + b.ObjStart() + b.PutID("affiliateInfo") + b.Comma() + b.FieldStart("commission_per_mille") + b.PutInt32(a.CommissionPerMille) + b.Comma() + b.FieldStart("affiliate_chat_id") + b.PutInt53(a.AffiliateChatID) + b.Comma() + b.FieldStart("star_amount") + if err := a.StarAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode affiliateInfo#b1c1dcfa: field star_amount: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateInfo) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateInfo#b1c1dcfa to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateInfo"); err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: %w", err) + } + case "commission_per_mille": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field commission_per_mille: %w", err) + } + a.CommissionPerMille = value + case "affiliate_chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field affiliate_chat_id: %w", err) + } + a.AffiliateChatID = value + case "star_amount": + if err := a.StarAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode affiliateInfo#b1c1dcfa: field star_amount: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetCommissionPerMille returns value of CommissionPerMille field. +func (a *AffiliateInfo) GetCommissionPerMille() (value int32) { + if a == nil { + return + } + return a.CommissionPerMille +} + +// GetAffiliateChatID returns value of AffiliateChatID field. +func (a *AffiliateInfo) GetAffiliateChatID() (value int64) { + if a == nil { + return + } + return a.AffiliateChatID +} + +// GetStarAmount returns value of StarAmount field. +func (a *AffiliateInfo) GetStarAmount() (value StarAmount) { + if a == nil { + return + } + return a.StarAmount +} diff --git a/tdapi/tl_affiliate_program_info_gen.go b/tdapi/tl_affiliate_program_info_gen.go new file mode 100644 index 0000000000..4e7a41ff7d --- /dev/null +++ b/tdapi/tl_affiliate_program_info_gen.go @@ -0,0 +1,263 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AffiliateProgramInfo represents TL type `affiliateProgramInfo#96fce8b5`. +type AffiliateProgramInfo struct { + // Parameters of the affiliate program + Parameters AffiliateProgramParameters + // Point in time (Unix timestamp) when the affiliate program will be closed; 0 if the + // affiliate program isn't scheduled to be closed. + EndDate int32 + // The amount of daily revenue per user in Telegram Stars of the bot that created the + // affiliate program + DailyRevenuePerUserAmount StarAmount +} + +// AffiliateProgramInfoTypeID is TL type id of AffiliateProgramInfo. +const AffiliateProgramInfoTypeID = 0x96fce8b5 + +// Ensuring interfaces in compile-time for AffiliateProgramInfo. +var ( + _ bin.Encoder = &AffiliateProgramInfo{} + _ bin.Decoder = &AffiliateProgramInfo{} + _ bin.BareEncoder = &AffiliateProgramInfo{} + _ bin.BareDecoder = &AffiliateProgramInfo{} +) + +func (a *AffiliateProgramInfo) Zero() bool { + if a == nil { + return true + } + if !(a.Parameters.Zero()) { + return false + } + if !(a.EndDate == 0) { + return false + } + if !(a.DailyRevenuePerUserAmount.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateProgramInfo) String() string { + if a == nil { + return "AffiliateProgramInfo(nil)" + } + type Alias AffiliateProgramInfo + return fmt.Sprintf("AffiliateProgramInfo%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateProgramInfo) TypeID() uint32 { + return AffiliateProgramInfoTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateProgramInfo) TypeName() string { + return "affiliateProgramInfo" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateProgramInfo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateProgramInfo", + ID: AffiliateProgramInfoTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Parameters", + SchemaName: "parameters", + }, + { + Name: "EndDate", + SchemaName: "end_date", + }, + { + Name: "DailyRevenuePerUserAmount", + SchemaName: "daily_revenue_per_user_amount", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateProgramInfo) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramInfo#96fce8b5 as nil") + } + b.PutID(AffiliateProgramInfoTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateProgramInfo) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramInfo#96fce8b5 as nil") + } + if err := a.Parameters.Encode(b); err != nil { + return fmt.Errorf("unable to encode affiliateProgramInfo#96fce8b5: field parameters: %w", err) + } + b.PutInt32(a.EndDate) + if err := a.DailyRevenuePerUserAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode affiliateProgramInfo#96fce8b5: field daily_revenue_per_user_amount: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateProgramInfo) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramInfo#96fce8b5 to nil") + } + if err := b.ConsumeID(AffiliateProgramInfoTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateProgramInfo) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramInfo#96fce8b5 to nil") + } + { + if err := a.Parameters.Decode(b); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field parameters: %w", err) + } + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field end_date: %w", err) + } + a.EndDate = value + } + { + if err := a.DailyRevenuePerUserAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field daily_revenue_per_user_amount: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateProgramInfo) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramInfo#96fce8b5 as nil") + } + b.ObjStart() + b.PutID("affiliateProgramInfo") + b.Comma() + b.FieldStart("parameters") + if err := a.Parameters.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode affiliateProgramInfo#96fce8b5: field parameters: %w", err) + } + b.Comma() + b.FieldStart("end_date") + b.PutInt32(a.EndDate) + b.Comma() + b.FieldStart("daily_revenue_per_user_amount") + if err := a.DailyRevenuePerUserAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode affiliateProgramInfo#96fce8b5: field daily_revenue_per_user_amount: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateProgramInfo) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramInfo#96fce8b5 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateProgramInfo"); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: %w", err) + } + case "parameters": + if err := a.Parameters.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field parameters: %w", err) + } + case "end_date": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field end_date: %w", err) + } + a.EndDate = value + case "daily_revenue_per_user_amount": + if err := a.DailyRevenuePerUserAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode affiliateProgramInfo#96fce8b5: field daily_revenue_per_user_amount: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetParameters returns value of Parameters field. +func (a *AffiliateProgramInfo) GetParameters() (value AffiliateProgramParameters) { + if a == nil { + return + } + return a.Parameters +} + +// GetEndDate returns value of EndDate field. +func (a *AffiliateProgramInfo) GetEndDate() (value int32) { + if a == nil { + return + } + return a.EndDate +} + +// GetDailyRevenuePerUserAmount returns value of DailyRevenuePerUserAmount field. +func (a *AffiliateProgramInfo) GetDailyRevenuePerUserAmount() (value StarAmount) { + if a == nil { + return + } + return a.DailyRevenuePerUserAmount +} diff --git a/tdapi/tl_affiliate_program_parameters_gen.go b/tdapi/tl_affiliate_program_parameters_gen.go new file mode 100644 index 0000000000..485f9b41a3 --- /dev/null +++ b/tdapi/tl_affiliate_program_parameters_gen.go @@ -0,0 +1,228 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AffiliateProgramParameters represents TL type `affiliateProgramParameters#61e90c54`. +type AffiliateProgramParameters struct { + // The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars + // received by the program owner; + CommissionPerMille int32 + // Number of months the program will be active; 0-36. If 0, then the program is eternal + MonthCount int32 +} + +// AffiliateProgramParametersTypeID is TL type id of AffiliateProgramParameters. +const AffiliateProgramParametersTypeID = 0x61e90c54 + +// Ensuring interfaces in compile-time for AffiliateProgramParameters. +var ( + _ bin.Encoder = &AffiliateProgramParameters{} + _ bin.Decoder = &AffiliateProgramParameters{} + _ bin.BareEncoder = &AffiliateProgramParameters{} + _ bin.BareDecoder = &AffiliateProgramParameters{} +) + +func (a *AffiliateProgramParameters) Zero() bool { + if a == nil { + return true + } + if !(a.CommissionPerMille == 0) { + return false + } + if !(a.MonthCount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateProgramParameters) String() string { + if a == nil { + return "AffiliateProgramParameters(nil)" + } + type Alias AffiliateProgramParameters + return fmt.Sprintf("AffiliateProgramParameters%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateProgramParameters) TypeID() uint32 { + return AffiliateProgramParametersTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateProgramParameters) TypeName() string { + return "affiliateProgramParameters" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateProgramParameters) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateProgramParameters", + ID: AffiliateProgramParametersTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "CommissionPerMille", + SchemaName: "commission_per_mille", + }, + { + Name: "MonthCount", + SchemaName: "month_count", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateProgramParameters) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramParameters#61e90c54 as nil") + } + b.PutID(AffiliateProgramParametersTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateProgramParameters) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramParameters#61e90c54 as nil") + } + b.PutInt32(a.CommissionPerMille) + b.PutInt32(a.MonthCount) + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateProgramParameters) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramParameters#61e90c54 to nil") + } + if err := b.ConsumeID(AffiliateProgramParametersTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateProgramParameters) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramParameters#61e90c54 to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: field commission_per_mille: %w", err) + } + a.CommissionPerMille = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: field month_count: %w", err) + } + a.MonthCount = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateProgramParameters) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramParameters#61e90c54 as nil") + } + b.ObjStart() + b.PutID("affiliateProgramParameters") + b.Comma() + b.FieldStart("commission_per_mille") + b.PutInt32(a.CommissionPerMille) + b.Comma() + b.FieldStart("month_count") + b.PutInt32(a.MonthCount) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateProgramParameters) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramParameters#61e90c54 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateProgramParameters"); err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: %w", err) + } + case "commission_per_mille": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: field commission_per_mille: %w", err) + } + a.CommissionPerMille = value + case "month_count": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode affiliateProgramParameters#61e90c54: field month_count: %w", err) + } + a.MonthCount = value + default: + return b.Skip() + } + return nil + }) +} + +// GetCommissionPerMille returns value of CommissionPerMille field. +func (a *AffiliateProgramParameters) GetCommissionPerMille() (value int32) { + if a == nil { + return + } + return a.CommissionPerMille +} + +// GetMonthCount returns value of MonthCount field. +func (a *AffiliateProgramParameters) GetMonthCount() (value int32) { + if a == nil { + return + } + return a.MonthCount +} diff --git a/tdapi/tl_affiliate_program_sort_order_gen.go b/tdapi/tl_affiliate_program_sort_order_gen.go new file mode 100644 index 0000000000..91c60c04de --- /dev/null +++ b/tdapi/tl_affiliate_program_sort_order_gen.go @@ -0,0 +1,577 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// AffiliateProgramSortOrderProfitability represents TL type `affiliateProgramSortOrderProfitability#8afaaf67`. +type AffiliateProgramSortOrderProfitability struct { +} + +// AffiliateProgramSortOrderProfitabilityTypeID is TL type id of AffiliateProgramSortOrderProfitability. +const AffiliateProgramSortOrderProfitabilityTypeID = 0x8afaaf67 + +// construct implements constructor of AffiliateProgramSortOrderClass. +func (a AffiliateProgramSortOrderProfitability) construct() AffiliateProgramSortOrderClass { return &a } + +// Ensuring interfaces in compile-time for AffiliateProgramSortOrderProfitability. +var ( + _ bin.Encoder = &AffiliateProgramSortOrderProfitability{} + _ bin.Decoder = &AffiliateProgramSortOrderProfitability{} + _ bin.BareEncoder = &AffiliateProgramSortOrderProfitability{} + _ bin.BareDecoder = &AffiliateProgramSortOrderProfitability{} + + _ AffiliateProgramSortOrderClass = &AffiliateProgramSortOrderProfitability{} +) + +func (a *AffiliateProgramSortOrderProfitability) Zero() bool { + if a == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateProgramSortOrderProfitability) String() string { + if a == nil { + return "AffiliateProgramSortOrderProfitability(nil)" + } + type Alias AffiliateProgramSortOrderProfitability + return fmt.Sprintf("AffiliateProgramSortOrderProfitability%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateProgramSortOrderProfitability) TypeID() uint32 { + return AffiliateProgramSortOrderProfitabilityTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateProgramSortOrderProfitability) TypeName() string { + return "affiliateProgramSortOrderProfitability" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateProgramSortOrderProfitability) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateProgramSortOrderProfitability", + ID: AffiliateProgramSortOrderProfitabilityTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateProgramSortOrderProfitability) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderProfitability#8afaaf67 as nil") + } + b.PutID(AffiliateProgramSortOrderProfitabilityTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateProgramSortOrderProfitability) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderProfitability#8afaaf67 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateProgramSortOrderProfitability) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderProfitability#8afaaf67 to nil") + } + if err := b.ConsumeID(AffiliateProgramSortOrderProfitabilityTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderProfitability#8afaaf67: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateProgramSortOrderProfitability) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderProfitability#8afaaf67 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateProgramSortOrderProfitability) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderProfitability#8afaaf67 as nil") + } + b.ObjStart() + b.PutID("affiliateProgramSortOrderProfitability") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateProgramSortOrderProfitability) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderProfitability#8afaaf67 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateProgramSortOrderProfitability"); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderProfitability#8afaaf67: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// AffiliateProgramSortOrderCreationDate represents TL type `affiliateProgramSortOrderCreationDate#a319390d`. +type AffiliateProgramSortOrderCreationDate struct { +} + +// AffiliateProgramSortOrderCreationDateTypeID is TL type id of AffiliateProgramSortOrderCreationDate. +const AffiliateProgramSortOrderCreationDateTypeID = 0xa319390d + +// construct implements constructor of AffiliateProgramSortOrderClass. +func (a AffiliateProgramSortOrderCreationDate) construct() AffiliateProgramSortOrderClass { return &a } + +// Ensuring interfaces in compile-time for AffiliateProgramSortOrderCreationDate. +var ( + _ bin.Encoder = &AffiliateProgramSortOrderCreationDate{} + _ bin.Decoder = &AffiliateProgramSortOrderCreationDate{} + _ bin.BareEncoder = &AffiliateProgramSortOrderCreationDate{} + _ bin.BareDecoder = &AffiliateProgramSortOrderCreationDate{} + + _ AffiliateProgramSortOrderClass = &AffiliateProgramSortOrderCreationDate{} +) + +func (a *AffiliateProgramSortOrderCreationDate) Zero() bool { + if a == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateProgramSortOrderCreationDate) String() string { + if a == nil { + return "AffiliateProgramSortOrderCreationDate(nil)" + } + type Alias AffiliateProgramSortOrderCreationDate + return fmt.Sprintf("AffiliateProgramSortOrderCreationDate%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateProgramSortOrderCreationDate) TypeID() uint32 { + return AffiliateProgramSortOrderCreationDateTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateProgramSortOrderCreationDate) TypeName() string { + return "affiliateProgramSortOrderCreationDate" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateProgramSortOrderCreationDate) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateProgramSortOrderCreationDate", + ID: AffiliateProgramSortOrderCreationDateTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateProgramSortOrderCreationDate) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderCreationDate#a319390d as nil") + } + b.PutID(AffiliateProgramSortOrderCreationDateTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateProgramSortOrderCreationDate) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderCreationDate#a319390d as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateProgramSortOrderCreationDate) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderCreationDate#a319390d to nil") + } + if err := b.ConsumeID(AffiliateProgramSortOrderCreationDateTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderCreationDate#a319390d: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateProgramSortOrderCreationDate) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderCreationDate#a319390d to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateProgramSortOrderCreationDate) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderCreationDate#a319390d as nil") + } + b.ObjStart() + b.PutID("affiliateProgramSortOrderCreationDate") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateProgramSortOrderCreationDate) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderCreationDate#a319390d to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateProgramSortOrderCreationDate"); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderCreationDate#a319390d: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// AffiliateProgramSortOrderRevenue represents TL type `affiliateProgramSortOrderRevenue#72a2c2b8`. +type AffiliateProgramSortOrderRevenue struct { +} + +// AffiliateProgramSortOrderRevenueTypeID is TL type id of AffiliateProgramSortOrderRevenue. +const AffiliateProgramSortOrderRevenueTypeID = 0x72a2c2b8 + +// construct implements constructor of AffiliateProgramSortOrderClass. +func (a AffiliateProgramSortOrderRevenue) construct() AffiliateProgramSortOrderClass { return &a } + +// Ensuring interfaces in compile-time for AffiliateProgramSortOrderRevenue. +var ( + _ bin.Encoder = &AffiliateProgramSortOrderRevenue{} + _ bin.Decoder = &AffiliateProgramSortOrderRevenue{} + _ bin.BareEncoder = &AffiliateProgramSortOrderRevenue{} + _ bin.BareDecoder = &AffiliateProgramSortOrderRevenue{} + + _ AffiliateProgramSortOrderClass = &AffiliateProgramSortOrderRevenue{} +) + +func (a *AffiliateProgramSortOrderRevenue) Zero() bool { + if a == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (a *AffiliateProgramSortOrderRevenue) String() string { + if a == nil { + return "AffiliateProgramSortOrderRevenue(nil)" + } + type Alias AffiliateProgramSortOrderRevenue + return fmt.Sprintf("AffiliateProgramSortOrderRevenue%+v", Alias(*a)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*AffiliateProgramSortOrderRevenue) TypeID() uint32 { + return AffiliateProgramSortOrderRevenueTypeID +} + +// TypeName returns name of type in TL schema. +func (*AffiliateProgramSortOrderRevenue) TypeName() string { + return "affiliateProgramSortOrderRevenue" +} + +// TypeInfo returns info about TL type. +func (a *AffiliateProgramSortOrderRevenue) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "affiliateProgramSortOrderRevenue", + ID: AffiliateProgramSortOrderRevenueTypeID, + } + if a == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (a *AffiliateProgramSortOrderRevenue) Encode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderRevenue#72a2c2b8 as nil") + } + b.PutID(AffiliateProgramSortOrderRevenueTypeID) + return a.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (a *AffiliateProgramSortOrderRevenue) EncodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderRevenue#72a2c2b8 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (a *AffiliateProgramSortOrderRevenue) Decode(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderRevenue#72a2c2b8 to nil") + } + if err := b.ConsumeID(AffiliateProgramSortOrderRevenueTypeID); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderRevenue#72a2c2b8: %w", err) + } + return a.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (a *AffiliateProgramSortOrderRevenue) DecodeBare(b *bin.Buffer) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderRevenue#72a2c2b8 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (a *AffiliateProgramSortOrderRevenue) EncodeTDLibJSON(b tdjson.Encoder) error { + if a == nil { + return fmt.Errorf("can't encode affiliateProgramSortOrderRevenue#72a2c2b8 as nil") + } + b.ObjStart() + b.PutID("affiliateProgramSortOrderRevenue") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (a *AffiliateProgramSortOrderRevenue) DecodeTDLibJSON(b tdjson.Decoder) error { + if a == nil { + return fmt.Errorf("can't decode affiliateProgramSortOrderRevenue#72a2c2b8 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("affiliateProgramSortOrderRevenue"); err != nil { + return fmt.Errorf("unable to decode affiliateProgramSortOrderRevenue#72a2c2b8: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// AffiliateProgramSortOrderClassName is schema name of AffiliateProgramSortOrderClass. +const AffiliateProgramSortOrderClassName = "AffiliateProgramSortOrder" + +// AffiliateProgramSortOrderClass represents AffiliateProgramSortOrder generic type. +// +// Example: +// +// g, err := tdapi.DecodeAffiliateProgramSortOrder(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tdapi.AffiliateProgramSortOrderProfitability: // affiliateProgramSortOrderProfitability#8afaaf67 +// case *tdapi.AffiliateProgramSortOrderCreationDate: // affiliateProgramSortOrderCreationDate#a319390d +// case *tdapi.AffiliateProgramSortOrderRevenue: // affiliateProgramSortOrderRevenue#72a2c2b8 +// default: panic(v) +// } +type AffiliateProgramSortOrderClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() AffiliateProgramSortOrderClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + EncodeTDLibJSON(b tdjson.Encoder) error + DecodeTDLibJSON(b tdjson.Decoder) error +} + +// DecodeAffiliateProgramSortOrder implements binary de-serialization for AffiliateProgramSortOrderClass. +func DecodeAffiliateProgramSortOrder(buf *bin.Buffer) (AffiliateProgramSortOrderClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case AffiliateProgramSortOrderProfitabilityTypeID: + // Decoding affiliateProgramSortOrderProfitability#8afaaf67. + v := AffiliateProgramSortOrderProfitability{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + case AffiliateProgramSortOrderCreationDateTypeID: + // Decoding affiliateProgramSortOrderCreationDate#a319390d. + v := AffiliateProgramSortOrderCreationDate{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + case AffiliateProgramSortOrderRevenueTypeID: + // Decoding affiliateProgramSortOrderRevenue#72a2c2b8. + v := AffiliateProgramSortOrderRevenue{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", bin.NewUnexpectedID(id)) + } +} + +// DecodeTDLibJSONAffiliateProgramSortOrder implements binary de-serialization for AffiliateProgramSortOrderClass. +func DecodeTDLibJSONAffiliateProgramSortOrder(buf tdjson.Decoder) (AffiliateProgramSortOrderClass, error) { + id, err := buf.FindTypeID() + if err != nil { + return nil, err + } + switch id { + case "affiliateProgramSortOrderProfitability": + // Decoding affiliateProgramSortOrderProfitability#8afaaf67. + v := AffiliateProgramSortOrderProfitability{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + case "affiliateProgramSortOrderCreationDate": + // Decoding affiliateProgramSortOrderCreationDate#a319390d. + v := AffiliateProgramSortOrderCreationDate{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + case "affiliateProgramSortOrderRevenue": + // Decoding affiliateProgramSortOrderRevenue#72a2c2b8. + v := AffiliateProgramSortOrderRevenue{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode AffiliateProgramSortOrderClass: %w", tdjson.NewUnexpectedID(id)) + } +} + +// AffiliateProgramSortOrder boxes the AffiliateProgramSortOrderClass providing a helper. +type AffiliateProgramSortOrderBox struct { + AffiliateProgramSortOrder AffiliateProgramSortOrderClass +} + +// Decode implements bin.Decoder for AffiliateProgramSortOrderBox. +func (b *AffiliateProgramSortOrderBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode AffiliateProgramSortOrderBox to nil") + } + v, err := DecodeAffiliateProgramSortOrder(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.AffiliateProgramSortOrder = v + return nil +} + +// Encode implements bin.Encode for AffiliateProgramSortOrderBox. +func (b *AffiliateProgramSortOrderBox) Encode(buf *bin.Buffer) error { + if b == nil || b.AffiliateProgramSortOrder == nil { + return fmt.Errorf("unable to encode AffiliateProgramSortOrderClass as nil") + } + return b.AffiliateProgramSortOrder.Encode(buf) +} + +// DecodeTDLibJSON implements bin.Decoder for AffiliateProgramSortOrderBox. +func (b *AffiliateProgramSortOrderBox) DecodeTDLibJSON(buf tdjson.Decoder) error { + if b == nil { + return fmt.Errorf("unable to decode AffiliateProgramSortOrderBox to nil") + } + v, err := DecodeTDLibJSONAffiliateProgramSortOrder(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.AffiliateProgramSortOrder = v + return nil +} + +// EncodeTDLibJSON implements bin.Encode for AffiliateProgramSortOrderBox. +func (b *AffiliateProgramSortOrderBox) EncodeTDLibJSON(buf tdjson.Encoder) error { + if b == nil || b.AffiliateProgramSortOrder == nil { + return fmt.Errorf("unable to encode AffiliateProgramSortOrderClass as nil") + } + return b.AffiliateProgramSortOrder.EncodeTDLibJSON(buf) +} diff --git a/tdapi/tl_bot_info_gen.go b/tdapi/tl_bot_info_gen.go index af7c52c432..3b4b67d8d5 100644 --- a/tdapi/tl_bot_info_gen.go +++ b/tdapi/tl_bot_info_gen.go @@ -31,7 +31,7 @@ var ( _ = tdjson.Encoder{} ) -// BotInfo represents TL type `botInfo#15e58682`. +// BotInfo represents TL type `botInfo#80eb0e42`. type BotInfo struct { // The text that is shown on the bot's profile page and is sent together with the link // when users share the bot @@ -56,6 +56,8 @@ type BotInfo struct { DefaultGroupAdministratorRights ChatAdministratorRights // Default administrator rights for adding the bot to channels; may be null DefaultChannelAdministratorRights ChatAdministratorRights + // Information about the affiliate program of the bot; may be null if none + AffiliateProgram AffiliateProgramInfo // Default light background color for bot Web Apps; -1 if not specified WebAppBackgroundLightColor int32 // Default dark background color for bot Web Apps; -1 if not specified @@ -82,7 +84,7 @@ type BotInfo struct { } // BotInfoTypeID is TL type id of BotInfo. -const BotInfoTypeID = 0x15e58682 +const BotInfoTypeID = 0x80eb0e42 // Ensuring interfaces in compile-time for BotInfo. var ( @@ -123,6 +125,9 @@ func (b *BotInfo) Zero() bool { if !(b.DefaultChannelAdministratorRights.Zero()) { return false } + if !(b.AffiliateProgram.Zero()) { + return false + } if !(b.WebAppBackgroundLightColor == 0) { return false } @@ -228,6 +233,10 @@ func (b *BotInfo) TypeInfo() tdp.Type { Name: "DefaultChannelAdministratorRights", SchemaName: "default_channel_administrator_rights", }, + { + Name: "AffiliateProgram", + SchemaName: "affiliate_program", + }, { Name: "WebAppBackgroundLightColor", SchemaName: "web_app_background_light_color", @@ -279,7 +288,7 @@ func (b *BotInfo) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (b *BotInfo) Encode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode botInfo#15e58682 as nil") + return fmt.Errorf("can't encode botInfo#80eb0e42 as nil") } buf.PutID(BotInfoTypeID) return b.EncodeBare(buf) @@ -288,31 +297,34 @@ func (b *BotInfo) Encode(buf *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (b *BotInfo) EncodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't encode botInfo#15e58682 as nil") + return fmt.Errorf("can't encode botInfo#80eb0e42 as nil") } buf.PutString(b.ShortDescription) buf.PutString(b.Description) if err := b.Photo.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field photo: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field photo: %w", err) } if err := b.Animation.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field animation: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field animation: %w", err) } if err := b.MenuButton.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field menu_button: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field menu_button: %w", err) } buf.PutInt(len(b.Commands)) for idx, v := range b.Commands { if err := v.EncodeBare(buf); err != nil { - return fmt.Errorf("unable to encode bare botInfo#15e58682: field commands element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode bare botInfo#80eb0e42: field commands element with index %d: %w", idx, err) } } buf.PutString(b.PrivacyPolicyURL) if err := b.DefaultGroupAdministratorRights.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field default_group_administrator_rights: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field default_group_administrator_rights: %w", err) } if err := b.DefaultChannelAdministratorRights.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field default_channel_administrator_rights: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field default_channel_administrator_rights: %w", err) + } + if err := b.AffiliateProgram.Encode(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#80eb0e42: field affiliate_program: %w", err) } buf.PutInt32(b.WebAppBackgroundLightColor) buf.PutInt32(b.WebAppBackgroundDarkColor) @@ -322,28 +334,28 @@ func (b *BotInfo) EncodeBare(buf *bin.Buffer) error { buf.PutBool(b.CanManageEmojiStatus) buf.PutBool(b.HasMediaPreviews) if b.EditCommandsLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_commands_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_commands_link is nil") } if err := b.EditCommandsLink.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_commands_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_commands_link: %w", err) } if b.EditDescriptionLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_link is nil") } if err := b.EditDescriptionLink.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_link: %w", err) } if b.EditDescriptionMediaLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_media_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_media_link is nil") } if err := b.EditDescriptionMediaLink.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_media_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_media_link: %w", err) } if b.EditSettingsLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_settings_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_settings_link is nil") } if err := b.EditSettingsLink.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_settings_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_settings_link: %w", err) } return nil } @@ -351,10 +363,10 @@ func (b *BotInfo) EncodeBare(buf *bin.Buffer) error { // Decode implements bin.Decoder. func (b *BotInfo) Decode(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode botInfo#15e58682 to nil") + return fmt.Errorf("can't decode botInfo#80eb0e42 to nil") } if err := buf.ConsumeID(BotInfoTypeID); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: %w", err) } return b.DecodeBare(buf) } @@ -362,41 +374,41 @@ func (b *BotInfo) Decode(buf *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { if b == nil { - return fmt.Errorf("can't decode botInfo#15e58682 to nil") + return fmt.Errorf("can't decode botInfo#80eb0e42 to nil") } { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field short_description: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field short_description: %w", err) } b.ShortDescription = value } { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field description: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field description: %w", err) } b.Description = value } { if err := b.Photo.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field photo: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field photo: %w", err) } } { if err := b.Animation.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field animation: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field animation: %w", err) } } { if err := b.MenuButton.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field menu_button: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field menu_button: %w", err) } } { headerLen, err := buf.Int() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field commands: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field commands: %w", err) } if headerLen > 0 { @@ -405,7 +417,7 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value BotCommand if err := value.DecodeBare(buf); err != nil { - return fmt.Errorf("unable to decode bare botInfo#15e58682: field commands: %w", err) + return fmt.Errorf("unable to decode bare botInfo#80eb0e42: field commands: %w", err) } b.Commands = append(b.Commands, value) } @@ -413,94 +425,99 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { { value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field privacy_policy_url: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field privacy_policy_url: %w", err) } b.PrivacyPolicyURL = value } { if err := b.DefaultGroupAdministratorRights.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field default_group_administrator_rights: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field default_group_administrator_rights: %w", err) } } { if err := b.DefaultChannelAdministratorRights.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field default_channel_administrator_rights: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field default_channel_administrator_rights: %w", err) + } + } + { + if err := b.AffiliateProgram.Decode(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#80eb0e42: field affiliate_program: %w", err) } } { value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_background_light_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_background_light_color: %w", err) } b.WebAppBackgroundLightColor = value } { value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_background_dark_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_background_dark_color: %w", err) } b.WebAppBackgroundDarkColor = value } { value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_header_light_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_header_light_color: %w", err) } b.WebAppHeaderLightColor = value } { value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_header_dark_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_header_dark_color: %w", err) } b.WebAppHeaderDarkColor = value } { value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field can_get_revenue_statistics: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field can_get_revenue_statistics: %w", err) } b.CanGetRevenueStatistics = value } { value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field can_manage_emoji_status: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field can_manage_emoji_status: %w", err) } b.CanManageEmojiStatus = value } { value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field has_media_previews: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field has_media_previews: %w", err) } b.HasMediaPreviews = value } { value, err := DecodeInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_commands_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_commands_link: %w", err) } b.EditCommandsLink = value } { value, err := DecodeInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_description_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_description_link: %w", err) } b.EditDescriptionLink = value } { value, err := DecodeInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_description_media_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_description_media_link: %w", err) } b.EditDescriptionMediaLink = value } { value, err := DecodeInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_settings_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_settings_link: %w", err) } b.EditSettingsLink = value } @@ -510,7 +527,7 @@ func (b *BotInfo) DecodeBare(buf *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil { - return fmt.Errorf("can't encode botInfo#15e58682 as nil") + return fmt.Errorf("can't encode botInfo#80eb0e42 as nil") } buf.ObjStart() buf.PutID("botInfo") @@ -523,24 +540,24 @@ func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { buf.Comma() buf.FieldStart("photo") if err := b.Photo.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field photo: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field photo: %w", err) } buf.Comma() buf.FieldStart("animation") if err := b.Animation.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field animation: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field animation: %w", err) } buf.Comma() buf.FieldStart("menu_button") if err := b.MenuButton.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field menu_button: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field menu_button: %w", err) } buf.Comma() buf.FieldStart("commands") buf.ArrStart() for idx, v := range b.Commands { if err := v.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field commands element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field commands element with index %d: %w", idx, err) } buf.Comma() } @@ -552,12 +569,17 @@ func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { buf.Comma() buf.FieldStart("default_group_administrator_rights") if err := b.DefaultGroupAdministratorRights.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field default_group_administrator_rights: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field default_group_administrator_rights: %w", err) } buf.Comma() buf.FieldStart("default_channel_administrator_rights") if err := b.DefaultChannelAdministratorRights.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field default_channel_administrator_rights: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field default_channel_administrator_rights: %w", err) + } + buf.Comma() + buf.FieldStart("affiliate_program") + if err := b.AffiliateProgram.EncodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to encode botInfo#80eb0e42: field affiliate_program: %w", err) } buf.Comma() buf.FieldStart("web_app_background_light_color") @@ -583,34 +605,34 @@ func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { buf.Comma() buf.FieldStart("edit_commands_link") if b.EditCommandsLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_commands_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_commands_link is nil") } if err := b.EditCommandsLink.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_commands_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_commands_link: %w", err) } buf.Comma() buf.FieldStart("edit_description_link") if b.EditDescriptionLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_link is nil") } if err := b.EditDescriptionLink.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_link: %w", err) } buf.Comma() buf.FieldStart("edit_description_media_link") if b.EditDescriptionMediaLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_media_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_media_link is nil") } if err := b.EditDescriptionMediaLink.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_description_media_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_description_media_link: %w", err) } buf.Comma() buf.FieldStart("edit_settings_link") if b.EditSettingsLink == nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_settings_link is nil") + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_settings_link is nil") } if err := b.EditSettingsLink.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botInfo#15e58682: field edit_settings_link: %w", err) + return fmt.Errorf("unable to encode botInfo#80eb0e42: field edit_settings_link: %w", err) } buf.Comma() buf.StripComma() @@ -621,128 +643,132 @@ func (b *BotInfo) EncodeTDLibJSON(buf tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (b *BotInfo) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { - return fmt.Errorf("can't decode botInfo#15e58682 to nil") + return fmt.Errorf("can't decode botInfo#80eb0e42 to nil") } return buf.Obj(func(buf tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := buf.ConsumeID("botInfo"); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: %w", err) } case "short_description": value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field short_description: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field short_description: %w", err) } b.ShortDescription = value case "description": value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field description: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field description: %w", err) } b.Description = value case "photo": if err := b.Photo.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field photo: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field photo: %w", err) } case "animation": if err := b.Animation.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field animation: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field animation: %w", err) } case "menu_button": if err := b.MenuButton.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field menu_button: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field menu_button: %w", err) } case "commands": if err := buf.Arr(func(buf tdjson.Decoder) error { var value BotCommand if err := value.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field commands: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field commands: %w", err) } b.Commands = append(b.Commands, value) return nil }); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field commands: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field commands: %w", err) } case "privacy_policy_url": value, err := buf.String() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field privacy_policy_url: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field privacy_policy_url: %w", err) } b.PrivacyPolicyURL = value case "default_group_administrator_rights": if err := b.DefaultGroupAdministratorRights.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field default_group_administrator_rights: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field default_group_administrator_rights: %w", err) } case "default_channel_administrator_rights": if err := b.DefaultChannelAdministratorRights.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field default_channel_administrator_rights: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field default_channel_administrator_rights: %w", err) + } + case "affiliate_program": + if err := b.AffiliateProgram.DecodeTDLibJSON(buf); err != nil { + return fmt.Errorf("unable to decode botInfo#80eb0e42: field affiliate_program: %w", err) } case "web_app_background_light_color": value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_background_light_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_background_light_color: %w", err) } b.WebAppBackgroundLightColor = value case "web_app_background_dark_color": value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_background_dark_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_background_dark_color: %w", err) } b.WebAppBackgroundDarkColor = value case "web_app_header_light_color": value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_header_light_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_header_light_color: %w", err) } b.WebAppHeaderLightColor = value case "web_app_header_dark_color": value, err := buf.Int32() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field web_app_header_dark_color: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field web_app_header_dark_color: %w", err) } b.WebAppHeaderDarkColor = value case "can_get_revenue_statistics": value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field can_get_revenue_statistics: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field can_get_revenue_statistics: %w", err) } b.CanGetRevenueStatistics = value case "can_manage_emoji_status": value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field can_manage_emoji_status: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field can_manage_emoji_status: %w", err) } b.CanManageEmojiStatus = value case "has_media_previews": value, err := buf.Bool() if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field has_media_previews: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field has_media_previews: %w", err) } b.HasMediaPreviews = value case "edit_commands_link": value, err := DecodeTDLibJSONInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_commands_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_commands_link: %w", err) } b.EditCommandsLink = value case "edit_description_link": value, err := DecodeTDLibJSONInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_description_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_description_link: %w", err) } b.EditDescriptionLink = value case "edit_description_media_link": value, err := DecodeTDLibJSONInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_description_media_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_description_media_link: %w", err) } b.EditDescriptionMediaLink = value case "edit_settings_link": value, err := DecodeTDLibJSONInternalLinkType(buf) if err != nil { - return fmt.Errorf("unable to decode botInfo#15e58682: field edit_settings_link: %w", err) + return fmt.Errorf("unable to decode botInfo#80eb0e42: field edit_settings_link: %w", err) } b.EditSettingsLink = value default: @@ -824,6 +850,14 @@ func (b *BotInfo) GetDefaultChannelAdministratorRights() (value ChatAdministrato return b.DefaultChannelAdministratorRights } +// GetAffiliateProgram returns value of AffiliateProgram field. +func (b *BotInfo) GetAffiliateProgram() (value AffiliateProgramInfo) { + if b == nil { + return + } + return b.AffiliateProgram +} + // GetWebAppBackgroundLightColor returns value of WebAppBackgroundLightColor field. func (b *BotInfo) GetWebAppBackgroundLightColor() (value int32) { if b == nil { diff --git a/tdapi/tl_bot_transaction_purpose_gen.go b/tdapi/tl_bot_transaction_purpose_gen.go deleted file mode 100644 index 4e65981d61..0000000000 --- a/tdapi/tl_bot_transaction_purpose_gen.go +++ /dev/null @@ -1,852 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tdapi - -import ( - "context" - "errors" - "fmt" - "sort" - "strings" - - "go.uber.org/multierr" - - "github.com/gotd/td/bin" - "github.com/gotd/td/tdjson" - "github.com/gotd/td/tdp" - "github.com/gotd/td/tgerr" -) - -// No-op definition for keeping imports. -var ( - _ = bin.Buffer{} - _ = context.Background() - _ = fmt.Stringer(nil) - _ = strings.Builder{} - _ = errors.Is - _ = multierr.AppendInto - _ = sort.Ints - _ = tdp.Format - _ = tgerr.Error{} - _ = tdjson.Encoder{} -) - -// BotTransactionPurposePaidMedia represents TL type `botTransactionPurposePaidMedia#62952496`. -type BotTransactionPurposePaidMedia struct { - // The bought media if the transaction wasn't refunded - Media []PaidMediaClass - // Bot-provided payload; for bots only - Payload string -} - -// BotTransactionPurposePaidMediaTypeID is TL type id of BotTransactionPurposePaidMedia. -const BotTransactionPurposePaidMediaTypeID = 0x62952496 - -// construct implements constructor of BotTransactionPurposeClass. -func (b BotTransactionPurposePaidMedia) construct() BotTransactionPurposeClass { return &b } - -// Ensuring interfaces in compile-time for BotTransactionPurposePaidMedia. -var ( - _ bin.Encoder = &BotTransactionPurposePaidMedia{} - _ bin.Decoder = &BotTransactionPurposePaidMedia{} - _ bin.BareEncoder = &BotTransactionPurposePaidMedia{} - _ bin.BareDecoder = &BotTransactionPurposePaidMedia{} - - _ BotTransactionPurposeClass = &BotTransactionPurposePaidMedia{} -) - -func (b *BotTransactionPurposePaidMedia) Zero() bool { - if b == nil { - return true - } - if !(b.Media == nil) { - return false - } - if !(b.Payload == "") { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *BotTransactionPurposePaidMedia) String() string { - if b == nil { - return "BotTransactionPurposePaidMedia(nil)" - } - type Alias BotTransactionPurposePaidMedia - return fmt.Sprintf("BotTransactionPurposePaidMedia%+v", Alias(*b)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*BotTransactionPurposePaidMedia) TypeID() uint32 { - return BotTransactionPurposePaidMediaTypeID -} - -// TypeName returns name of type in TL schema. -func (*BotTransactionPurposePaidMedia) TypeName() string { - return "botTransactionPurposePaidMedia" -} - -// TypeInfo returns info about TL type. -func (b *BotTransactionPurposePaidMedia) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "botTransactionPurposePaidMedia", - ID: BotTransactionPurposePaidMediaTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Media", - SchemaName: "media", - }, - { - Name: "Payload", - SchemaName: "payload", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (b *BotTransactionPurposePaidMedia) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposePaidMedia#62952496 as nil") - } - buf.PutID(BotTransactionPurposePaidMediaTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *BotTransactionPurposePaidMedia) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposePaidMedia#62952496 as nil") - } - buf.PutInt(len(b.Media)) - for idx, v := range b.Media { - if v == nil { - return fmt.Errorf("unable to encode botTransactionPurposePaidMedia#62952496: field media element with index %d is nil", idx) - } - if err := v.EncodeBare(buf); err != nil { - return fmt.Errorf("unable to encode bare botTransactionPurposePaidMedia#62952496: field media element with index %d: %w", idx, err) - } - } - buf.PutString(b.Payload) - return nil -} - -// Decode implements bin.Decoder. -func (b *BotTransactionPurposePaidMedia) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposePaidMedia#62952496 to nil") - } - if err := buf.ConsumeID(BotTransactionPurposePaidMediaTypeID); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *BotTransactionPurposePaidMedia) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposePaidMedia#62952496 to nil") - } - { - headerLen, err := buf.Int() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field media: %w", err) - } - - if headerLen > 0 { - b.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodePaidMedia(buf) - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field media: %w", err) - } - b.Media = append(b.Media, value) - } - } - { - value, err := buf.String() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field payload: %w", err) - } - b.Payload = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (b *BotTransactionPurposePaidMedia) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposePaidMedia#62952496 as nil") - } - buf.ObjStart() - buf.PutID("botTransactionPurposePaidMedia") - buf.Comma() - buf.FieldStart("media") - buf.ArrStart() - for idx, v := range b.Media { - if v == nil { - return fmt.Errorf("unable to encode botTransactionPurposePaidMedia#62952496: field media element with index %d is nil", idx) - } - if err := v.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botTransactionPurposePaidMedia#62952496: field media element with index %d: %w", idx, err) - } - buf.Comma() - } - buf.StripComma() - buf.ArrEnd() - buf.Comma() - buf.FieldStart("payload") - buf.PutString(b.Payload) - buf.Comma() - buf.StripComma() - buf.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (b *BotTransactionPurposePaidMedia) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposePaidMedia#62952496 to nil") - } - - return buf.Obj(func(buf tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := buf.ConsumeID("botTransactionPurposePaidMedia"); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: %w", err) - } - case "media": - if err := buf.Arr(func(buf tdjson.Decoder) error { - value, err := DecodeTDLibJSONPaidMedia(buf) - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field media: %w", err) - } - b.Media = append(b.Media, value) - return nil - }); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field media: %w", err) - } - case "payload": - value, err := buf.String() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposePaidMedia#62952496: field payload: %w", err) - } - b.Payload = value - default: - return buf.Skip() - } - return nil - }) -} - -// GetMedia returns value of Media field. -func (b *BotTransactionPurposePaidMedia) GetMedia() (value []PaidMediaClass) { - if b == nil { - return - } - return b.Media -} - -// GetPayload returns value of Payload field. -func (b *BotTransactionPurposePaidMedia) GetPayload() (value string) { - if b == nil { - return - } - return b.Payload -} - -// BotTransactionPurposeInvoicePayment represents TL type `botTransactionPurposeInvoicePayment#699860ac`. -type BotTransactionPurposeInvoicePayment struct { - // Information about the bought product; may be null if not applicable - ProductInfo ProductInfo - // Invoice payload; for bots only - InvoicePayload []byte -} - -// BotTransactionPurposeInvoicePaymentTypeID is TL type id of BotTransactionPurposeInvoicePayment. -const BotTransactionPurposeInvoicePaymentTypeID = 0x699860ac - -// construct implements constructor of BotTransactionPurposeClass. -func (b BotTransactionPurposeInvoicePayment) construct() BotTransactionPurposeClass { return &b } - -// Ensuring interfaces in compile-time for BotTransactionPurposeInvoicePayment. -var ( - _ bin.Encoder = &BotTransactionPurposeInvoicePayment{} - _ bin.Decoder = &BotTransactionPurposeInvoicePayment{} - _ bin.BareEncoder = &BotTransactionPurposeInvoicePayment{} - _ bin.BareDecoder = &BotTransactionPurposeInvoicePayment{} - - _ BotTransactionPurposeClass = &BotTransactionPurposeInvoicePayment{} -) - -func (b *BotTransactionPurposeInvoicePayment) Zero() bool { - if b == nil { - return true - } - if !(b.ProductInfo.Zero()) { - return false - } - if !(b.InvoicePayload == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *BotTransactionPurposeInvoicePayment) String() string { - if b == nil { - return "BotTransactionPurposeInvoicePayment(nil)" - } - type Alias BotTransactionPurposeInvoicePayment - return fmt.Sprintf("BotTransactionPurposeInvoicePayment%+v", Alias(*b)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*BotTransactionPurposeInvoicePayment) TypeID() uint32 { - return BotTransactionPurposeInvoicePaymentTypeID -} - -// TypeName returns name of type in TL schema. -func (*BotTransactionPurposeInvoicePayment) TypeName() string { - return "botTransactionPurposeInvoicePayment" -} - -// TypeInfo returns info about TL type. -func (b *BotTransactionPurposeInvoicePayment) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "botTransactionPurposeInvoicePayment", - ID: BotTransactionPurposeInvoicePaymentTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "ProductInfo", - SchemaName: "product_info", - }, - { - Name: "InvoicePayload", - SchemaName: "invoice_payload", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (b *BotTransactionPurposeInvoicePayment) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeInvoicePayment#699860ac as nil") - } - buf.PutID(BotTransactionPurposeInvoicePaymentTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *BotTransactionPurposeInvoicePayment) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeInvoicePayment#699860ac as nil") - } - if err := b.ProductInfo.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botTransactionPurposeInvoicePayment#699860ac: field product_info: %w", err) - } - buf.PutBytes(b.InvoicePayload) - return nil -} - -// Decode implements bin.Decoder. -func (b *BotTransactionPurposeInvoicePayment) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeInvoicePayment#699860ac to nil") - } - if err := buf.ConsumeID(BotTransactionPurposeInvoicePaymentTypeID); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *BotTransactionPurposeInvoicePayment) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeInvoicePayment#699860ac to nil") - } - { - if err := b.ProductInfo.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: field product_info: %w", err) - } - } - { - value, err := buf.Bytes() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: field invoice_payload: %w", err) - } - b.InvoicePayload = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (b *BotTransactionPurposeInvoicePayment) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeInvoicePayment#699860ac as nil") - } - buf.ObjStart() - buf.PutID("botTransactionPurposeInvoicePayment") - buf.Comma() - buf.FieldStart("product_info") - if err := b.ProductInfo.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botTransactionPurposeInvoicePayment#699860ac: field product_info: %w", err) - } - buf.Comma() - buf.FieldStart("invoice_payload") - buf.PutBytes(b.InvoicePayload) - buf.Comma() - buf.StripComma() - buf.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (b *BotTransactionPurposeInvoicePayment) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeInvoicePayment#699860ac to nil") - } - - return buf.Obj(func(buf tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := buf.ConsumeID("botTransactionPurposeInvoicePayment"); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: %w", err) - } - case "product_info": - if err := b.ProductInfo.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: field product_info: %w", err) - } - case "invoice_payload": - value, err := buf.Bytes() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeInvoicePayment#699860ac: field invoice_payload: %w", err) - } - b.InvoicePayload = value - default: - return buf.Skip() - } - return nil - }) -} - -// GetProductInfo returns value of ProductInfo field. -func (b *BotTransactionPurposeInvoicePayment) GetProductInfo() (value ProductInfo) { - if b == nil { - return - } - return b.ProductInfo -} - -// GetInvoicePayload returns value of InvoicePayload field. -func (b *BotTransactionPurposeInvoicePayment) GetInvoicePayload() (value []byte) { - if b == nil { - return - } - return b.InvoicePayload -} - -// BotTransactionPurposeSubscription represents TL type `botTransactionPurposeSubscription#e5796205`. -type BotTransactionPurposeSubscription struct { - // The number of seconds between consecutive Telegram Star debiting - Period int32 - // Information about the bought subscription; may be null if not applicable - ProductInfo ProductInfo - // Invoice payload; for bots only - InvoicePayload []byte -} - -// BotTransactionPurposeSubscriptionTypeID is TL type id of BotTransactionPurposeSubscription. -const BotTransactionPurposeSubscriptionTypeID = 0xe5796205 - -// construct implements constructor of BotTransactionPurposeClass. -func (b BotTransactionPurposeSubscription) construct() BotTransactionPurposeClass { return &b } - -// Ensuring interfaces in compile-time for BotTransactionPurposeSubscription. -var ( - _ bin.Encoder = &BotTransactionPurposeSubscription{} - _ bin.Decoder = &BotTransactionPurposeSubscription{} - _ bin.BareEncoder = &BotTransactionPurposeSubscription{} - _ bin.BareDecoder = &BotTransactionPurposeSubscription{} - - _ BotTransactionPurposeClass = &BotTransactionPurposeSubscription{} -) - -func (b *BotTransactionPurposeSubscription) Zero() bool { - if b == nil { - return true - } - if !(b.Period == 0) { - return false - } - if !(b.ProductInfo.Zero()) { - return false - } - if !(b.InvoicePayload == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (b *BotTransactionPurposeSubscription) String() string { - if b == nil { - return "BotTransactionPurposeSubscription(nil)" - } - type Alias BotTransactionPurposeSubscription - return fmt.Sprintf("BotTransactionPurposeSubscription%+v", Alias(*b)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*BotTransactionPurposeSubscription) TypeID() uint32 { - return BotTransactionPurposeSubscriptionTypeID -} - -// TypeName returns name of type in TL schema. -func (*BotTransactionPurposeSubscription) TypeName() string { - return "botTransactionPurposeSubscription" -} - -// TypeInfo returns info about TL type. -func (b *BotTransactionPurposeSubscription) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "botTransactionPurposeSubscription", - ID: BotTransactionPurposeSubscriptionTypeID, - } - if b == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Period", - SchemaName: "period", - }, - { - Name: "ProductInfo", - SchemaName: "product_info", - }, - { - Name: "InvoicePayload", - SchemaName: "invoice_payload", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (b *BotTransactionPurposeSubscription) Encode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeSubscription#e5796205 as nil") - } - buf.PutID(BotTransactionPurposeSubscriptionTypeID) - return b.EncodeBare(buf) -} - -// EncodeBare implements bin.BareEncoder. -func (b *BotTransactionPurposeSubscription) EncodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeSubscription#e5796205 as nil") - } - buf.PutInt32(b.Period) - if err := b.ProductInfo.Encode(buf); err != nil { - return fmt.Errorf("unable to encode botTransactionPurposeSubscription#e5796205: field product_info: %w", err) - } - buf.PutBytes(b.InvoicePayload) - return nil -} - -// Decode implements bin.Decoder. -func (b *BotTransactionPurposeSubscription) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeSubscription#e5796205 to nil") - } - if err := buf.ConsumeID(BotTransactionPurposeSubscriptionTypeID); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: %w", err) - } - return b.DecodeBare(buf) -} - -// DecodeBare implements bin.BareDecoder. -func (b *BotTransactionPurposeSubscription) DecodeBare(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeSubscription#e5796205 to nil") - } - { - value, err := buf.Int32() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field period: %w", err) - } - b.Period = value - } - { - if err := b.ProductInfo.Decode(buf); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field product_info: %w", err) - } - } - { - value, err := buf.Bytes() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field invoice_payload: %w", err) - } - b.InvoicePayload = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (b *BotTransactionPurposeSubscription) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil { - return fmt.Errorf("can't encode botTransactionPurposeSubscription#e5796205 as nil") - } - buf.ObjStart() - buf.PutID("botTransactionPurposeSubscription") - buf.Comma() - buf.FieldStart("period") - buf.PutInt32(b.Period) - buf.Comma() - buf.FieldStart("product_info") - if err := b.ProductInfo.EncodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to encode botTransactionPurposeSubscription#e5796205: field product_info: %w", err) - } - buf.Comma() - buf.FieldStart("invoice_payload") - buf.PutBytes(b.InvoicePayload) - buf.Comma() - buf.StripComma() - buf.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (b *BotTransactionPurposeSubscription) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("can't decode botTransactionPurposeSubscription#e5796205 to nil") - } - - return buf.Obj(func(buf tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := buf.ConsumeID("botTransactionPurposeSubscription"); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: %w", err) - } - case "period": - value, err := buf.Int32() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field period: %w", err) - } - b.Period = value - case "product_info": - if err := b.ProductInfo.DecodeTDLibJSON(buf); err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field product_info: %w", err) - } - case "invoice_payload": - value, err := buf.Bytes() - if err != nil { - return fmt.Errorf("unable to decode botTransactionPurposeSubscription#e5796205: field invoice_payload: %w", err) - } - b.InvoicePayload = value - default: - return buf.Skip() - } - return nil - }) -} - -// GetPeriod returns value of Period field. -func (b *BotTransactionPurposeSubscription) GetPeriod() (value int32) { - if b == nil { - return - } - return b.Period -} - -// GetProductInfo returns value of ProductInfo field. -func (b *BotTransactionPurposeSubscription) GetProductInfo() (value ProductInfo) { - if b == nil { - return - } - return b.ProductInfo -} - -// GetInvoicePayload returns value of InvoicePayload field. -func (b *BotTransactionPurposeSubscription) GetInvoicePayload() (value []byte) { - if b == nil { - return - } - return b.InvoicePayload -} - -// BotTransactionPurposeClassName is schema name of BotTransactionPurposeClass. -const BotTransactionPurposeClassName = "BotTransactionPurpose" - -// BotTransactionPurposeClass represents BotTransactionPurpose generic type. -// -// Example: -// -// g, err := tdapi.DecodeBotTransactionPurpose(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tdapi.BotTransactionPurposePaidMedia: // botTransactionPurposePaidMedia#62952496 -// case *tdapi.BotTransactionPurposeInvoicePayment: // botTransactionPurposeInvoicePayment#699860ac -// case *tdapi.BotTransactionPurposeSubscription: // botTransactionPurposeSubscription#e5796205 -// default: panic(v) -// } -type BotTransactionPurposeClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() BotTransactionPurposeClass - - // TypeID returns type id in TL schema. - // - // See https://core.telegram.org/mtproto/TL-tl#remarks. - TypeID() uint32 - // TypeName returns name of type in TL schema. - TypeName() string - // String implements fmt.Stringer. - String() string - // Zero returns true if current object has a zero value. - Zero() bool - - EncodeTDLibJSON(b tdjson.Encoder) error - DecodeTDLibJSON(b tdjson.Decoder) error -} - -// DecodeBotTransactionPurpose implements binary de-serialization for BotTransactionPurposeClass. -func DecodeBotTransactionPurpose(buf *bin.Buffer) (BotTransactionPurposeClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case BotTransactionPurposePaidMediaTypeID: - // Decoding botTransactionPurposePaidMedia#62952496. - v := BotTransactionPurposePaidMedia{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - case BotTransactionPurposeInvoicePaymentTypeID: - // Decoding botTransactionPurposeInvoicePayment#699860ac. - v := BotTransactionPurposeInvoicePayment{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - case BotTransactionPurposeSubscriptionTypeID: - // Decoding botTransactionPurposeSubscription#e5796205. - v := BotTransactionPurposeSubscription{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", bin.NewUnexpectedID(id)) - } -} - -// DecodeTDLibJSONBotTransactionPurpose implements binary de-serialization for BotTransactionPurposeClass. -func DecodeTDLibJSONBotTransactionPurpose(buf tdjson.Decoder) (BotTransactionPurposeClass, error) { - id, err := buf.FindTypeID() - if err != nil { - return nil, err - } - switch id { - case "botTransactionPurposePaidMedia": - // Decoding botTransactionPurposePaidMedia#62952496. - v := BotTransactionPurposePaidMedia{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - case "botTransactionPurposeInvoicePayment": - // Decoding botTransactionPurposeInvoicePayment#699860ac. - v := BotTransactionPurposeInvoicePayment{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - case "botTransactionPurposeSubscription": - // Decoding botTransactionPurposeSubscription#e5796205. - v := BotTransactionPurposeSubscription{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode BotTransactionPurposeClass: %w", tdjson.NewUnexpectedID(id)) - } -} - -// BotTransactionPurpose boxes the BotTransactionPurposeClass providing a helper. -type BotTransactionPurposeBox struct { - BotTransactionPurpose BotTransactionPurposeClass -} - -// Decode implements bin.Decoder for BotTransactionPurposeBox. -func (b *BotTransactionPurposeBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode BotTransactionPurposeBox to nil") - } - v, err := DecodeBotTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.BotTransactionPurpose = v - return nil -} - -// Encode implements bin.Encode for BotTransactionPurposeBox. -func (b *BotTransactionPurposeBox) Encode(buf *bin.Buffer) error { - if b == nil || b.BotTransactionPurpose == nil { - return fmt.Errorf("unable to encode BotTransactionPurposeClass as nil") - } - return b.BotTransactionPurpose.Encode(buf) -} - -// DecodeTDLibJSON implements bin.Decoder for BotTransactionPurposeBox. -func (b *BotTransactionPurposeBox) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("unable to decode BotTransactionPurposeBox to nil") - } - v, err := DecodeTDLibJSONBotTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.BotTransactionPurpose = v - return nil -} - -// EncodeTDLibJSON implements bin.Encode for BotTransactionPurposeBox. -func (b *BotTransactionPurposeBox) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil || b.BotTransactionPurpose == nil { - return fmt.Errorf("unable to encode BotTransactionPurposeClass as nil") - } - return b.BotTransactionPurpose.EncodeTDLibJSON(buf) -} diff --git a/tdapi/tl_chat_affiliate_program_gen.go b/tdapi/tl_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..ebf41ddc9b --- /dev/null +++ b/tdapi/tl_chat_affiliate_program_gen.go @@ -0,0 +1,398 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChatAffiliateProgram represents TL type `chatAffiliateProgram#ab9c1136`. +type ChatAffiliateProgram struct { + // The link that can be used to refer users if the program is still active + URL string + // User identifier of the bot created the program + BotUserID int64 + // The parameters of the affiliate program + Parameters AffiliateProgramParameters + // Point in time (Unix timestamp) when the affiliate program was connected + ConnectionDate int32 + // True, if the program was canceled by the bot, or disconnected by the chat owner and + // isn't available anymore + IsDisconnected bool + // The number of users that used the affiliate program + UserCount int64 + // The number of Telegram Stars that were earned by the affiliate program + RevenueStarCount int64 +} + +// ChatAffiliateProgramTypeID is TL type id of ChatAffiliateProgram. +const ChatAffiliateProgramTypeID = 0xab9c1136 + +// Ensuring interfaces in compile-time for ChatAffiliateProgram. +var ( + _ bin.Encoder = &ChatAffiliateProgram{} + _ bin.Decoder = &ChatAffiliateProgram{} + _ bin.BareEncoder = &ChatAffiliateProgram{} + _ bin.BareDecoder = &ChatAffiliateProgram{} +) + +func (c *ChatAffiliateProgram) Zero() bool { + if c == nil { + return true + } + if !(c.URL == "") { + return false + } + if !(c.BotUserID == 0) { + return false + } + if !(c.Parameters.Zero()) { + return false + } + if !(c.ConnectionDate == 0) { + return false + } + if !(c.IsDisconnected == false) { + return false + } + if !(c.UserCount == 0) { + return false + } + if !(c.RevenueStarCount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatAffiliateProgram) String() string { + if c == nil { + return "ChatAffiliateProgram(nil)" + } + type Alias ChatAffiliateProgram + return fmt.Sprintf("ChatAffiliateProgram%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatAffiliateProgram) TypeID() uint32 { + return ChatAffiliateProgramTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatAffiliateProgram) TypeName() string { + return "chatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (c *ChatAffiliateProgram) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatAffiliateProgram", + ID: ChatAffiliateProgramTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "URL", + SchemaName: "url", + }, + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "Parameters", + SchemaName: "parameters", + }, + { + Name: "ConnectionDate", + SchemaName: "connection_date", + }, + { + Name: "IsDisconnected", + SchemaName: "is_disconnected", + }, + { + Name: "UserCount", + SchemaName: "user_count", + }, + { + Name: "RevenueStarCount", + SchemaName: "revenue_star_count", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChatAffiliateProgram) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliateProgram#ab9c1136 as nil") + } + b.PutID(ChatAffiliateProgramTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatAffiliateProgram) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliateProgram#ab9c1136 as nil") + } + b.PutString(c.URL) + b.PutInt53(c.BotUserID) + if err := c.Parameters.Encode(b); err != nil { + return fmt.Errorf("unable to encode chatAffiliateProgram#ab9c1136: field parameters: %w", err) + } + b.PutInt32(c.ConnectionDate) + b.PutBool(c.IsDisconnected) + b.PutLong(c.UserCount) + b.PutLong(c.RevenueStarCount) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatAffiliateProgram) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliateProgram#ab9c1136 to nil") + } + if err := b.ConsumeID(ChatAffiliateProgramTypeID); err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatAffiliateProgram) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliateProgram#ab9c1136 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field url: %w", err) + } + c.URL = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field bot_user_id: %w", err) + } + c.BotUserID = value + } + { + if err := c.Parameters.Decode(b); err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field parameters: %w", err) + } + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field connection_date: %w", err) + } + c.ConnectionDate = value + } + { + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field is_disconnected: %w", err) + } + c.IsDisconnected = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field user_count: %w", err) + } + c.UserCount = value + } + { + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field revenue_star_count: %w", err) + } + c.RevenueStarCount = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (c *ChatAffiliateProgram) EncodeTDLibJSON(b tdjson.Encoder) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliateProgram#ab9c1136 as nil") + } + b.ObjStart() + b.PutID("chatAffiliateProgram") + b.Comma() + b.FieldStart("url") + b.PutString(c.URL) + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(c.BotUserID) + b.Comma() + b.FieldStart("parameters") + if err := c.Parameters.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode chatAffiliateProgram#ab9c1136: field parameters: %w", err) + } + b.Comma() + b.FieldStart("connection_date") + b.PutInt32(c.ConnectionDate) + b.Comma() + b.FieldStart("is_disconnected") + b.PutBool(c.IsDisconnected) + b.Comma() + b.FieldStart("user_count") + b.PutLong(c.UserCount) + b.Comma() + b.FieldStart("revenue_star_count") + b.PutLong(c.RevenueStarCount) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (c *ChatAffiliateProgram) DecodeTDLibJSON(b tdjson.Decoder) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliateProgram#ab9c1136 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("chatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: %w", err) + } + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field url: %w", err) + } + c.URL = value + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field bot_user_id: %w", err) + } + c.BotUserID = value + case "parameters": + if err := c.Parameters.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field parameters: %w", err) + } + case "connection_date": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field connection_date: %w", err) + } + c.ConnectionDate = value + case "is_disconnected": + value, err := b.Bool() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field is_disconnected: %w", err) + } + c.IsDisconnected = value + case "user_count": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field user_count: %w", err) + } + c.UserCount = value + case "revenue_star_count": + value, err := b.Long() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliateProgram#ab9c1136: field revenue_star_count: %w", err) + } + c.RevenueStarCount = value + default: + return b.Skip() + } + return nil + }) +} + +// GetURL returns value of URL field. +func (c *ChatAffiliateProgram) GetURL() (value string) { + if c == nil { + return + } + return c.URL +} + +// GetBotUserID returns value of BotUserID field. +func (c *ChatAffiliateProgram) GetBotUserID() (value int64) { + if c == nil { + return + } + return c.BotUserID +} + +// GetParameters returns value of Parameters field. +func (c *ChatAffiliateProgram) GetParameters() (value AffiliateProgramParameters) { + if c == nil { + return + } + return c.Parameters +} + +// GetConnectionDate returns value of ConnectionDate field. +func (c *ChatAffiliateProgram) GetConnectionDate() (value int32) { + if c == nil { + return + } + return c.ConnectionDate +} + +// GetIsDisconnected returns value of IsDisconnected field. +func (c *ChatAffiliateProgram) GetIsDisconnected() (value bool) { + if c == nil { + return + } + return c.IsDisconnected +} + +// GetUserCount returns value of UserCount field. +func (c *ChatAffiliateProgram) GetUserCount() (value int64) { + if c == nil { + return + } + return c.UserCount +} + +// GetRevenueStarCount returns value of RevenueStarCount field. +func (c *ChatAffiliateProgram) GetRevenueStarCount() (value int64) { + if c == nil { + return + } + return c.RevenueStarCount +} diff --git a/tdapi/tl_chat_affiliate_programs_gen.go b/tdapi/tl_chat_affiliate_programs_gen.go new file mode 100644 index 0000000000..cc52186cfa --- /dev/null +++ b/tdapi/tl_chat_affiliate_programs_gen.go @@ -0,0 +1,289 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ChatAffiliatePrograms represents TL type `chatAffiliatePrograms#74f423e2`. +type ChatAffiliatePrograms struct { + // The total number of affiliate programs that were connected to the chat + TotalCount int32 + // The list of connected affiliate programs + Programs []ChatAffiliateProgram + // The offset for the next request. If empty, then there are no more results + NextOffset string +} + +// ChatAffiliateProgramsTypeID is TL type id of ChatAffiliatePrograms. +const ChatAffiliateProgramsTypeID = 0x74f423e2 + +// Ensuring interfaces in compile-time for ChatAffiliatePrograms. +var ( + _ bin.Encoder = &ChatAffiliatePrograms{} + _ bin.Decoder = &ChatAffiliatePrograms{} + _ bin.BareEncoder = &ChatAffiliatePrograms{} + _ bin.BareDecoder = &ChatAffiliatePrograms{} +) + +func (c *ChatAffiliatePrograms) Zero() bool { + if c == nil { + return true + } + if !(c.TotalCount == 0) { + return false + } + if !(c.Programs == nil) { + return false + } + if !(c.NextOffset == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ChatAffiliatePrograms) String() string { + if c == nil { + return "ChatAffiliatePrograms(nil)" + } + type Alias ChatAffiliatePrograms + return fmt.Sprintf("ChatAffiliatePrograms%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ChatAffiliatePrograms) TypeID() uint32 { + return ChatAffiliateProgramsTypeID +} + +// TypeName returns name of type in TL schema. +func (*ChatAffiliatePrograms) TypeName() string { + return "chatAffiliatePrograms" +} + +// TypeInfo returns info about TL type. +func (c *ChatAffiliatePrograms) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "chatAffiliatePrograms", + ID: ChatAffiliateProgramsTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "TotalCount", + SchemaName: "total_count", + }, + { + Name: "Programs", + SchemaName: "programs", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ChatAffiliatePrograms) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliatePrograms#74f423e2 as nil") + } + b.PutID(ChatAffiliateProgramsTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ChatAffiliatePrograms) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliatePrograms#74f423e2 as nil") + } + b.PutInt32(c.TotalCount) + b.PutInt(len(c.Programs)) + for idx, v := range c.Programs { + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare chatAffiliatePrograms#74f423e2: field programs element with index %d: %w", idx, err) + } + } + b.PutString(c.NextOffset) + return nil +} + +// Decode implements bin.Decoder. +func (c *ChatAffiliatePrograms) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliatePrograms#74f423e2 to nil") + } + if err := b.ConsumeID(ChatAffiliateProgramsTypeID); err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ChatAffiliatePrograms) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliatePrograms#74f423e2 to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field total_count: %w", err) + } + c.TotalCount = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field programs: %w", err) + } + + if headerLen > 0 { + c.Programs = make([]ChatAffiliateProgram, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value ChatAffiliateProgram + if err := value.DecodeBare(b); err != nil { + return fmt.Errorf("unable to decode bare chatAffiliatePrograms#74f423e2: field programs: %w", err) + } + c.Programs = append(c.Programs, value) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field next_offset: %w", err) + } + c.NextOffset = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (c *ChatAffiliatePrograms) EncodeTDLibJSON(b tdjson.Encoder) error { + if c == nil { + return fmt.Errorf("can't encode chatAffiliatePrograms#74f423e2 as nil") + } + b.ObjStart() + b.PutID("chatAffiliatePrograms") + b.Comma() + b.FieldStart("total_count") + b.PutInt32(c.TotalCount) + b.Comma() + b.FieldStart("programs") + b.ArrStart() + for idx, v := range c.Programs { + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode chatAffiliatePrograms#74f423e2: field programs element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.FieldStart("next_offset") + b.PutString(c.NextOffset) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (c *ChatAffiliatePrograms) DecodeTDLibJSON(b tdjson.Decoder) error { + if c == nil { + return fmt.Errorf("can't decode chatAffiliatePrograms#74f423e2 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("chatAffiliatePrograms"); err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: %w", err) + } + case "total_count": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field total_count: %w", err) + } + c.TotalCount = value + case "programs": + if err := b.Arr(func(b tdjson.Decoder) error { + var value ChatAffiliateProgram + if err := value.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field programs: %w", err) + } + c.Programs = append(c.Programs, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field programs: %w", err) + } + case "next_offset": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode chatAffiliatePrograms#74f423e2: field next_offset: %w", err) + } + c.NextOffset = value + default: + return b.Skip() + } + return nil + }) +} + +// GetTotalCount returns value of TotalCount field. +func (c *ChatAffiliatePrograms) GetTotalCount() (value int32) { + if c == nil { + return + } + return c.TotalCount +} + +// GetPrograms returns value of Programs field. +func (c *ChatAffiliatePrograms) GetPrograms() (value []ChatAffiliateProgram) { + if c == nil { + return + } + return c.Programs +} + +// GetNextOffset returns value of NextOffset field. +func (c *ChatAffiliatePrograms) GetNextOffset() (value string) { + if c == nil { + return + } + return c.NextOffset +} diff --git a/tdapi/tl_chat_transaction_purpose_gen.go b/tdapi/tl_chat_transaction_purpose_gen.go deleted file mode 100644 index 8fc867fe74..0000000000 --- a/tdapi/tl_chat_transaction_purpose_gen.go +++ /dev/null @@ -1,933 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tdapi - -import ( - "context" - "errors" - "fmt" - "sort" - "strings" - - "go.uber.org/multierr" - - "github.com/gotd/td/bin" - "github.com/gotd/td/tdjson" - "github.com/gotd/td/tdp" - "github.com/gotd/td/tgerr" -) - -// No-op definition for keeping imports. -var ( - _ = bin.Buffer{} - _ = context.Background() - _ = fmt.Stringer(nil) - _ = strings.Builder{} - _ = errors.Is - _ = multierr.AppendInto - _ = sort.Ints - _ = tdp.Format - _ = tgerr.Error{} - _ = tdjson.Encoder{} -) - -// ChatTransactionPurposePaidMedia represents TL type `chatTransactionPurposePaidMedia#d35febb`. -type ChatTransactionPurposePaidMedia struct { - // Identifier of the corresponding message with paid media; can be 0 or an identifier of - // a deleted message - MessageID int64 - // The bought media if the transaction wasn't refunded - Media []PaidMediaClass -} - -// ChatTransactionPurposePaidMediaTypeID is TL type id of ChatTransactionPurposePaidMedia. -const ChatTransactionPurposePaidMediaTypeID = 0xd35febb - -// construct implements constructor of ChatTransactionPurposeClass. -func (c ChatTransactionPurposePaidMedia) construct() ChatTransactionPurposeClass { return &c } - -// Ensuring interfaces in compile-time for ChatTransactionPurposePaidMedia. -var ( - _ bin.Encoder = &ChatTransactionPurposePaidMedia{} - _ bin.Decoder = &ChatTransactionPurposePaidMedia{} - _ bin.BareEncoder = &ChatTransactionPurposePaidMedia{} - _ bin.BareDecoder = &ChatTransactionPurposePaidMedia{} - - _ ChatTransactionPurposeClass = &ChatTransactionPurposePaidMedia{} -) - -func (c *ChatTransactionPurposePaidMedia) Zero() bool { - if c == nil { - return true - } - if !(c.MessageID == 0) { - return false - } - if !(c.Media == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *ChatTransactionPurposePaidMedia) String() string { - if c == nil { - return "ChatTransactionPurposePaidMedia(nil)" - } - type Alias ChatTransactionPurposePaidMedia - return fmt.Sprintf("ChatTransactionPurposePaidMedia%+v", Alias(*c)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*ChatTransactionPurposePaidMedia) TypeID() uint32 { - return ChatTransactionPurposePaidMediaTypeID -} - -// TypeName returns name of type in TL schema. -func (*ChatTransactionPurposePaidMedia) TypeName() string { - return "chatTransactionPurposePaidMedia" -} - -// TypeInfo returns info about TL type. -func (c *ChatTransactionPurposePaidMedia) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "chatTransactionPurposePaidMedia", - ID: ChatTransactionPurposePaidMediaTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "MessageID", - SchemaName: "message_id", - }, - { - Name: "Media", - SchemaName: "media", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *ChatTransactionPurposePaidMedia) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposePaidMedia#d35febb as nil") - } - b.PutID(ChatTransactionPurposePaidMediaTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *ChatTransactionPurposePaidMedia) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposePaidMedia#d35febb as nil") - } - b.PutInt53(c.MessageID) - b.PutInt(len(c.Media)) - for idx, v := range c.Media { - if v == nil { - return fmt.Errorf("unable to encode chatTransactionPurposePaidMedia#d35febb: field media element with index %d is nil", idx) - } - if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare chatTransactionPurposePaidMedia#d35febb: field media element with index %d: %w", idx, err) - } - } - return nil -} - -// Decode implements bin.Decoder. -func (c *ChatTransactionPurposePaidMedia) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposePaidMedia#d35febb to nil") - } - if err := b.ConsumeID(ChatTransactionPurposePaidMediaTypeID); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *ChatTransactionPurposePaidMedia) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposePaidMedia#d35febb to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field message_id: %w", err) - } - c.MessageID = value - } - { - headerLen, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field media: %w", err) - } - - if headerLen > 0 { - c.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodePaidMedia(b) - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field media: %w", err) - } - c.Media = append(c.Media, value) - } - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (c *ChatTransactionPurposePaidMedia) EncodeTDLibJSON(b tdjson.Encoder) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposePaidMedia#d35febb as nil") - } - b.ObjStart() - b.PutID("chatTransactionPurposePaidMedia") - b.Comma() - b.FieldStart("message_id") - b.PutInt53(c.MessageID) - b.Comma() - b.FieldStart("media") - b.ArrStart() - for idx, v := range c.Media { - if v == nil { - return fmt.Errorf("unable to encode chatTransactionPurposePaidMedia#d35febb: field media element with index %d is nil", idx) - } - if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode chatTransactionPurposePaidMedia#d35febb: field media element with index %d: %w", idx, err) - } - b.Comma() - } - b.StripComma() - b.ArrEnd() - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (c *ChatTransactionPurposePaidMedia) DecodeTDLibJSON(b tdjson.Decoder) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposePaidMedia#d35febb to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("chatTransactionPurposePaidMedia"); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: %w", err) - } - case "message_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field message_id: %w", err) - } - c.MessageID = value - case "media": - if err := b.Arr(func(b tdjson.Decoder) error { - value, err := DecodeTDLibJSONPaidMedia(b) - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field media: %w", err) - } - c.Media = append(c.Media, value) - return nil - }); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposePaidMedia#d35febb: field media: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// GetMessageID returns value of MessageID field. -func (c *ChatTransactionPurposePaidMedia) GetMessageID() (value int64) { - if c == nil { - return - } - return c.MessageID -} - -// GetMedia returns value of Media field. -func (c *ChatTransactionPurposePaidMedia) GetMedia() (value []PaidMediaClass) { - if c == nil { - return - } - return c.Media -} - -// ChatTransactionPurposeJoin represents TL type `chatTransactionPurposeJoin#5b31327a`. -type ChatTransactionPurposeJoin struct { - // The number of seconds between consecutive Telegram Star debiting - Period int32 -} - -// ChatTransactionPurposeJoinTypeID is TL type id of ChatTransactionPurposeJoin. -const ChatTransactionPurposeJoinTypeID = 0x5b31327a - -// construct implements constructor of ChatTransactionPurposeClass. -func (c ChatTransactionPurposeJoin) construct() ChatTransactionPurposeClass { return &c } - -// Ensuring interfaces in compile-time for ChatTransactionPurposeJoin. -var ( - _ bin.Encoder = &ChatTransactionPurposeJoin{} - _ bin.Decoder = &ChatTransactionPurposeJoin{} - _ bin.BareEncoder = &ChatTransactionPurposeJoin{} - _ bin.BareDecoder = &ChatTransactionPurposeJoin{} - - _ ChatTransactionPurposeClass = &ChatTransactionPurposeJoin{} -) - -func (c *ChatTransactionPurposeJoin) Zero() bool { - if c == nil { - return true - } - if !(c.Period == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *ChatTransactionPurposeJoin) String() string { - if c == nil { - return "ChatTransactionPurposeJoin(nil)" - } - type Alias ChatTransactionPurposeJoin - return fmt.Sprintf("ChatTransactionPurposeJoin%+v", Alias(*c)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*ChatTransactionPurposeJoin) TypeID() uint32 { - return ChatTransactionPurposeJoinTypeID -} - -// TypeName returns name of type in TL schema. -func (*ChatTransactionPurposeJoin) TypeName() string { - return "chatTransactionPurposeJoin" -} - -// TypeInfo returns info about TL type. -func (c *ChatTransactionPurposeJoin) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "chatTransactionPurposeJoin", - ID: ChatTransactionPurposeJoinTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Period", - SchemaName: "period", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *ChatTransactionPurposeJoin) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeJoin#5b31327a as nil") - } - b.PutID(ChatTransactionPurposeJoinTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *ChatTransactionPurposeJoin) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeJoin#5b31327a as nil") - } - b.PutInt32(c.Period) - return nil -} - -// Decode implements bin.Decoder. -func (c *ChatTransactionPurposeJoin) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeJoin#5b31327a to nil") - } - if err := b.ConsumeID(ChatTransactionPurposeJoinTypeID); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeJoin#5b31327a: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *ChatTransactionPurposeJoin) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeJoin#5b31327a to nil") - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeJoin#5b31327a: field period: %w", err) - } - c.Period = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (c *ChatTransactionPurposeJoin) EncodeTDLibJSON(b tdjson.Encoder) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeJoin#5b31327a as nil") - } - b.ObjStart() - b.PutID("chatTransactionPurposeJoin") - b.Comma() - b.FieldStart("period") - b.PutInt32(c.Period) - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (c *ChatTransactionPurposeJoin) DecodeTDLibJSON(b tdjson.Decoder) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeJoin#5b31327a to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("chatTransactionPurposeJoin"); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeJoin#5b31327a: %w", err) - } - case "period": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeJoin#5b31327a: field period: %w", err) - } - c.Period = value - default: - return b.Skip() - } - return nil - }) -} - -// GetPeriod returns value of Period field. -func (c *ChatTransactionPurposeJoin) GetPeriod() (value int32) { - if c == nil { - return - } - return c.Period -} - -// ChatTransactionPurposeReaction represents TL type `chatTransactionPurposeReaction#7a5f9888`. -type ChatTransactionPurposeReaction struct { - // Identifier of the reacted message; can be 0 or an identifier of a deleted message - MessageID int64 -} - -// ChatTransactionPurposeReactionTypeID is TL type id of ChatTransactionPurposeReaction. -const ChatTransactionPurposeReactionTypeID = 0x7a5f9888 - -// construct implements constructor of ChatTransactionPurposeClass. -func (c ChatTransactionPurposeReaction) construct() ChatTransactionPurposeClass { return &c } - -// Ensuring interfaces in compile-time for ChatTransactionPurposeReaction. -var ( - _ bin.Encoder = &ChatTransactionPurposeReaction{} - _ bin.Decoder = &ChatTransactionPurposeReaction{} - _ bin.BareEncoder = &ChatTransactionPurposeReaction{} - _ bin.BareDecoder = &ChatTransactionPurposeReaction{} - - _ ChatTransactionPurposeClass = &ChatTransactionPurposeReaction{} -) - -func (c *ChatTransactionPurposeReaction) Zero() bool { - if c == nil { - return true - } - if !(c.MessageID == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *ChatTransactionPurposeReaction) String() string { - if c == nil { - return "ChatTransactionPurposeReaction(nil)" - } - type Alias ChatTransactionPurposeReaction - return fmt.Sprintf("ChatTransactionPurposeReaction%+v", Alias(*c)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*ChatTransactionPurposeReaction) TypeID() uint32 { - return ChatTransactionPurposeReactionTypeID -} - -// TypeName returns name of type in TL schema. -func (*ChatTransactionPurposeReaction) TypeName() string { - return "chatTransactionPurposeReaction" -} - -// TypeInfo returns info about TL type. -func (c *ChatTransactionPurposeReaction) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "chatTransactionPurposeReaction", - ID: ChatTransactionPurposeReactionTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "MessageID", - SchemaName: "message_id", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *ChatTransactionPurposeReaction) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeReaction#7a5f9888 as nil") - } - b.PutID(ChatTransactionPurposeReactionTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *ChatTransactionPurposeReaction) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeReaction#7a5f9888 as nil") - } - b.PutInt53(c.MessageID) - return nil -} - -// Decode implements bin.Decoder. -func (c *ChatTransactionPurposeReaction) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeReaction#7a5f9888 to nil") - } - if err := b.ConsumeID(ChatTransactionPurposeReactionTypeID); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeReaction#7a5f9888: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *ChatTransactionPurposeReaction) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeReaction#7a5f9888 to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeReaction#7a5f9888: field message_id: %w", err) - } - c.MessageID = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (c *ChatTransactionPurposeReaction) EncodeTDLibJSON(b tdjson.Encoder) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeReaction#7a5f9888 as nil") - } - b.ObjStart() - b.PutID("chatTransactionPurposeReaction") - b.Comma() - b.FieldStart("message_id") - b.PutInt53(c.MessageID) - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (c *ChatTransactionPurposeReaction) DecodeTDLibJSON(b tdjson.Decoder) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeReaction#7a5f9888 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("chatTransactionPurposeReaction"); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeReaction#7a5f9888: %w", err) - } - case "message_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeReaction#7a5f9888: field message_id: %w", err) - } - c.MessageID = value - default: - return b.Skip() - } - return nil - }) -} - -// GetMessageID returns value of MessageID field. -func (c *ChatTransactionPurposeReaction) GetMessageID() (value int64) { - if c == nil { - return - } - return c.MessageID -} - -// ChatTransactionPurposeGiveaway represents TL type `chatTransactionPurposeGiveaway#384c8b7f`. -type ChatTransactionPurposeGiveaway struct { - // Identifier of the message with giveaway; can be 0 or an identifier of a deleted - // message - GiveawayMessageID int64 -} - -// ChatTransactionPurposeGiveawayTypeID is TL type id of ChatTransactionPurposeGiveaway. -const ChatTransactionPurposeGiveawayTypeID = 0x384c8b7f - -// construct implements constructor of ChatTransactionPurposeClass. -func (c ChatTransactionPurposeGiveaway) construct() ChatTransactionPurposeClass { return &c } - -// Ensuring interfaces in compile-time for ChatTransactionPurposeGiveaway. -var ( - _ bin.Encoder = &ChatTransactionPurposeGiveaway{} - _ bin.Decoder = &ChatTransactionPurposeGiveaway{} - _ bin.BareEncoder = &ChatTransactionPurposeGiveaway{} - _ bin.BareDecoder = &ChatTransactionPurposeGiveaway{} - - _ ChatTransactionPurposeClass = &ChatTransactionPurposeGiveaway{} -) - -func (c *ChatTransactionPurposeGiveaway) Zero() bool { - if c == nil { - return true - } - if !(c.GiveawayMessageID == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (c *ChatTransactionPurposeGiveaway) String() string { - if c == nil { - return "ChatTransactionPurposeGiveaway(nil)" - } - type Alias ChatTransactionPurposeGiveaway - return fmt.Sprintf("ChatTransactionPurposeGiveaway%+v", Alias(*c)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*ChatTransactionPurposeGiveaway) TypeID() uint32 { - return ChatTransactionPurposeGiveawayTypeID -} - -// TypeName returns name of type in TL schema. -func (*ChatTransactionPurposeGiveaway) TypeName() string { - return "chatTransactionPurposeGiveaway" -} - -// TypeInfo returns info about TL type. -func (c *ChatTransactionPurposeGiveaway) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "chatTransactionPurposeGiveaway", - ID: ChatTransactionPurposeGiveawayTypeID, - } - if c == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "GiveawayMessageID", - SchemaName: "giveaway_message_id", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (c *ChatTransactionPurposeGiveaway) Encode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeGiveaway#384c8b7f as nil") - } - b.PutID(ChatTransactionPurposeGiveawayTypeID) - return c.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (c *ChatTransactionPurposeGiveaway) EncodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeGiveaway#384c8b7f as nil") - } - b.PutInt53(c.GiveawayMessageID) - return nil -} - -// Decode implements bin.Decoder. -func (c *ChatTransactionPurposeGiveaway) Decode(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeGiveaway#384c8b7f to nil") - } - if err := b.ConsumeID(ChatTransactionPurposeGiveawayTypeID); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeGiveaway#384c8b7f: %w", err) - } - return c.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (c *ChatTransactionPurposeGiveaway) DecodeBare(b *bin.Buffer) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeGiveaway#384c8b7f to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeGiveaway#384c8b7f: field giveaway_message_id: %w", err) - } - c.GiveawayMessageID = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (c *ChatTransactionPurposeGiveaway) EncodeTDLibJSON(b tdjson.Encoder) error { - if c == nil { - return fmt.Errorf("can't encode chatTransactionPurposeGiveaway#384c8b7f as nil") - } - b.ObjStart() - b.PutID("chatTransactionPurposeGiveaway") - b.Comma() - b.FieldStart("giveaway_message_id") - b.PutInt53(c.GiveawayMessageID) - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (c *ChatTransactionPurposeGiveaway) DecodeTDLibJSON(b tdjson.Decoder) error { - if c == nil { - return fmt.Errorf("can't decode chatTransactionPurposeGiveaway#384c8b7f to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("chatTransactionPurposeGiveaway"); err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeGiveaway#384c8b7f: %w", err) - } - case "giveaway_message_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode chatTransactionPurposeGiveaway#384c8b7f: field giveaway_message_id: %w", err) - } - c.GiveawayMessageID = value - default: - return b.Skip() - } - return nil - }) -} - -// GetGiveawayMessageID returns value of GiveawayMessageID field. -func (c *ChatTransactionPurposeGiveaway) GetGiveawayMessageID() (value int64) { - if c == nil { - return - } - return c.GiveawayMessageID -} - -// ChatTransactionPurposeClassName is schema name of ChatTransactionPurposeClass. -const ChatTransactionPurposeClassName = "ChatTransactionPurpose" - -// ChatTransactionPurposeClass represents ChatTransactionPurpose generic type. -// -// Example: -// -// g, err := tdapi.DecodeChatTransactionPurpose(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tdapi.ChatTransactionPurposePaidMedia: // chatTransactionPurposePaidMedia#d35febb -// case *tdapi.ChatTransactionPurposeJoin: // chatTransactionPurposeJoin#5b31327a -// case *tdapi.ChatTransactionPurposeReaction: // chatTransactionPurposeReaction#7a5f9888 -// case *tdapi.ChatTransactionPurposeGiveaway: // chatTransactionPurposeGiveaway#384c8b7f -// default: panic(v) -// } -type ChatTransactionPurposeClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() ChatTransactionPurposeClass - - // TypeID returns type id in TL schema. - // - // See https://core.telegram.org/mtproto/TL-tl#remarks. - TypeID() uint32 - // TypeName returns name of type in TL schema. - TypeName() string - // String implements fmt.Stringer. - String() string - // Zero returns true if current object has a zero value. - Zero() bool - - EncodeTDLibJSON(b tdjson.Encoder) error - DecodeTDLibJSON(b tdjson.Decoder) error -} - -// DecodeChatTransactionPurpose implements binary de-serialization for ChatTransactionPurposeClass. -func DecodeChatTransactionPurpose(buf *bin.Buffer) (ChatTransactionPurposeClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case ChatTransactionPurposePaidMediaTypeID: - // Decoding chatTransactionPurposePaidMedia#d35febb. - v := ChatTransactionPurposePaidMedia{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case ChatTransactionPurposeJoinTypeID: - // Decoding chatTransactionPurposeJoin#5b31327a. - v := ChatTransactionPurposeJoin{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case ChatTransactionPurposeReactionTypeID: - // Decoding chatTransactionPurposeReaction#7a5f9888. - v := ChatTransactionPurposeReaction{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case ChatTransactionPurposeGiveawayTypeID: - // Decoding chatTransactionPurposeGiveaway#384c8b7f. - v := ChatTransactionPurposeGiveaway{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", bin.NewUnexpectedID(id)) - } -} - -// DecodeTDLibJSONChatTransactionPurpose implements binary de-serialization for ChatTransactionPurposeClass. -func DecodeTDLibJSONChatTransactionPurpose(buf tdjson.Decoder) (ChatTransactionPurposeClass, error) { - id, err := buf.FindTypeID() - if err != nil { - return nil, err - } - switch id { - case "chatTransactionPurposePaidMedia": - // Decoding chatTransactionPurposePaidMedia#d35febb. - v := ChatTransactionPurposePaidMedia{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case "chatTransactionPurposeJoin": - // Decoding chatTransactionPurposeJoin#5b31327a. - v := ChatTransactionPurposeJoin{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case "chatTransactionPurposeReaction": - // Decoding chatTransactionPurposeReaction#7a5f9888. - v := ChatTransactionPurposeReaction{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - case "chatTransactionPurposeGiveaway": - // Decoding chatTransactionPurposeGiveaway#384c8b7f. - v := ChatTransactionPurposeGiveaway{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode ChatTransactionPurposeClass: %w", tdjson.NewUnexpectedID(id)) - } -} - -// ChatTransactionPurpose boxes the ChatTransactionPurposeClass providing a helper. -type ChatTransactionPurposeBox struct { - ChatTransactionPurpose ChatTransactionPurposeClass -} - -// Decode implements bin.Decoder for ChatTransactionPurposeBox. -func (b *ChatTransactionPurposeBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode ChatTransactionPurposeBox to nil") - } - v, err := DecodeChatTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.ChatTransactionPurpose = v - return nil -} - -// Encode implements bin.Encode for ChatTransactionPurposeBox. -func (b *ChatTransactionPurposeBox) Encode(buf *bin.Buffer) error { - if b == nil || b.ChatTransactionPurpose == nil { - return fmt.Errorf("unable to encode ChatTransactionPurposeClass as nil") - } - return b.ChatTransactionPurpose.Encode(buf) -} - -// DecodeTDLibJSON implements bin.Decoder for ChatTransactionPurposeBox. -func (b *ChatTransactionPurposeBox) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("unable to decode ChatTransactionPurposeBox to nil") - } - v, err := DecodeTDLibJSONChatTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.ChatTransactionPurpose = v - return nil -} - -// EncodeTDLibJSON implements bin.Encode for ChatTransactionPurposeBox. -func (b *ChatTransactionPurposeBox) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil || b.ChatTransactionPurpose == nil { - return fmt.Errorf("unable to encode ChatTransactionPurposeClass as nil") - } - return b.ChatTransactionPurpose.EncodeTDLibJSON(buf) -} diff --git a/tdapi/tl_connect_chat_affiliate_program_gen.go b/tdapi/tl_connect_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..d9be27a544 --- /dev/null +++ b/tdapi/tl_connect_chat_affiliate_program_gen.go @@ -0,0 +1,239 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// ConnectChatAffiliateProgramRequest represents TL type `connectChatAffiliateProgram#75b163c4`. +type ConnectChatAffiliateProgramRequest struct { + // Identifier of the chat to which the affiliate program will be connected. Can be an + // identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel + // chat with can_post_messages administrator right + ChatID int64 + // Identifier of the bot, which affiliate program is connected + BotUserID int64 +} + +// ConnectChatAffiliateProgramRequestTypeID is TL type id of ConnectChatAffiliateProgramRequest. +const ConnectChatAffiliateProgramRequestTypeID = 0x75b163c4 + +// Ensuring interfaces in compile-time for ConnectChatAffiliateProgramRequest. +var ( + _ bin.Encoder = &ConnectChatAffiliateProgramRequest{} + _ bin.Decoder = &ConnectChatAffiliateProgramRequest{} + _ bin.BareEncoder = &ConnectChatAffiliateProgramRequest{} + _ bin.BareDecoder = &ConnectChatAffiliateProgramRequest{} +) + +func (c *ConnectChatAffiliateProgramRequest) Zero() bool { + if c == nil { + return true + } + if !(c.ChatID == 0) { + return false + } + if !(c.BotUserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (c *ConnectChatAffiliateProgramRequest) String() string { + if c == nil { + return "ConnectChatAffiliateProgramRequest(nil)" + } + type Alias ConnectChatAffiliateProgramRequest + return fmt.Sprintf("ConnectChatAffiliateProgramRequest%+v", Alias(*c)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*ConnectChatAffiliateProgramRequest) TypeID() uint32 { + return ConnectChatAffiliateProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*ConnectChatAffiliateProgramRequest) TypeName() string { + return "connectChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (c *ConnectChatAffiliateProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "connectChatAffiliateProgram", + ID: ConnectChatAffiliateProgramRequestTypeID, + } + if c == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (c *ConnectChatAffiliateProgramRequest) Encode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode connectChatAffiliateProgram#75b163c4 as nil") + } + b.PutID(ConnectChatAffiliateProgramRequestTypeID) + return c.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (c *ConnectChatAffiliateProgramRequest) EncodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't encode connectChatAffiliateProgram#75b163c4 as nil") + } + b.PutInt53(c.ChatID) + b.PutInt53(c.BotUserID) + return nil +} + +// Decode implements bin.Decoder. +func (c *ConnectChatAffiliateProgramRequest) Decode(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode connectChatAffiliateProgram#75b163c4 to nil") + } + if err := b.ConsumeID(ConnectChatAffiliateProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: %w", err) + } + return c.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (c *ConnectChatAffiliateProgramRequest) DecodeBare(b *bin.Buffer) error { + if c == nil { + return fmt.Errorf("can't decode connectChatAffiliateProgram#75b163c4 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: field chat_id: %w", err) + } + c.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: field bot_user_id: %w", err) + } + c.BotUserID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (c *ConnectChatAffiliateProgramRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if c == nil { + return fmt.Errorf("can't encode connectChatAffiliateProgram#75b163c4 as nil") + } + b.ObjStart() + b.PutID("connectChatAffiliateProgram") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(c.ChatID) + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(c.BotUserID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (c *ConnectChatAffiliateProgramRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if c == nil { + return fmt.Errorf("can't decode connectChatAffiliateProgram#75b163c4 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("connectChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: field chat_id: %w", err) + } + c.ChatID = value + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode connectChatAffiliateProgram#75b163c4: field bot_user_id: %w", err) + } + c.BotUserID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (c *ConnectChatAffiliateProgramRequest) GetChatID() (value int64) { + if c == nil { + return + } + return c.ChatID +} + +// GetBotUserID returns value of BotUserID field. +func (c *ConnectChatAffiliateProgramRequest) GetBotUserID() (value int64) { + if c == nil { + return + } + return c.BotUserID +} + +// ConnectChatAffiliateProgram invokes method connectChatAffiliateProgram#75b163c4 returning error if any. +func (c *Client) ConnectChatAffiliateProgram(ctx context.Context, request *ConnectChatAffiliateProgramRequest) (*ChatAffiliateProgram, error) { + var result ChatAffiliateProgram + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_create_video_chat_gen.go b/tdapi/tl_create_video_chat_gen.go index 5f013b2d1d..8c7dcd4da1 100644 --- a/tdapi/tl_create_video_chat_gen.go +++ b/tdapi/tl_create_video_chat_gen.go @@ -41,8 +41,7 @@ type CreateVideoChatRequest struct { // administrator; 0 to start the video chat immediately. The date must be at least 10 // seconds and at most 8 days in the future StartDate int32 - // Pass true to create an RTMP stream instead of an ordinary video chat; requires owner - // privileges + // Pass true to create an RTMP stream instead of an ordinary video chat IsRtmpStream bool } diff --git a/tdapi/tl_disconnect_chat_affiliate_program_gen.go b/tdapi/tl_disconnect_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..fbbc308723 --- /dev/null +++ b/tdapi/tl_disconnect_chat_affiliate_program_gen.go @@ -0,0 +1,237 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// DisconnectChatAffiliateProgramRequest represents TL type `disconnectChatAffiliateProgram#48ef7257`. +type DisconnectChatAffiliateProgramRequest struct { + // Identifier of the chat for which the affiliate program is connected + ChatID int64 + // The referral link of the affiliate program + URL string +} + +// DisconnectChatAffiliateProgramRequestTypeID is TL type id of DisconnectChatAffiliateProgramRequest. +const DisconnectChatAffiliateProgramRequestTypeID = 0x48ef7257 + +// Ensuring interfaces in compile-time for DisconnectChatAffiliateProgramRequest. +var ( + _ bin.Encoder = &DisconnectChatAffiliateProgramRequest{} + _ bin.Decoder = &DisconnectChatAffiliateProgramRequest{} + _ bin.BareEncoder = &DisconnectChatAffiliateProgramRequest{} + _ bin.BareDecoder = &DisconnectChatAffiliateProgramRequest{} +) + +func (d *DisconnectChatAffiliateProgramRequest) Zero() bool { + if d == nil { + return true + } + if !(d.ChatID == 0) { + return false + } + if !(d.URL == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (d *DisconnectChatAffiliateProgramRequest) String() string { + if d == nil { + return "DisconnectChatAffiliateProgramRequest(nil)" + } + type Alias DisconnectChatAffiliateProgramRequest + return fmt.Sprintf("DisconnectChatAffiliateProgramRequest%+v", Alias(*d)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*DisconnectChatAffiliateProgramRequest) TypeID() uint32 { + return DisconnectChatAffiliateProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*DisconnectChatAffiliateProgramRequest) TypeName() string { + return "disconnectChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (d *DisconnectChatAffiliateProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "disconnectChatAffiliateProgram", + ID: DisconnectChatAffiliateProgramRequestTypeID, + } + if d == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "URL", + SchemaName: "url", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (d *DisconnectChatAffiliateProgramRequest) Encode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode disconnectChatAffiliateProgram#48ef7257 as nil") + } + b.PutID(DisconnectChatAffiliateProgramRequestTypeID) + return d.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (d *DisconnectChatAffiliateProgramRequest) EncodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't encode disconnectChatAffiliateProgram#48ef7257 as nil") + } + b.PutInt53(d.ChatID) + b.PutString(d.URL) + return nil +} + +// Decode implements bin.Decoder. +func (d *DisconnectChatAffiliateProgramRequest) Decode(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode disconnectChatAffiliateProgram#48ef7257 to nil") + } + if err := b.ConsumeID(DisconnectChatAffiliateProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: %w", err) + } + return d.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (d *DisconnectChatAffiliateProgramRequest) DecodeBare(b *bin.Buffer) error { + if d == nil { + return fmt.Errorf("can't decode disconnectChatAffiliateProgram#48ef7257 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: field chat_id: %w", err) + } + d.ChatID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: field url: %w", err) + } + d.URL = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (d *DisconnectChatAffiliateProgramRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if d == nil { + return fmt.Errorf("can't encode disconnectChatAffiliateProgram#48ef7257 as nil") + } + b.ObjStart() + b.PutID("disconnectChatAffiliateProgram") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(d.ChatID) + b.Comma() + b.FieldStart("url") + b.PutString(d.URL) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (d *DisconnectChatAffiliateProgramRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if d == nil { + return fmt.Errorf("can't decode disconnectChatAffiliateProgram#48ef7257 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("disconnectChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: field chat_id: %w", err) + } + d.ChatID = value + case "url": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode disconnectChatAffiliateProgram#48ef7257: field url: %w", err) + } + d.URL = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (d *DisconnectChatAffiliateProgramRequest) GetChatID() (value int64) { + if d == nil { + return + } + return d.ChatID +} + +// GetURL returns value of URL field. +func (d *DisconnectChatAffiliateProgramRequest) GetURL() (value string) { + if d == nil { + return + } + return d.URL +} + +// DisconnectChatAffiliateProgram invokes method disconnectChatAffiliateProgram#48ef7257 returning error if any. +func (c *Client) DisconnectChatAffiliateProgram(ctx context.Context, request *DisconnectChatAffiliateProgramRequest) (*ChatAffiliateProgram, error) { + var result ChatAffiliateProgram + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_file_type_gen.go b/tdapi/tl_file_type_gen.go index a64bce77ca..0402253c97 100644 --- a/tdapi/tl_file_type_gen.go +++ b/tdapi/tl_file_type_gen.go @@ -1472,6 +1472,530 @@ func (f *FileTypeSecure) DecodeTDLibJSON(b tdjson.Decoder) error { }) } +// FileTypeSelfDestructingPhoto represents TL type `fileTypeSelfDestructingPhoto#7bcf329b`. +type FileTypeSelfDestructingPhoto struct { +} + +// FileTypeSelfDestructingPhotoTypeID is TL type id of FileTypeSelfDestructingPhoto. +const FileTypeSelfDestructingPhotoTypeID = 0x7bcf329b + +// construct implements constructor of FileTypeClass. +func (f FileTypeSelfDestructingPhoto) construct() FileTypeClass { return &f } + +// Ensuring interfaces in compile-time for FileTypeSelfDestructingPhoto. +var ( + _ bin.Encoder = &FileTypeSelfDestructingPhoto{} + _ bin.Decoder = &FileTypeSelfDestructingPhoto{} + _ bin.BareEncoder = &FileTypeSelfDestructingPhoto{} + _ bin.BareDecoder = &FileTypeSelfDestructingPhoto{} + + _ FileTypeClass = &FileTypeSelfDestructingPhoto{} +) + +func (f *FileTypeSelfDestructingPhoto) Zero() bool { + if f == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (f *FileTypeSelfDestructingPhoto) String() string { + if f == nil { + return "FileTypeSelfDestructingPhoto(nil)" + } + type Alias FileTypeSelfDestructingPhoto + return fmt.Sprintf("FileTypeSelfDestructingPhoto%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FileTypeSelfDestructingPhoto) TypeID() uint32 { + return FileTypeSelfDestructingPhotoTypeID +} + +// TypeName returns name of type in TL schema. +func (*FileTypeSelfDestructingPhoto) TypeName() string { + return "fileTypeSelfDestructingPhoto" +} + +// TypeInfo returns info about TL type. +func (f *FileTypeSelfDestructingPhoto) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "fileTypeSelfDestructingPhoto", + ID: FileTypeSelfDestructingPhotoTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (f *FileTypeSelfDestructingPhoto) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingPhoto#7bcf329b as nil") + } + b.PutID(FileTypeSelfDestructingPhotoTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FileTypeSelfDestructingPhoto) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingPhoto#7bcf329b as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FileTypeSelfDestructingPhoto) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingPhoto#7bcf329b to nil") + } + if err := b.ConsumeID(FileTypeSelfDestructingPhotoTypeID); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingPhoto#7bcf329b: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FileTypeSelfDestructingPhoto) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingPhoto#7bcf329b to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FileTypeSelfDestructingPhoto) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingPhoto#7bcf329b as nil") + } + b.ObjStart() + b.PutID("fileTypeSelfDestructingPhoto") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FileTypeSelfDestructingPhoto) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingPhoto#7bcf329b to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("fileTypeSelfDestructingPhoto"); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingPhoto#7bcf329b: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// FileTypeSelfDestructingVideo represents TL type `fileTypeSelfDestructingVideo#b70cc425`. +type FileTypeSelfDestructingVideo struct { +} + +// FileTypeSelfDestructingVideoTypeID is TL type id of FileTypeSelfDestructingVideo. +const FileTypeSelfDestructingVideoTypeID = 0xb70cc425 + +// construct implements constructor of FileTypeClass. +func (f FileTypeSelfDestructingVideo) construct() FileTypeClass { return &f } + +// Ensuring interfaces in compile-time for FileTypeSelfDestructingVideo. +var ( + _ bin.Encoder = &FileTypeSelfDestructingVideo{} + _ bin.Decoder = &FileTypeSelfDestructingVideo{} + _ bin.BareEncoder = &FileTypeSelfDestructingVideo{} + _ bin.BareDecoder = &FileTypeSelfDestructingVideo{} + + _ FileTypeClass = &FileTypeSelfDestructingVideo{} +) + +func (f *FileTypeSelfDestructingVideo) Zero() bool { + if f == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (f *FileTypeSelfDestructingVideo) String() string { + if f == nil { + return "FileTypeSelfDestructingVideo(nil)" + } + type Alias FileTypeSelfDestructingVideo + return fmt.Sprintf("FileTypeSelfDestructingVideo%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FileTypeSelfDestructingVideo) TypeID() uint32 { + return FileTypeSelfDestructingVideoTypeID +} + +// TypeName returns name of type in TL schema. +func (*FileTypeSelfDestructingVideo) TypeName() string { + return "fileTypeSelfDestructingVideo" +} + +// TypeInfo returns info about TL type. +func (f *FileTypeSelfDestructingVideo) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "fileTypeSelfDestructingVideo", + ID: FileTypeSelfDestructingVideoTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (f *FileTypeSelfDestructingVideo) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideo#b70cc425 as nil") + } + b.PutID(FileTypeSelfDestructingVideoTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FileTypeSelfDestructingVideo) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideo#b70cc425 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FileTypeSelfDestructingVideo) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideo#b70cc425 to nil") + } + if err := b.ConsumeID(FileTypeSelfDestructingVideoTypeID); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVideo#b70cc425: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FileTypeSelfDestructingVideo) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideo#b70cc425 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FileTypeSelfDestructingVideo) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideo#b70cc425 as nil") + } + b.ObjStart() + b.PutID("fileTypeSelfDestructingVideo") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FileTypeSelfDestructingVideo) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideo#b70cc425 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("fileTypeSelfDestructingVideo"); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVideo#b70cc425: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// FileTypeSelfDestructingVideoNote represents TL type `fileTypeSelfDestructingVideoNote#592012c1`. +type FileTypeSelfDestructingVideoNote struct { +} + +// FileTypeSelfDestructingVideoNoteTypeID is TL type id of FileTypeSelfDestructingVideoNote. +const FileTypeSelfDestructingVideoNoteTypeID = 0x592012c1 + +// construct implements constructor of FileTypeClass. +func (f FileTypeSelfDestructingVideoNote) construct() FileTypeClass { return &f } + +// Ensuring interfaces in compile-time for FileTypeSelfDestructingVideoNote. +var ( + _ bin.Encoder = &FileTypeSelfDestructingVideoNote{} + _ bin.Decoder = &FileTypeSelfDestructingVideoNote{} + _ bin.BareEncoder = &FileTypeSelfDestructingVideoNote{} + _ bin.BareDecoder = &FileTypeSelfDestructingVideoNote{} + + _ FileTypeClass = &FileTypeSelfDestructingVideoNote{} +) + +func (f *FileTypeSelfDestructingVideoNote) Zero() bool { + if f == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (f *FileTypeSelfDestructingVideoNote) String() string { + if f == nil { + return "FileTypeSelfDestructingVideoNote(nil)" + } + type Alias FileTypeSelfDestructingVideoNote + return fmt.Sprintf("FileTypeSelfDestructingVideoNote%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FileTypeSelfDestructingVideoNote) TypeID() uint32 { + return FileTypeSelfDestructingVideoNoteTypeID +} + +// TypeName returns name of type in TL schema. +func (*FileTypeSelfDestructingVideoNote) TypeName() string { + return "fileTypeSelfDestructingVideoNote" +} + +// TypeInfo returns info about TL type. +func (f *FileTypeSelfDestructingVideoNote) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "fileTypeSelfDestructingVideoNote", + ID: FileTypeSelfDestructingVideoNoteTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (f *FileTypeSelfDestructingVideoNote) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideoNote#592012c1 as nil") + } + b.PutID(FileTypeSelfDestructingVideoNoteTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FileTypeSelfDestructingVideoNote) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideoNote#592012c1 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FileTypeSelfDestructingVideoNote) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideoNote#592012c1 to nil") + } + if err := b.ConsumeID(FileTypeSelfDestructingVideoNoteTypeID); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVideoNote#592012c1: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FileTypeSelfDestructingVideoNote) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideoNote#592012c1 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FileTypeSelfDestructingVideoNote) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVideoNote#592012c1 as nil") + } + b.ObjStart() + b.PutID("fileTypeSelfDestructingVideoNote") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FileTypeSelfDestructingVideoNote) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVideoNote#592012c1 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("fileTypeSelfDestructingVideoNote"); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVideoNote#592012c1: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// FileTypeSelfDestructingVoiceNote represents TL type `fileTypeSelfDestructingVoiceNote#64d0db1d`. +type FileTypeSelfDestructingVoiceNote struct { +} + +// FileTypeSelfDestructingVoiceNoteTypeID is TL type id of FileTypeSelfDestructingVoiceNote. +const FileTypeSelfDestructingVoiceNoteTypeID = 0x64d0db1d + +// construct implements constructor of FileTypeClass. +func (f FileTypeSelfDestructingVoiceNote) construct() FileTypeClass { return &f } + +// Ensuring interfaces in compile-time for FileTypeSelfDestructingVoiceNote. +var ( + _ bin.Encoder = &FileTypeSelfDestructingVoiceNote{} + _ bin.Decoder = &FileTypeSelfDestructingVoiceNote{} + _ bin.BareEncoder = &FileTypeSelfDestructingVoiceNote{} + _ bin.BareDecoder = &FileTypeSelfDestructingVoiceNote{} + + _ FileTypeClass = &FileTypeSelfDestructingVoiceNote{} +) + +func (f *FileTypeSelfDestructingVoiceNote) Zero() bool { + if f == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (f *FileTypeSelfDestructingVoiceNote) String() string { + if f == nil { + return "FileTypeSelfDestructingVoiceNote(nil)" + } + type Alias FileTypeSelfDestructingVoiceNote + return fmt.Sprintf("FileTypeSelfDestructingVoiceNote%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FileTypeSelfDestructingVoiceNote) TypeID() uint32 { + return FileTypeSelfDestructingVoiceNoteTypeID +} + +// TypeName returns name of type in TL schema. +func (*FileTypeSelfDestructingVoiceNote) TypeName() string { + return "fileTypeSelfDestructingVoiceNote" +} + +// TypeInfo returns info about TL type. +func (f *FileTypeSelfDestructingVoiceNote) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "fileTypeSelfDestructingVoiceNote", + ID: FileTypeSelfDestructingVoiceNoteTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (f *FileTypeSelfDestructingVoiceNote) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVoiceNote#64d0db1d as nil") + } + b.PutID(FileTypeSelfDestructingVoiceNoteTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FileTypeSelfDestructingVoiceNote) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVoiceNote#64d0db1d as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FileTypeSelfDestructingVoiceNote) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVoiceNote#64d0db1d to nil") + } + if err := b.ConsumeID(FileTypeSelfDestructingVoiceNoteTypeID); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVoiceNote#64d0db1d: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FileTypeSelfDestructingVoiceNote) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVoiceNote#64d0db1d to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FileTypeSelfDestructingVoiceNote) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode fileTypeSelfDestructingVoiceNote#64d0db1d as nil") + } + b.ObjStart() + b.PutID("fileTypeSelfDestructingVoiceNote") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FileTypeSelfDestructingVoiceNote) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode fileTypeSelfDestructingVoiceNote#64d0db1d to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("fileTypeSelfDestructingVoiceNote"); err != nil { + return fmt.Errorf("unable to decode fileTypeSelfDestructingVoiceNote#64d0db1d: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + // FileTypeSticker represents TL type `fileTypeSticker#1c537c69`. type FileTypeSticker struct { } @@ -2543,6 +3067,10 @@ const FileTypeClassName = "FileType" // case *tdapi.FileTypeSecret: // fileTypeSecret#906d14f7 // case *tdapi.FileTypeSecretThumbnail: // fileTypeSecretThumbnail#ac797636 // case *tdapi.FileTypeSecure: // fileTypeSecure#ab69bf26 +// case *tdapi.FileTypeSelfDestructingPhoto: // fileTypeSelfDestructingPhoto#7bcf329b +// case *tdapi.FileTypeSelfDestructingVideo: // fileTypeSelfDestructingVideo#b70cc425 +// case *tdapi.FileTypeSelfDestructingVideoNote: // fileTypeSelfDestructingVideoNote#592012c1 +// case *tdapi.FileTypeSelfDestructingVoiceNote: // fileTypeSelfDestructingVoiceNote#64d0db1d // case *tdapi.FileTypeSticker: // fileTypeSticker#1c537c69 // case *tdapi.FileTypeThumbnail: // fileTypeThumbnail#ff42215e // case *tdapi.FileTypeUnknown: // fileTypeUnknown#8819ed50 @@ -2659,6 +3187,34 @@ func DecodeFileType(buf *bin.Buffer) (FileTypeClass, error) { return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) } return &v, nil + case FileTypeSelfDestructingPhotoTypeID: + // Decoding fileTypeSelfDestructingPhoto#7bcf329b. + v := FileTypeSelfDestructingPhoto{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case FileTypeSelfDestructingVideoTypeID: + // Decoding fileTypeSelfDestructingVideo#b70cc425. + v := FileTypeSelfDestructingVideo{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case FileTypeSelfDestructingVideoNoteTypeID: + // Decoding fileTypeSelfDestructingVideoNote#592012c1. + v := FileTypeSelfDestructingVideoNote{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case FileTypeSelfDestructingVoiceNoteTypeID: + // Decoding fileTypeSelfDestructingVoiceNote#64d0db1d. + v := FileTypeSelfDestructingVoiceNote{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil case FileTypeStickerTypeID: // Decoding fileTypeSticker#1c537c69. v := FileTypeSticker{} @@ -2804,6 +3360,34 @@ func DecodeTDLibJSONFileType(buf tdjson.Decoder) (FileTypeClass, error) { return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) } return &v, nil + case "fileTypeSelfDestructingPhoto": + // Decoding fileTypeSelfDestructingPhoto#7bcf329b. + v := FileTypeSelfDestructingPhoto{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case "fileTypeSelfDestructingVideo": + // Decoding fileTypeSelfDestructingVideo#b70cc425. + v := FileTypeSelfDestructingVideo{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case "fileTypeSelfDestructingVideoNote": + // Decoding fileTypeSelfDestructingVideoNote#592012c1. + v := FileTypeSelfDestructingVideoNote{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil + case "fileTypeSelfDestructingVoiceNote": + // Decoding fileTypeSelfDestructingVoiceNote#64d0db1d. + v := FileTypeSelfDestructingVoiceNote{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode FileTypeClass: %w", err) + } + return &v, nil case "fileTypeSticker": // Decoding fileTypeSticker#1c537c69. v := FileTypeSticker{} diff --git a/tdapi/tl_found_affiliate_program_gen.go b/tdapi/tl_found_affiliate_program_gen.go new file mode 100644 index 0000000000..1f900b1b36 --- /dev/null +++ b/tdapi/tl_found_affiliate_program_gen.go @@ -0,0 +1,227 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// FoundAffiliateProgram represents TL type `foundAffiliateProgram#80bf7012`. +type FoundAffiliateProgram struct { + // User identifier of the bot created the program + BotUserID int64 + // Information about the affiliate program + Parameters AffiliateProgramInfo +} + +// FoundAffiliateProgramTypeID is TL type id of FoundAffiliateProgram. +const FoundAffiliateProgramTypeID = 0x80bf7012 + +// Ensuring interfaces in compile-time for FoundAffiliateProgram. +var ( + _ bin.Encoder = &FoundAffiliateProgram{} + _ bin.Decoder = &FoundAffiliateProgram{} + _ bin.BareEncoder = &FoundAffiliateProgram{} + _ bin.BareDecoder = &FoundAffiliateProgram{} +) + +func (f *FoundAffiliateProgram) Zero() bool { + if f == nil { + return true + } + if !(f.BotUserID == 0) { + return false + } + if !(f.Parameters.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *FoundAffiliateProgram) String() string { + if f == nil { + return "FoundAffiliateProgram(nil)" + } + type Alias FoundAffiliateProgram + return fmt.Sprintf("FoundAffiliateProgram%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FoundAffiliateProgram) TypeID() uint32 { + return FoundAffiliateProgramTypeID +} + +// TypeName returns name of type in TL schema. +func (*FoundAffiliateProgram) TypeName() string { + return "foundAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (f *FoundAffiliateProgram) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "foundAffiliateProgram", + ID: FoundAffiliateProgramTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + { + Name: "Parameters", + SchemaName: "parameters", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (f *FoundAffiliateProgram) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliateProgram#80bf7012 as nil") + } + b.PutID(FoundAffiliateProgramTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FoundAffiliateProgram) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliateProgram#80bf7012 as nil") + } + b.PutInt53(f.BotUserID) + if err := f.Parameters.Encode(b); err != nil { + return fmt.Errorf("unable to encode foundAffiliateProgram#80bf7012: field parameters: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (f *FoundAffiliateProgram) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliateProgram#80bf7012 to nil") + } + if err := b.ConsumeID(FoundAffiliateProgramTypeID); err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FoundAffiliateProgram) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliateProgram#80bf7012 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: field bot_user_id: %w", err) + } + f.BotUserID = value + } + { + if err := f.Parameters.Decode(b); err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: field parameters: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FoundAffiliateProgram) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliateProgram#80bf7012 as nil") + } + b.ObjStart() + b.PutID("foundAffiliateProgram") + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(f.BotUserID) + b.Comma() + b.FieldStart("parameters") + if err := f.Parameters.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode foundAffiliateProgram#80bf7012: field parameters: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FoundAffiliateProgram) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliateProgram#80bf7012 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("foundAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: %w", err) + } + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: field bot_user_id: %w", err) + } + f.BotUserID = value + case "parameters": + if err := f.Parameters.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode foundAffiliateProgram#80bf7012: field parameters: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetBotUserID returns value of BotUserID field. +func (f *FoundAffiliateProgram) GetBotUserID() (value int64) { + if f == nil { + return + } + return f.BotUserID +} + +// GetParameters returns value of Parameters field. +func (f *FoundAffiliateProgram) GetParameters() (value AffiliateProgramInfo) { + if f == nil { + return + } + return f.Parameters +} diff --git a/tdapi/tl_found_affiliate_programs_gen.go b/tdapi/tl_found_affiliate_programs_gen.go new file mode 100644 index 0000000000..b25ceb677a --- /dev/null +++ b/tdapi/tl_found_affiliate_programs_gen.go @@ -0,0 +1,289 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// FoundAffiliatePrograms represents TL type `foundAffiliatePrograms#b6228108`. +type FoundAffiliatePrograms struct { + // The total number of found affiliate programs + TotalCount int32 + // The list of affiliate programs + Programs []FoundAffiliateProgram + // The offset for the next request. If empty, then there are no more results + NextOffset string +} + +// FoundAffiliateProgramsTypeID is TL type id of FoundAffiliatePrograms. +const FoundAffiliateProgramsTypeID = 0xb6228108 + +// Ensuring interfaces in compile-time for FoundAffiliatePrograms. +var ( + _ bin.Encoder = &FoundAffiliatePrograms{} + _ bin.Decoder = &FoundAffiliatePrograms{} + _ bin.BareEncoder = &FoundAffiliatePrograms{} + _ bin.BareDecoder = &FoundAffiliatePrograms{} +) + +func (f *FoundAffiliatePrograms) Zero() bool { + if f == nil { + return true + } + if !(f.TotalCount == 0) { + return false + } + if !(f.Programs == nil) { + return false + } + if !(f.NextOffset == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (f *FoundAffiliatePrograms) String() string { + if f == nil { + return "FoundAffiliatePrograms(nil)" + } + type Alias FoundAffiliatePrograms + return fmt.Sprintf("FoundAffiliatePrograms%+v", Alias(*f)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*FoundAffiliatePrograms) TypeID() uint32 { + return FoundAffiliateProgramsTypeID +} + +// TypeName returns name of type in TL schema. +func (*FoundAffiliatePrograms) TypeName() string { + return "foundAffiliatePrograms" +} + +// TypeInfo returns info about TL type. +func (f *FoundAffiliatePrograms) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "foundAffiliatePrograms", + ID: FoundAffiliateProgramsTypeID, + } + if f == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "TotalCount", + SchemaName: "total_count", + }, + { + Name: "Programs", + SchemaName: "programs", + }, + { + Name: "NextOffset", + SchemaName: "next_offset", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (f *FoundAffiliatePrograms) Encode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliatePrograms#b6228108 as nil") + } + b.PutID(FoundAffiliateProgramsTypeID) + return f.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (f *FoundAffiliatePrograms) EncodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliatePrograms#b6228108 as nil") + } + b.PutInt32(f.TotalCount) + b.PutInt(len(f.Programs)) + for idx, v := range f.Programs { + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare foundAffiliatePrograms#b6228108: field programs element with index %d: %w", idx, err) + } + } + b.PutString(f.NextOffset) + return nil +} + +// Decode implements bin.Decoder. +func (f *FoundAffiliatePrograms) Decode(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliatePrograms#b6228108 to nil") + } + if err := b.ConsumeID(FoundAffiliateProgramsTypeID); err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: %w", err) + } + return f.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (f *FoundAffiliatePrograms) DecodeBare(b *bin.Buffer) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliatePrograms#b6228108 to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field total_count: %w", err) + } + f.TotalCount = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field programs: %w", err) + } + + if headerLen > 0 { + f.Programs = make([]FoundAffiliateProgram, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + var value FoundAffiliateProgram + if err := value.DecodeBare(b); err != nil { + return fmt.Errorf("unable to decode bare foundAffiliatePrograms#b6228108: field programs: %w", err) + } + f.Programs = append(f.Programs, value) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field next_offset: %w", err) + } + f.NextOffset = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (f *FoundAffiliatePrograms) EncodeTDLibJSON(b tdjson.Encoder) error { + if f == nil { + return fmt.Errorf("can't encode foundAffiliatePrograms#b6228108 as nil") + } + b.ObjStart() + b.PutID("foundAffiliatePrograms") + b.Comma() + b.FieldStart("total_count") + b.PutInt32(f.TotalCount) + b.Comma() + b.FieldStart("programs") + b.ArrStart() + for idx, v := range f.Programs { + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode foundAffiliatePrograms#b6228108: field programs element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.FieldStart("next_offset") + b.PutString(f.NextOffset) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (f *FoundAffiliatePrograms) DecodeTDLibJSON(b tdjson.Decoder) error { + if f == nil { + return fmt.Errorf("can't decode foundAffiliatePrograms#b6228108 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("foundAffiliatePrograms"); err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: %w", err) + } + case "total_count": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field total_count: %w", err) + } + f.TotalCount = value + case "programs": + if err := b.Arr(func(b tdjson.Decoder) error { + var value FoundAffiliateProgram + if err := value.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field programs: %w", err) + } + f.Programs = append(f.Programs, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field programs: %w", err) + } + case "next_offset": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode foundAffiliatePrograms#b6228108: field next_offset: %w", err) + } + f.NextOffset = value + default: + return b.Skip() + } + return nil + }) +} + +// GetTotalCount returns value of TotalCount field. +func (f *FoundAffiliatePrograms) GetTotalCount() (value int32) { + if f == nil { + return + } + return f.TotalCount +} + +// GetPrograms returns value of Programs field. +func (f *FoundAffiliatePrograms) GetPrograms() (value []FoundAffiliateProgram) { + if f == nil { + return + } + return f.Programs +} + +// GetNextOffset returns value of NextOffset field. +func (f *FoundAffiliatePrograms) GetNextOffset() (value string) { + if f == nil { + return + } + return f.NextOffset +} diff --git a/tdapi/tl_get_chat_affiliate_program_gen.go b/tdapi/tl_get_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..6e5cf805dd --- /dev/null +++ b/tdapi/tl_get_chat_affiliate_program_gen.go @@ -0,0 +1,239 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// GetChatAffiliateProgramRequest represents TL type `getChatAffiliateProgram#6ec8a39a`. +type GetChatAffiliateProgramRequest struct { + // Identifier of the chat for which the affiliate program was connected. Can be an + // identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel + // chat with can_post_messages administrator right + ChatID int64 + // Identifier of the bot that created the program + BotUserID int64 +} + +// GetChatAffiliateProgramRequestTypeID is TL type id of GetChatAffiliateProgramRequest. +const GetChatAffiliateProgramRequestTypeID = 0x6ec8a39a + +// Ensuring interfaces in compile-time for GetChatAffiliateProgramRequest. +var ( + _ bin.Encoder = &GetChatAffiliateProgramRequest{} + _ bin.Decoder = &GetChatAffiliateProgramRequest{} + _ bin.BareEncoder = &GetChatAffiliateProgramRequest{} + _ bin.BareDecoder = &GetChatAffiliateProgramRequest{} +) + +func (g *GetChatAffiliateProgramRequest) Zero() bool { + if g == nil { + return true + } + if !(g.ChatID == 0) { + return false + } + if !(g.BotUserID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetChatAffiliateProgramRequest) String() string { + if g == nil { + return "GetChatAffiliateProgramRequest(nil)" + } + type Alias GetChatAffiliateProgramRequest + return fmt.Sprintf("GetChatAffiliateProgramRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetChatAffiliateProgramRequest) TypeID() uint32 { + return GetChatAffiliateProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetChatAffiliateProgramRequest) TypeName() string { + return "getChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (g *GetChatAffiliateProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getChatAffiliateProgram", + ID: GetChatAffiliateProgramRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "BotUserID", + SchemaName: "bot_user_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetChatAffiliateProgramRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliateProgram#6ec8a39a as nil") + } + b.PutID(GetChatAffiliateProgramRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetChatAffiliateProgramRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliateProgram#6ec8a39a as nil") + } + b.PutInt53(g.ChatID) + b.PutInt53(g.BotUserID) + return nil +} + +// Decode implements bin.Decoder. +func (g *GetChatAffiliateProgramRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliateProgram#6ec8a39a to nil") + } + if err := b.ConsumeID(GetChatAffiliateProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetChatAffiliateProgramRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliateProgram#6ec8a39a to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: field chat_id: %w", err) + } + g.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: field bot_user_id: %w", err) + } + g.BotUserID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetChatAffiliateProgramRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliateProgram#6ec8a39a as nil") + } + b.ObjStart() + b.PutID("getChatAffiliateProgram") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(g.ChatID) + b.Comma() + b.FieldStart("bot_user_id") + b.PutInt53(g.BotUserID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetChatAffiliateProgramRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliateProgram#6ec8a39a to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: field chat_id: %w", err) + } + g.ChatID = value + case "bot_user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliateProgram#6ec8a39a: field bot_user_id: %w", err) + } + g.BotUserID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (g *GetChatAffiliateProgramRequest) GetChatID() (value int64) { + if g == nil { + return + } + return g.ChatID +} + +// GetBotUserID returns value of BotUserID field. +func (g *GetChatAffiliateProgramRequest) GetBotUserID() (value int64) { + if g == nil { + return + } + return g.BotUserID +} + +// GetChatAffiliateProgram invokes method getChatAffiliateProgram#6ec8a39a returning error if any. +func (c *Client) GetChatAffiliateProgram(ctx context.Context, request *GetChatAffiliateProgramRequest) (*ChatAffiliateProgram, error) { + var result ChatAffiliateProgram + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_chat_affiliate_programs_gen.go b/tdapi/tl_get_chat_affiliate_programs_gen.go new file mode 100644 index 0000000000..2eef94e012 --- /dev/null +++ b/tdapi/tl_get_chat_affiliate_programs_gen.go @@ -0,0 +1,274 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// GetChatAffiliateProgramsRequest represents TL type `getChatAffiliatePrograms#f9df5251`. +type GetChatAffiliateProgramsRequest struct { + // Identifier of the chat for which the affiliate programs were connected. Can be an + // identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel + // chat with can_post_messages administrator right + ChatID int64 + // Offset of the first affiliate program to return as received from the previous request; + // use empty string to get the first chunk of results + Offset string + // The maximum number of affiliate programs to return + Limit int32 +} + +// GetChatAffiliateProgramsRequestTypeID is TL type id of GetChatAffiliateProgramsRequest. +const GetChatAffiliateProgramsRequestTypeID = 0xf9df5251 + +// Ensuring interfaces in compile-time for GetChatAffiliateProgramsRequest. +var ( + _ bin.Encoder = &GetChatAffiliateProgramsRequest{} + _ bin.Decoder = &GetChatAffiliateProgramsRequest{} + _ bin.BareEncoder = &GetChatAffiliateProgramsRequest{} + _ bin.BareDecoder = &GetChatAffiliateProgramsRequest{} +) + +func (g *GetChatAffiliateProgramsRequest) Zero() bool { + if g == nil { + return true + } + if !(g.ChatID == 0) { + return false + } + if !(g.Offset == "") { + return false + } + if !(g.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetChatAffiliateProgramsRequest) String() string { + if g == nil { + return "GetChatAffiliateProgramsRequest(nil)" + } + type Alias GetChatAffiliateProgramsRequest + return fmt.Sprintf("GetChatAffiliateProgramsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetChatAffiliateProgramsRequest) TypeID() uint32 { + return GetChatAffiliateProgramsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetChatAffiliateProgramsRequest) TypeName() string { + return "getChatAffiliatePrograms" +} + +// TypeInfo returns info about TL type. +func (g *GetChatAffiliateProgramsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getChatAffiliatePrograms", + ID: GetChatAffiliateProgramsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (g *GetChatAffiliateProgramsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliatePrograms#f9df5251 as nil") + } + b.PutID(GetChatAffiliateProgramsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetChatAffiliateProgramsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliatePrograms#f9df5251 as nil") + } + b.PutInt53(g.ChatID) + b.PutString(g.Offset) + b.PutInt32(g.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (g *GetChatAffiliateProgramsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliatePrograms#f9df5251 to nil") + } + if err := b.ConsumeID(GetChatAffiliateProgramsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetChatAffiliateProgramsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliatePrograms#f9df5251 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field chat_id: %w", err) + } + g.ChatID = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field offset: %w", err) + } + g.Offset = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field limit: %w", err) + } + g.Limit = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetChatAffiliateProgramsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getChatAffiliatePrograms#f9df5251 as nil") + } + b.ObjStart() + b.PutID("getChatAffiliatePrograms") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(g.ChatID) + b.Comma() + b.FieldStart("offset") + b.PutString(g.Offset) + b.Comma() + b.FieldStart("limit") + b.PutInt32(g.Limit) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetChatAffiliateProgramsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getChatAffiliatePrograms#f9df5251 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getChatAffiliatePrograms"); err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field chat_id: %w", err) + } + g.ChatID = value + case "offset": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field offset: %w", err) + } + g.Offset = value + case "limit": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode getChatAffiliatePrograms#f9df5251: field limit: %w", err) + } + g.Limit = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (g *GetChatAffiliateProgramsRequest) GetChatID() (value int64) { + if g == nil { + return + } + return g.ChatID +} + +// GetOffset returns value of Offset field. +func (g *GetChatAffiliateProgramsRequest) GetOffset() (value string) { + if g == nil { + return + } + return g.Offset +} + +// GetLimit returns value of Limit field. +func (g *GetChatAffiliateProgramsRequest) GetLimit() (value int32) { + if g == nil { + return + } + return g.Limit +} + +// GetChatAffiliatePrograms invokes method getChatAffiliatePrograms#f9df5251 returning error if any. +func (c *Client) GetChatAffiliatePrograms(ctx context.Context, request *GetChatAffiliateProgramsRequest) (*ChatAffiliatePrograms, error) { + var result ChatAffiliatePrograms + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_get_owned_bots_gen.go b/tdapi/tl_get_owned_bots_gen.go new file mode 100644 index 0000000000..2f9926542f --- /dev/null +++ b/tdapi/tl_get_owned_bots_gen.go @@ -0,0 +1,169 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// GetOwnedBotsRequest represents TL type `getOwnedBots#8b87c7fd`. +type GetOwnedBotsRequest struct { +} + +// GetOwnedBotsRequestTypeID is TL type id of GetOwnedBotsRequest. +const GetOwnedBotsRequestTypeID = 0x8b87c7fd + +// Ensuring interfaces in compile-time for GetOwnedBotsRequest. +var ( + _ bin.Encoder = &GetOwnedBotsRequest{} + _ bin.Decoder = &GetOwnedBotsRequest{} + _ bin.BareEncoder = &GetOwnedBotsRequest{} + _ bin.BareDecoder = &GetOwnedBotsRequest{} +) + +func (g *GetOwnedBotsRequest) Zero() bool { + if g == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (g *GetOwnedBotsRequest) String() string { + if g == nil { + return "GetOwnedBotsRequest(nil)" + } + type Alias GetOwnedBotsRequest + return fmt.Sprintf("GetOwnedBotsRequest%+v", Alias(*g)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*GetOwnedBotsRequest) TypeID() uint32 { + return GetOwnedBotsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*GetOwnedBotsRequest) TypeName() string { + return "getOwnedBots" +} + +// TypeInfo returns info about TL type. +func (g *GetOwnedBotsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "getOwnedBots", + ID: GetOwnedBotsRequestTypeID, + } + if g == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (g *GetOwnedBotsRequest) Encode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getOwnedBots#8b87c7fd as nil") + } + b.PutID(GetOwnedBotsRequestTypeID) + return g.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (g *GetOwnedBotsRequest) EncodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't encode getOwnedBots#8b87c7fd as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (g *GetOwnedBotsRequest) Decode(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getOwnedBots#8b87c7fd to nil") + } + if err := b.ConsumeID(GetOwnedBotsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode getOwnedBots#8b87c7fd: %w", err) + } + return g.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (g *GetOwnedBotsRequest) DecodeBare(b *bin.Buffer) error { + if g == nil { + return fmt.Errorf("can't decode getOwnedBots#8b87c7fd to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (g *GetOwnedBotsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if g == nil { + return fmt.Errorf("can't encode getOwnedBots#8b87c7fd as nil") + } + b.ObjStart() + b.PutID("getOwnedBots") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (g *GetOwnedBotsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if g == nil { + return fmt.Errorf("can't decode getOwnedBots#8b87c7fd to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("getOwnedBots"); err != nil { + return fmt.Errorf("unable to decode getOwnedBots#8b87c7fd: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetOwnedBots invokes method getOwnedBots#8b87c7fd returning error if any. +func (c *Client) GetOwnedBots(ctx context.Context) (*Users, error) { + var result Users + + request := &GetOwnedBotsRequest{} + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_internal_link_type_gen.go b/tdapi/tl_internal_link_type_gen.go index b4502d9791..2d098517b8 100644 --- a/tdapi/tl_internal_link_type_gen.go +++ b/tdapi/tl_internal_link_type_gen.go @@ -1905,6 +1905,206 @@ func (i *InternalLinkTypeChangePhoneNumber) DecodeTDLibJSON(b tdjson.Decoder) er }) } +// InternalLinkTypeChatAffiliateProgram represents TL type `internalLinkTypeChatAffiliateProgram#25ac5024`. +type InternalLinkTypeChatAffiliateProgram struct { + // Username to be passed to searchChatAffiliateProgram + Username string + // Referrer to be passed to searchChatAffiliateProgram + Referrer string +} + +// InternalLinkTypeChatAffiliateProgramTypeID is TL type id of InternalLinkTypeChatAffiliateProgram. +const InternalLinkTypeChatAffiliateProgramTypeID = 0x25ac5024 + +// construct implements constructor of InternalLinkTypeClass. +func (i InternalLinkTypeChatAffiliateProgram) construct() InternalLinkTypeClass { return &i } + +// Ensuring interfaces in compile-time for InternalLinkTypeChatAffiliateProgram. +var ( + _ bin.Encoder = &InternalLinkTypeChatAffiliateProgram{} + _ bin.Decoder = &InternalLinkTypeChatAffiliateProgram{} + _ bin.BareEncoder = &InternalLinkTypeChatAffiliateProgram{} + _ bin.BareDecoder = &InternalLinkTypeChatAffiliateProgram{} + + _ InternalLinkTypeClass = &InternalLinkTypeChatAffiliateProgram{} +) + +func (i *InternalLinkTypeChatAffiliateProgram) Zero() bool { + if i == nil { + return true + } + if !(i.Username == "") { + return false + } + if !(i.Referrer == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (i *InternalLinkTypeChatAffiliateProgram) String() string { + if i == nil { + return "InternalLinkTypeChatAffiliateProgram(nil)" + } + type Alias InternalLinkTypeChatAffiliateProgram + return fmt.Sprintf("InternalLinkTypeChatAffiliateProgram%+v", Alias(*i)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*InternalLinkTypeChatAffiliateProgram) TypeID() uint32 { + return InternalLinkTypeChatAffiliateProgramTypeID +} + +// TypeName returns name of type in TL schema. +func (*InternalLinkTypeChatAffiliateProgram) TypeName() string { + return "internalLinkTypeChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (i *InternalLinkTypeChatAffiliateProgram) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "internalLinkTypeChatAffiliateProgram", + ID: InternalLinkTypeChatAffiliateProgramTypeID, + } + if i == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Username", + SchemaName: "username", + }, + { + Name: "Referrer", + SchemaName: "referrer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (i *InternalLinkTypeChatAffiliateProgram) Encode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeChatAffiliateProgram#25ac5024 as nil") + } + b.PutID(InternalLinkTypeChatAffiliateProgramTypeID) + return i.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (i *InternalLinkTypeChatAffiliateProgram) EncodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeChatAffiliateProgram#25ac5024 as nil") + } + b.PutString(i.Username) + b.PutString(i.Referrer) + return nil +} + +// Decode implements bin.Decoder. +func (i *InternalLinkTypeChatAffiliateProgram) Decode(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeChatAffiliateProgram#25ac5024 to nil") + } + if err := b.ConsumeID(InternalLinkTypeChatAffiliateProgramTypeID); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: %w", err) + } + return i.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (i *InternalLinkTypeChatAffiliateProgram) DecodeBare(b *bin.Buffer) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeChatAffiliateProgram#25ac5024 to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: field username: %w", err) + } + i.Username = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: field referrer: %w", err) + } + i.Referrer = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (i *InternalLinkTypeChatAffiliateProgram) EncodeTDLibJSON(b tdjson.Encoder) error { + if i == nil { + return fmt.Errorf("can't encode internalLinkTypeChatAffiliateProgram#25ac5024 as nil") + } + b.ObjStart() + b.PutID("internalLinkTypeChatAffiliateProgram") + b.Comma() + b.FieldStart("username") + b.PutString(i.Username) + b.Comma() + b.FieldStart("referrer") + b.PutString(i.Referrer) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (i *InternalLinkTypeChatAffiliateProgram) DecodeTDLibJSON(b tdjson.Decoder) error { + if i == nil { + return fmt.Errorf("can't decode internalLinkTypeChatAffiliateProgram#25ac5024 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("internalLinkTypeChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: %w", err) + } + case "username": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: field username: %w", err) + } + i.Username = value + case "referrer": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode internalLinkTypeChatAffiliateProgram#25ac5024: field referrer: %w", err) + } + i.Referrer = value + default: + return b.Skip() + } + return nil + }) +} + +// GetUsername returns value of Username field. +func (i *InternalLinkTypeChatAffiliateProgram) GetUsername() (value string) { + if i == nil { + return + } + return i.Username +} + +// GetReferrer returns value of Referrer field. +func (i *InternalLinkTypeChatAffiliateProgram) GetReferrer() (value string) { + if i == nil { + return + } + return i.Referrer +} + // InternalLinkTypeChatBoost represents TL type `internalLinkTypeChatBoost#d549fd40`. type InternalLinkTypeChatBoost struct { // URL to be passed to getChatBoostLinkInfo @@ -8208,6 +8408,7 @@ const InternalLinkTypeClassName = "InternalLinkType" // case *tdapi.InternalLinkTypeBusinessChat: // internalLinkTypeBusinessChat#a03ae9d7 // case *tdapi.InternalLinkTypeBuyStars: // internalLinkTypeBuyStars#a94cc347 // case *tdapi.InternalLinkTypeChangePhoneNumber: // internalLinkTypeChangePhoneNumber#f0275b01 +// case *tdapi.InternalLinkTypeChatAffiliateProgram: // internalLinkTypeChatAffiliateProgram#25ac5024 // case *tdapi.InternalLinkTypeChatBoost: // internalLinkTypeChatBoost#d549fd40 // case *tdapi.InternalLinkTypeChatFolderInvite: // internalLinkTypeChatFolderInvite#89b2493e // case *tdapi.InternalLinkTypeChatFolderSettings: // internalLinkTypeChatFolderSettings#bfff055c @@ -8344,6 +8545,13 @@ func DecodeInternalLinkType(buf *bin.Buffer) (InternalLinkTypeClass, error) { return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case InternalLinkTypeChatAffiliateProgramTypeID: + // Decoding internalLinkTypeChatAffiliateProgram#25ac5024. + v := InternalLinkTypeChatAffiliateProgram{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case InternalLinkTypeChatBoostTypeID: // Decoding internalLinkTypeChatBoost#d549fd40. v := InternalLinkTypeChatBoost{} @@ -8671,6 +8879,13 @@ func DecodeTDLibJSONInternalLinkType(buf tdjson.Decoder) (InternalLinkTypeClass, return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) } return &v, nil + case "internalLinkTypeChatAffiliateProgram": + // Decoding internalLinkTypeChatAffiliateProgram#25ac5024. + v := InternalLinkTypeChatAffiliateProgram{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode InternalLinkTypeClass: %w", err) + } + return &v, nil case "internalLinkTypeChatBoost": // Decoding internalLinkTypeChatBoost#d549fd40. v := InternalLinkTypeChatBoost{} diff --git a/tdapi/tl_registry_gen.go b/tdapi/tl_registry_gen.go index 77ed71d5b6..07d5f19dd6 100644 --- a/tdapi/tl_registry_gen.go +++ b/tdapi/tl_registry_gen.go @@ -178,11 +178,22 @@ func TypesMap() map[uint32]string { InputChatPhotoStickerTypeID: "inputChatPhotoSticker#4e6e735d", ChatPermissionsTypeID: "chatPermissions#f8f25a79", ChatAdministratorRightsTypeID: "chatAdministratorRights#5f4f9044", + StarAmountTypeID: "starAmount#6f0e6d80", StarSubscriptionTypeChannelTypeID: "starSubscriptionTypeChannel#c29ab6f5", StarSubscriptionTypeBotTypeID: "starSubscriptionTypeBot#d78ddd2", StarSubscriptionPricingTypeID: "starSubscriptionPricing#96a28856", StarSubscriptionTypeID: "starSubscription#3a3811f5", - StarSubscriptionsTypeID: "starSubscriptions#f7a7ae44", + StarSubscriptionsTypeID: "starSubscriptions#a2f27c8d", + AffiliateProgramSortOrderProfitabilityTypeID: "affiliateProgramSortOrderProfitability#8afaaf67", + AffiliateProgramSortOrderCreationDateTypeID: "affiliateProgramSortOrderCreationDate#a319390d", + AffiliateProgramSortOrderRevenueTypeID: "affiliateProgramSortOrderRevenue#72a2c2b8", + AffiliateProgramParametersTypeID: "affiliateProgramParameters#61e90c54", + AffiliateProgramInfoTypeID: "affiliateProgramInfo#96fce8b5", + AffiliateInfoTypeID: "affiliateInfo#b1c1dcfa", + FoundAffiliateProgramTypeID: "foundAffiliateProgram#80bf7012", + FoundAffiliateProgramsTypeID: "foundAffiliatePrograms#b6228108", + ChatAffiliateProgramTypeID: "chatAffiliateProgram#ab9c1136", + ChatAffiliateProgramsTypeID: "chatAffiliatePrograms#74f423e2", ProductInfoTypeID: "productInfo#87e47ca4", PremiumPaymentOptionTypeID: "premiumPaymentOption#8c0c5fb2", PremiumStatePaymentOptionTypeID: "premiumStatePaymentOption#7d06b579", @@ -200,29 +211,33 @@ func TypesMap() map[uint32]string { UserGiftsTypeID: "userGifts#e274219f", StarTransactionDirectionIncomingTypeID: "starTransactionDirectionIncoming#b2cabe46", StarTransactionDirectionOutgoingTypeID: "starTransactionDirectionOutgoing#6e83b5a0", - BotTransactionPurposePaidMediaTypeID: "botTransactionPurposePaidMedia#62952496", - BotTransactionPurposeInvoicePaymentTypeID: "botTransactionPurposeInvoicePayment#699860ac", - BotTransactionPurposeSubscriptionTypeID: "botTransactionPurposeSubscription#e5796205", - ChatTransactionPurposePaidMediaTypeID: "chatTransactionPurposePaidMedia#d35febb", - ChatTransactionPurposeJoinTypeID: "chatTransactionPurposeJoin#5b31327a", - ChatTransactionPurposeReactionTypeID: "chatTransactionPurposeReaction#7a5f9888", - ChatTransactionPurposeGiveawayTypeID: "chatTransactionPurposeGiveaway#384c8b7f", - UserTransactionPurposeGiftedStarsTypeID: "userTransactionPurposeGiftedStars#1fb3401", - UserTransactionPurposeGiftSellTypeID: "userTransactionPurposeGiftSell#195fcd8e", - UserTransactionPurposeGiftSendTypeID: "userTransactionPurposeGiftSend#b36e54df", - StarTransactionPartnerTelegramTypeID: "starTransactionPartnerTelegram#7a899cc0", - StarTransactionPartnerAppStoreTypeID: "starTransactionPartnerAppStore#e34026dc", - StarTransactionPartnerGooglePlayTypeID: "starTransactionPartnerGooglePlay#f229f2a0", - StarTransactionPartnerFragmentTypeID: "starTransactionPartnerFragment#da1849b5", - StarTransactionPartnerTelegramAdsTypeID: "starTransactionPartnerTelegramAds#91f9c6b", - StarTransactionPartnerTelegramAPITypeID: "starTransactionPartnerTelegramApi#543cc9fd", - StarTransactionPartnerBotTypeID: "starTransactionPartnerBot#4ece3a40", - StarTransactionPartnerBusinessTypeID: "starTransactionPartnerBusiness#7af9fb52", - StarTransactionPartnerChatTypeID: "starTransactionPartnerChat#71db4d40", - StarTransactionPartnerUserTypeID: "starTransactionPartnerUser#6f4d43d1", - StarTransactionPartnerUnsupportedTypeID: "starTransactionPartnerUnsupported#c4b20d73", - StarTransactionTypeID: "starTransaction#ce1084a8", - StarTransactionsTypeID: "starTransactions#306a010e", + StarTransactionTypePremiumBotDepositTypeID: "starTransactionTypePremiumBotDeposit#d879090e", + StarTransactionTypeAppStoreDepositTypeID: "starTransactionTypeAppStoreDeposit#8283941", + StarTransactionTypeGooglePlayDepositTypeID: "starTransactionTypeGooglePlayDeposit#ecbdb656", + StarTransactionTypeFragmentDepositTypeID: "starTransactionTypeFragmentDeposit#7625e44", + StarTransactionTypeUserDepositTypeID: "starTransactionTypeUserDeposit#c2a18e9", + StarTransactionTypeGiveawayDepositTypeID: "starTransactionTypeGiveawayDeposit#b16200c6", + StarTransactionTypeFragmentWithdrawalTypeID: "starTransactionTypeFragmentWithdrawal#af3a2992", + StarTransactionTypeTelegramAdsWithdrawalTypeID: "starTransactionTypeTelegramAdsWithdrawal#a58e8469", + StarTransactionTypeTelegramAPIUsageTypeID: "starTransactionTypeTelegramApiUsage#27a82afe", + StarTransactionTypeBotPaidMediaPurchaseTypeID: "starTransactionTypeBotPaidMediaPurchase#7f48cc6a", + StarTransactionTypeBotPaidMediaSaleTypeID: "starTransactionTypeBotPaidMediaSale#6e07eeb2", + StarTransactionTypeChannelPaidMediaPurchaseTypeID: "starTransactionTypeChannelPaidMediaPurchase#9016d4f5", + StarTransactionTypeChannelPaidMediaSaleTypeID: "starTransactionTypeChannelPaidMediaSale#eace92ef", + StarTransactionTypeBotInvoicePurchaseTypeID: "starTransactionTypeBotInvoicePurchase#1dddac0c", + StarTransactionTypeBotInvoiceSaleTypeID: "starTransactionTypeBotInvoiceSale#5b7d8d2f", + StarTransactionTypeBotSubscriptionPurchaseTypeID: "starTransactionTypeBotSubscriptionPurchase#40bf1355", + StarTransactionTypeBotSubscriptionSaleTypeID: "starTransactionTypeBotSubscriptionSale#1f686889", + StarTransactionTypeChannelSubscriptionPurchaseTypeID: "starTransactionTypeChannelSubscriptionPurchase#380eb3d1", + StarTransactionTypeChannelSubscriptionSaleTypeID: "starTransactionTypeChannelSubscriptionSale#fe127c82", + StarTransactionTypeGiftPurchaseTypeID: "starTransactionTypeGiftPurchase#ef5f1d52", + StarTransactionTypeGiftSaleTypeID: "starTransactionTypeGiftSale#64d61157", + StarTransactionTypeChannelPaidReactionSendTypeID: "starTransactionTypeChannelPaidReactionSend#c02667c0", + StarTransactionTypeChannelPaidReactionReceiveTypeID: "starTransactionTypeChannelPaidReactionReceive#23d6f9eb", + StarTransactionTypeAffiliateProgramCommissionTypeID: "starTransactionTypeAffiliateProgramCommission#9a637573", + StarTransactionTypeUnsupportedTypeID: "starTransactionTypeUnsupported#76cfcab2", + StarTransactionTypeID: "starTransaction#7f820a90", + StarTransactionsTypeID: "starTransactions#b5f5820b", GiveawayParticipantStatusEligibleTypeID: "giveawayParticipantStatusEligible#122ade97", GiveawayParticipantStatusParticipatingTypeID: "giveawayParticipantStatusParticipating#1d53e36f", GiveawayParticipantStatusAlreadyWasMemberTypeID: "giveawayParticipantStatusAlreadyWasMember#11f9b5a0", @@ -239,7 +254,7 @@ func TypesMap() map[uint32]string { EmojiStatusesTypeID: "emojiStatuses#eaeb9bdc", UsernamesTypeID: "usernames#bf343063", UserTypeID: "user#18552c62", - BotInfoTypeID: "botInfo#15e58682", + BotInfoTypeID: "botInfo#80eb0e42", UserFullInfoTypeID: "userFullInfo#85d0c905", UsersTypeID: "users#9d955a12", FoundUsersTypeID: "foundUsers#c531e854", @@ -1353,6 +1368,7 @@ func TypesMap() map[uint32]string { InternalLinkTypeBusinessChatTypeID: "internalLinkTypeBusinessChat#a03ae9d7", InternalLinkTypeBuyStarsTypeID: "internalLinkTypeBuyStars#a94cc347", InternalLinkTypeChangePhoneNumberTypeID: "internalLinkTypeChangePhoneNumber#f0275b01", + InternalLinkTypeChatAffiliateProgramTypeID: "internalLinkTypeChatAffiliateProgram#25ac5024", InternalLinkTypeChatBoostTypeID: "internalLinkTypeChatBoost#d549fd40", InternalLinkTypeChatFolderInviteTypeID: "internalLinkTypeChatFolderInvite#89b2493e", InternalLinkTypeChatFolderSettingsTypeID: "internalLinkTypeChatFolderSettings#bfff055c", @@ -1406,6 +1422,10 @@ func TypesMap() map[uint32]string { FileTypeSecretTypeID: "fileTypeSecret#906d14f7", FileTypeSecretThumbnailTypeID: "fileTypeSecretThumbnail#ac797636", FileTypeSecureTypeID: "fileTypeSecure#ab69bf26", + FileTypeSelfDestructingPhotoTypeID: "fileTypeSelfDestructingPhoto#7bcf329b", + FileTypeSelfDestructingVideoTypeID: "fileTypeSelfDestructingVideo#b70cc425", + FileTypeSelfDestructingVideoNoteTypeID: "fileTypeSelfDestructingVideoNote#592012c1", + FileTypeSelfDestructingVoiceNoteTypeID: "fileTypeSelfDestructingVoiceNote#64d0db1d", FileTypeStickerTypeID: "fileTypeSticker#1c537c69", FileTypeThumbnailTypeID: "fileTypeThumbnail#ff42215e", FileTypeUnknownTypeID: "fileTypeUnknown#8819ed50", @@ -1508,7 +1528,7 @@ func TypesMap() map[uint32]string { ChatRevenueTransactionTypeRefundTypeID: "chatRevenueTransactionTypeRefund#1206b847", ChatRevenueTransactionTypeID: "chatRevenueTransaction#4c7a4ff", ChatRevenueTransactionsTypeID: "chatRevenueTransactions#95e61144", - StarRevenueStatusTypeID: "starRevenueStatus#e85bd5fb", + StarRevenueStatusTypeID: "starRevenueStatus#779532e8", StarRevenueStatisticsTypeID: "starRevenueStatistics#bd2d9257", PointTypeID: "point#1a13f5b9", VectorPathCommandLineTypeID: "vectorPathCommandLine#db663c8a", @@ -1642,7 +1662,7 @@ func TypesMap() map[uint32]string { UpdateDefaultReactionTypeTypeID: "updateDefaultReactionType#4b615105", UpdateSavedMessagesTagsTypeID: "updateSavedMessagesTags#7386424a", UpdateActiveLiveLocationMessagesTypeID: "updateActiveLiveLocationMessages#a20b9b1f", - UpdateOwnedStarCountTypeID: "updateOwnedStarCount#de995b79", + UpdateOwnedStarCountTypeID: "updateOwnedStarCount#af7ebf88", UpdateChatRevenueAmountTypeID: "updateChatRevenueAmount#c6c9bcc4", UpdateStarRevenueStatusTypeID: "updateStarRevenueStatus#ef4bfccb", UpdateSpeechRecognitionTrialTypeID: "updateSpeechRecognitionTrial#ff4efcc1", @@ -2176,7 +2196,7 @@ func TypesMap() map[uint32]string { GetStickerOutlineRequestTypeID: "getStickerOutline#a3952da5", GetStickersRequestTypeID: "getStickers#45069343", GetAllStickerEmojisRequestTypeID: "getAllStickerEmojis#11ad2e30", - SearchStickersRequestTypeID: "searchStickers#9a19e90b", + SearchStickersRequestTypeID: "searchStickers#66428c3a", GetGreetingStickersRequestTypeID: "getGreetingStickers#16581d1c", GetPremiumStickersRequestTypeID: "getPremiumStickers#ef410a50", GetInstalledStickerSetsRequestTypeID: "getInstalledStickerSets#612ef6f6", @@ -2212,6 +2232,7 @@ func TypesMap() map[uint32]string { AddSavedAnimationRequestTypeID: "addSavedAnimation#a44bf860", RemoveSavedAnimationRequestTypeID: "removeSavedAnimation#e275a919", GetRecentInlineBotsRequestTypeID: "getRecentInlineBots#55b3723c", + GetOwnedBotsRequestTypeID: "getOwnedBots#8b87c7fd", SearchHashtagsRequestTypeID: "searchHashtags#3e34a571", RemoveRecentHashtagRequestTypeID: "removeRecentHashtag#c393a0a4", GetLinkPreviewRequestTypeID: "getLinkPreview#c2096321", @@ -2439,6 +2460,13 @@ func TypesMap() map[uint32]string { EditStarSubscriptionRequestTypeID: "editStarSubscription#7a1a3918", EditUserStarSubscriptionRequestTypeID: "editUserStarSubscription#51b16e89", ReuseStarSubscriptionRequestTypeID: "reuseStarSubscription#2e677441", + SetChatAffiliateProgramRequestTypeID: "setChatAffiliateProgram#e00237", + SearchChatAffiliateProgramRequestTypeID: "searchChatAffiliateProgram#b02c09ba", + SearchAffiliateProgramsRequestTypeID: "searchAffiliatePrograms#617c974c", + ConnectChatAffiliateProgramRequestTypeID: "connectChatAffiliateProgram#75b163c4", + DisconnectChatAffiliateProgramRequestTypeID: "disconnectChatAffiliateProgram#48ef7257", + GetChatAffiliateProgramRequestTypeID: "getChatAffiliateProgram#6ec8a39a", + GetChatAffiliateProgramsRequestTypeID: "getChatAffiliatePrograms#f9df5251", GetBusinessFeaturesRequestTypeID: "getBusinessFeatures#c4906001", AcceptTermsOfServiceRequestTypeID: "acceptTermsOfService#7efe03e4", SearchStringsByPrefixRequestTypeID: "searchStringsByPrefix#a8145813", @@ -2636,11 +2664,22 @@ func NamesMap() map[string]uint32 { "inputChatPhotoSticker": InputChatPhotoStickerTypeID, "chatPermissions": ChatPermissionsTypeID, "chatAdministratorRights": ChatAdministratorRightsTypeID, + "starAmount": StarAmountTypeID, "starSubscriptionTypeChannel": StarSubscriptionTypeChannelTypeID, "starSubscriptionTypeBot": StarSubscriptionTypeBotTypeID, "starSubscriptionPricing": StarSubscriptionPricingTypeID, "starSubscription": StarSubscriptionTypeID, "starSubscriptions": StarSubscriptionsTypeID, + "affiliateProgramSortOrderProfitability": AffiliateProgramSortOrderProfitabilityTypeID, + "affiliateProgramSortOrderCreationDate": AffiliateProgramSortOrderCreationDateTypeID, + "affiliateProgramSortOrderRevenue": AffiliateProgramSortOrderRevenueTypeID, + "affiliateProgramParameters": AffiliateProgramParametersTypeID, + "affiliateProgramInfo": AffiliateProgramInfoTypeID, + "affiliateInfo": AffiliateInfoTypeID, + "foundAffiliateProgram": FoundAffiliateProgramTypeID, + "foundAffiliatePrograms": FoundAffiliateProgramsTypeID, + "chatAffiliateProgram": ChatAffiliateProgramTypeID, + "chatAffiliatePrograms": ChatAffiliateProgramsTypeID, "productInfo": ProductInfoTypeID, "premiumPaymentOption": PremiumPaymentOptionTypeID, "premiumStatePaymentOption": PremiumStatePaymentOptionTypeID, @@ -2658,27 +2697,31 @@ func NamesMap() map[string]uint32 { "userGifts": UserGiftsTypeID, "starTransactionDirectionIncoming": StarTransactionDirectionIncomingTypeID, "starTransactionDirectionOutgoing": StarTransactionDirectionOutgoingTypeID, - "botTransactionPurposePaidMedia": BotTransactionPurposePaidMediaTypeID, - "botTransactionPurposeInvoicePayment": BotTransactionPurposeInvoicePaymentTypeID, - "botTransactionPurposeSubscription": BotTransactionPurposeSubscriptionTypeID, - "chatTransactionPurposePaidMedia": ChatTransactionPurposePaidMediaTypeID, - "chatTransactionPurposeJoin": ChatTransactionPurposeJoinTypeID, - "chatTransactionPurposeReaction": ChatTransactionPurposeReactionTypeID, - "chatTransactionPurposeGiveaway": ChatTransactionPurposeGiveawayTypeID, - "userTransactionPurposeGiftedStars": UserTransactionPurposeGiftedStarsTypeID, - "userTransactionPurposeGiftSell": UserTransactionPurposeGiftSellTypeID, - "userTransactionPurposeGiftSend": UserTransactionPurposeGiftSendTypeID, - "starTransactionPartnerTelegram": StarTransactionPartnerTelegramTypeID, - "starTransactionPartnerAppStore": StarTransactionPartnerAppStoreTypeID, - "starTransactionPartnerGooglePlay": StarTransactionPartnerGooglePlayTypeID, - "starTransactionPartnerFragment": StarTransactionPartnerFragmentTypeID, - "starTransactionPartnerTelegramAds": StarTransactionPartnerTelegramAdsTypeID, - "starTransactionPartnerTelegramApi": StarTransactionPartnerTelegramAPITypeID, - "starTransactionPartnerBot": StarTransactionPartnerBotTypeID, - "starTransactionPartnerBusiness": StarTransactionPartnerBusinessTypeID, - "starTransactionPartnerChat": StarTransactionPartnerChatTypeID, - "starTransactionPartnerUser": StarTransactionPartnerUserTypeID, - "starTransactionPartnerUnsupported": StarTransactionPartnerUnsupportedTypeID, + "starTransactionTypePremiumBotDeposit": StarTransactionTypePremiumBotDepositTypeID, + "starTransactionTypeAppStoreDeposit": StarTransactionTypeAppStoreDepositTypeID, + "starTransactionTypeGooglePlayDeposit": StarTransactionTypeGooglePlayDepositTypeID, + "starTransactionTypeFragmentDeposit": StarTransactionTypeFragmentDepositTypeID, + "starTransactionTypeUserDeposit": StarTransactionTypeUserDepositTypeID, + "starTransactionTypeGiveawayDeposit": StarTransactionTypeGiveawayDepositTypeID, + "starTransactionTypeFragmentWithdrawal": StarTransactionTypeFragmentWithdrawalTypeID, + "starTransactionTypeTelegramAdsWithdrawal": StarTransactionTypeTelegramAdsWithdrawalTypeID, + "starTransactionTypeTelegramApiUsage": StarTransactionTypeTelegramAPIUsageTypeID, + "starTransactionTypeBotPaidMediaPurchase": StarTransactionTypeBotPaidMediaPurchaseTypeID, + "starTransactionTypeBotPaidMediaSale": StarTransactionTypeBotPaidMediaSaleTypeID, + "starTransactionTypeChannelPaidMediaPurchase": StarTransactionTypeChannelPaidMediaPurchaseTypeID, + "starTransactionTypeChannelPaidMediaSale": StarTransactionTypeChannelPaidMediaSaleTypeID, + "starTransactionTypeBotInvoicePurchase": StarTransactionTypeBotInvoicePurchaseTypeID, + "starTransactionTypeBotInvoiceSale": StarTransactionTypeBotInvoiceSaleTypeID, + "starTransactionTypeBotSubscriptionPurchase": StarTransactionTypeBotSubscriptionPurchaseTypeID, + "starTransactionTypeBotSubscriptionSale": StarTransactionTypeBotSubscriptionSaleTypeID, + "starTransactionTypeChannelSubscriptionPurchase": StarTransactionTypeChannelSubscriptionPurchaseTypeID, + "starTransactionTypeChannelSubscriptionSale": StarTransactionTypeChannelSubscriptionSaleTypeID, + "starTransactionTypeGiftPurchase": StarTransactionTypeGiftPurchaseTypeID, + "starTransactionTypeGiftSale": StarTransactionTypeGiftSaleTypeID, + "starTransactionTypeChannelPaidReactionSend": StarTransactionTypeChannelPaidReactionSendTypeID, + "starTransactionTypeChannelPaidReactionReceive": StarTransactionTypeChannelPaidReactionReceiveTypeID, + "starTransactionTypeAffiliateProgramCommission": StarTransactionTypeAffiliateProgramCommissionTypeID, + "starTransactionTypeUnsupported": StarTransactionTypeUnsupportedTypeID, "starTransaction": StarTransactionTypeID, "starTransactions": StarTransactionsTypeID, "giveawayParticipantStatusEligible": GiveawayParticipantStatusEligibleTypeID, @@ -3811,6 +3854,7 @@ func NamesMap() map[string]uint32 { "internalLinkTypeBusinessChat": InternalLinkTypeBusinessChatTypeID, "internalLinkTypeBuyStars": InternalLinkTypeBuyStarsTypeID, "internalLinkTypeChangePhoneNumber": InternalLinkTypeChangePhoneNumberTypeID, + "internalLinkTypeChatAffiliateProgram": InternalLinkTypeChatAffiliateProgramTypeID, "internalLinkTypeChatBoost": InternalLinkTypeChatBoostTypeID, "internalLinkTypeChatFolderInvite": InternalLinkTypeChatFolderInviteTypeID, "internalLinkTypeChatFolderSettings": InternalLinkTypeChatFolderSettingsTypeID, @@ -3864,6 +3908,10 @@ func NamesMap() map[string]uint32 { "fileTypeSecret": FileTypeSecretTypeID, "fileTypeSecretThumbnail": FileTypeSecretThumbnailTypeID, "fileTypeSecure": FileTypeSecureTypeID, + "fileTypeSelfDestructingPhoto": FileTypeSelfDestructingPhotoTypeID, + "fileTypeSelfDestructingVideo": FileTypeSelfDestructingVideoTypeID, + "fileTypeSelfDestructingVideoNote": FileTypeSelfDestructingVideoNoteTypeID, + "fileTypeSelfDestructingVoiceNote": FileTypeSelfDestructingVoiceNoteTypeID, "fileTypeSticker": FileTypeStickerTypeID, "fileTypeThumbnail": FileTypeThumbnailTypeID, "fileTypeUnknown": FileTypeUnknownTypeID, @@ -4670,6 +4718,7 @@ func NamesMap() map[string]uint32 { "addSavedAnimation": AddSavedAnimationRequestTypeID, "removeSavedAnimation": RemoveSavedAnimationRequestTypeID, "getRecentInlineBots": GetRecentInlineBotsRequestTypeID, + "getOwnedBots": GetOwnedBotsRequestTypeID, "searchHashtags": SearchHashtagsRequestTypeID, "removeRecentHashtag": RemoveRecentHashtagRequestTypeID, "getLinkPreview": GetLinkPreviewRequestTypeID, @@ -4897,6 +4946,13 @@ func NamesMap() map[string]uint32 { "editStarSubscription": EditStarSubscriptionRequestTypeID, "editUserStarSubscription": EditUserStarSubscriptionRequestTypeID, "reuseStarSubscription": ReuseStarSubscriptionRequestTypeID, + "setChatAffiliateProgram": SetChatAffiliateProgramRequestTypeID, + "searchChatAffiliateProgram": SearchChatAffiliateProgramRequestTypeID, + "searchAffiliatePrograms": SearchAffiliateProgramsRequestTypeID, + "connectChatAffiliateProgram": ConnectChatAffiliateProgramRequestTypeID, + "disconnectChatAffiliateProgram": DisconnectChatAffiliateProgramRequestTypeID, + "getChatAffiliateProgram": GetChatAffiliateProgramRequestTypeID, + "getChatAffiliatePrograms": GetChatAffiliateProgramsRequestTypeID, "getBusinessFeatures": GetBusinessFeaturesRequestTypeID, "acceptTermsOfService": AcceptTermsOfServiceRequestTypeID, "searchStringsByPrefix": SearchStringsByPrefixRequestTypeID, @@ -5094,11 +5150,22 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InputChatPhotoStickerTypeID: func() bin.Object { return &InputChatPhotoSticker{} }, ChatPermissionsTypeID: func() bin.Object { return &ChatPermissions{} }, ChatAdministratorRightsTypeID: func() bin.Object { return &ChatAdministratorRights{} }, + StarAmountTypeID: func() bin.Object { return &StarAmount{} }, StarSubscriptionTypeChannelTypeID: func() bin.Object { return &StarSubscriptionTypeChannel{} }, StarSubscriptionTypeBotTypeID: func() bin.Object { return &StarSubscriptionTypeBot{} }, StarSubscriptionPricingTypeID: func() bin.Object { return &StarSubscriptionPricing{} }, StarSubscriptionTypeID: func() bin.Object { return &StarSubscription{} }, StarSubscriptionsTypeID: func() bin.Object { return &StarSubscriptions{} }, + AffiliateProgramSortOrderProfitabilityTypeID: func() bin.Object { return &AffiliateProgramSortOrderProfitability{} }, + AffiliateProgramSortOrderCreationDateTypeID: func() bin.Object { return &AffiliateProgramSortOrderCreationDate{} }, + AffiliateProgramSortOrderRevenueTypeID: func() bin.Object { return &AffiliateProgramSortOrderRevenue{} }, + AffiliateProgramParametersTypeID: func() bin.Object { return &AffiliateProgramParameters{} }, + AffiliateProgramInfoTypeID: func() bin.Object { return &AffiliateProgramInfo{} }, + AffiliateInfoTypeID: func() bin.Object { return &AffiliateInfo{} }, + FoundAffiliateProgramTypeID: func() bin.Object { return &FoundAffiliateProgram{} }, + FoundAffiliateProgramsTypeID: func() bin.Object { return &FoundAffiliatePrograms{} }, + ChatAffiliateProgramTypeID: func() bin.Object { return &ChatAffiliateProgram{} }, + ChatAffiliateProgramsTypeID: func() bin.Object { return &ChatAffiliatePrograms{} }, ProductInfoTypeID: func() bin.Object { return &ProductInfo{} }, PremiumPaymentOptionTypeID: func() bin.Object { return &PremiumPaymentOption{} }, PremiumStatePaymentOptionTypeID: func() bin.Object { return &PremiumStatePaymentOption{} }, @@ -5116,27 +5183,31 @@ func TypesConstructorMap() map[uint32]func() bin.Object { UserGiftsTypeID: func() bin.Object { return &UserGifts{} }, StarTransactionDirectionIncomingTypeID: func() bin.Object { return &StarTransactionDirectionIncoming{} }, StarTransactionDirectionOutgoingTypeID: func() bin.Object { return &StarTransactionDirectionOutgoing{} }, - BotTransactionPurposePaidMediaTypeID: func() bin.Object { return &BotTransactionPurposePaidMedia{} }, - BotTransactionPurposeInvoicePaymentTypeID: func() bin.Object { return &BotTransactionPurposeInvoicePayment{} }, - BotTransactionPurposeSubscriptionTypeID: func() bin.Object { return &BotTransactionPurposeSubscription{} }, - ChatTransactionPurposePaidMediaTypeID: func() bin.Object { return &ChatTransactionPurposePaidMedia{} }, - ChatTransactionPurposeJoinTypeID: func() bin.Object { return &ChatTransactionPurposeJoin{} }, - ChatTransactionPurposeReactionTypeID: func() bin.Object { return &ChatTransactionPurposeReaction{} }, - ChatTransactionPurposeGiveawayTypeID: func() bin.Object { return &ChatTransactionPurposeGiveaway{} }, - UserTransactionPurposeGiftedStarsTypeID: func() bin.Object { return &UserTransactionPurposeGiftedStars{} }, - UserTransactionPurposeGiftSellTypeID: func() bin.Object { return &UserTransactionPurposeGiftSell{} }, - UserTransactionPurposeGiftSendTypeID: func() bin.Object { return &UserTransactionPurposeGiftSend{} }, - StarTransactionPartnerTelegramTypeID: func() bin.Object { return &StarTransactionPartnerTelegram{} }, - StarTransactionPartnerAppStoreTypeID: func() bin.Object { return &StarTransactionPartnerAppStore{} }, - StarTransactionPartnerGooglePlayTypeID: func() bin.Object { return &StarTransactionPartnerGooglePlay{} }, - StarTransactionPartnerFragmentTypeID: func() bin.Object { return &StarTransactionPartnerFragment{} }, - StarTransactionPartnerTelegramAdsTypeID: func() bin.Object { return &StarTransactionPartnerTelegramAds{} }, - StarTransactionPartnerTelegramAPITypeID: func() bin.Object { return &StarTransactionPartnerTelegramAPI{} }, - StarTransactionPartnerBotTypeID: func() bin.Object { return &StarTransactionPartnerBot{} }, - StarTransactionPartnerBusinessTypeID: func() bin.Object { return &StarTransactionPartnerBusiness{} }, - StarTransactionPartnerChatTypeID: func() bin.Object { return &StarTransactionPartnerChat{} }, - StarTransactionPartnerUserTypeID: func() bin.Object { return &StarTransactionPartnerUser{} }, - StarTransactionPartnerUnsupportedTypeID: func() bin.Object { return &StarTransactionPartnerUnsupported{} }, + StarTransactionTypePremiumBotDepositTypeID: func() bin.Object { return &StarTransactionTypePremiumBotDeposit{} }, + StarTransactionTypeAppStoreDepositTypeID: func() bin.Object { return &StarTransactionTypeAppStoreDeposit{} }, + StarTransactionTypeGooglePlayDepositTypeID: func() bin.Object { return &StarTransactionTypeGooglePlayDeposit{} }, + StarTransactionTypeFragmentDepositTypeID: func() bin.Object { return &StarTransactionTypeFragmentDeposit{} }, + StarTransactionTypeUserDepositTypeID: func() bin.Object { return &StarTransactionTypeUserDeposit{} }, + StarTransactionTypeGiveawayDepositTypeID: func() bin.Object { return &StarTransactionTypeGiveawayDeposit{} }, + StarTransactionTypeFragmentWithdrawalTypeID: func() bin.Object { return &StarTransactionTypeFragmentWithdrawal{} }, + StarTransactionTypeTelegramAdsWithdrawalTypeID: func() bin.Object { return &StarTransactionTypeTelegramAdsWithdrawal{} }, + StarTransactionTypeTelegramAPIUsageTypeID: func() bin.Object { return &StarTransactionTypeTelegramAPIUsage{} }, + StarTransactionTypeBotPaidMediaPurchaseTypeID: func() bin.Object { return &StarTransactionTypeBotPaidMediaPurchase{} }, + StarTransactionTypeBotPaidMediaSaleTypeID: func() bin.Object { return &StarTransactionTypeBotPaidMediaSale{} }, + StarTransactionTypeChannelPaidMediaPurchaseTypeID: func() bin.Object { return &StarTransactionTypeChannelPaidMediaPurchase{} }, + StarTransactionTypeChannelPaidMediaSaleTypeID: func() bin.Object { return &StarTransactionTypeChannelPaidMediaSale{} }, + StarTransactionTypeBotInvoicePurchaseTypeID: func() bin.Object { return &StarTransactionTypeBotInvoicePurchase{} }, + StarTransactionTypeBotInvoiceSaleTypeID: func() bin.Object { return &StarTransactionTypeBotInvoiceSale{} }, + StarTransactionTypeBotSubscriptionPurchaseTypeID: func() bin.Object { return &StarTransactionTypeBotSubscriptionPurchase{} }, + StarTransactionTypeBotSubscriptionSaleTypeID: func() bin.Object { return &StarTransactionTypeBotSubscriptionSale{} }, + StarTransactionTypeChannelSubscriptionPurchaseTypeID: func() bin.Object { return &StarTransactionTypeChannelSubscriptionPurchase{} }, + StarTransactionTypeChannelSubscriptionSaleTypeID: func() bin.Object { return &StarTransactionTypeChannelSubscriptionSale{} }, + StarTransactionTypeGiftPurchaseTypeID: func() bin.Object { return &StarTransactionTypeGiftPurchase{} }, + StarTransactionTypeGiftSaleTypeID: func() bin.Object { return &StarTransactionTypeGiftSale{} }, + StarTransactionTypeChannelPaidReactionSendTypeID: func() bin.Object { return &StarTransactionTypeChannelPaidReactionSend{} }, + StarTransactionTypeChannelPaidReactionReceiveTypeID: func() bin.Object { return &StarTransactionTypeChannelPaidReactionReceive{} }, + StarTransactionTypeAffiliateProgramCommissionTypeID: func() bin.Object { return &StarTransactionTypeAffiliateProgramCommission{} }, + StarTransactionTypeUnsupportedTypeID: func() bin.Object { return &StarTransactionTypeUnsupported{} }, StarTransactionTypeID: func() bin.Object { return &StarTransaction{} }, StarTransactionsTypeID: func() bin.Object { return &StarTransactions{} }, GiveawayParticipantStatusEligibleTypeID: func() bin.Object { return &GiveawayParticipantStatusEligible{} }, @@ -6269,6 +6340,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { InternalLinkTypeBusinessChatTypeID: func() bin.Object { return &InternalLinkTypeBusinessChat{} }, InternalLinkTypeBuyStarsTypeID: func() bin.Object { return &InternalLinkTypeBuyStars{} }, InternalLinkTypeChangePhoneNumberTypeID: func() bin.Object { return &InternalLinkTypeChangePhoneNumber{} }, + InternalLinkTypeChatAffiliateProgramTypeID: func() bin.Object { return &InternalLinkTypeChatAffiliateProgram{} }, InternalLinkTypeChatBoostTypeID: func() bin.Object { return &InternalLinkTypeChatBoost{} }, InternalLinkTypeChatFolderInviteTypeID: func() bin.Object { return &InternalLinkTypeChatFolderInvite{} }, InternalLinkTypeChatFolderSettingsTypeID: func() bin.Object { return &InternalLinkTypeChatFolderSettings{} }, @@ -6322,6 +6394,10 @@ func TypesConstructorMap() map[uint32]func() bin.Object { FileTypeSecretTypeID: func() bin.Object { return &FileTypeSecret{} }, FileTypeSecretThumbnailTypeID: func() bin.Object { return &FileTypeSecretThumbnail{} }, FileTypeSecureTypeID: func() bin.Object { return &FileTypeSecure{} }, + FileTypeSelfDestructingPhotoTypeID: func() bin.Object { return &FileTypeSelfDestructingPhoto{} }, + FileTypeSelfDestructingVideoTypeID: func() bin.Object { return &FileTypeSelfDestructingVideo{} }, + FileTypeSelfDestructingVideoNoteTypeID: func() bin.Object { return &FileTypeSelfDestructingVideoNote{} }, + FileTypeSelfDestructingVoiceNoteTypeID: func() bin.Object { return &FileTypeSelfDestructingVoiceNote{} }, FileTypeStickerTypeID: func() bin.Object { return &FileTypeSticker{} }, FileTypeThumbnailTypeID: func() bin.Object { return &FileTypeThumbnail{} }, FileTypeUnknownTypeID: func() bin.Object { return &FileTypeUnknown{} }, @@ -7128,6 +7204,7 @@ func TypesConstructorMap() map[uint32]func() bin.Object { AddSavedAnimationRequestTypeID: func() bin.Object { return &AddSavedAnimationRequest{} }, RemoveSavedAnimationRequestTypeID: func() bin.Object { return &RemoveSavedAnimationRequest{} }, GetRecentInlineBotsRequestTypeID: func() bin.Object { return &GetRecentInlineBotsRequest{} }, + GetOwnedBotsRequestTypeID: func() bin.Object { return &GetOwnedBotsRequest{} }, SearchHashtagsRequestTypeID: func() bin.Object { return &SearchHashtagsRequest{} }, RemoveRecentHashtagRequestTypeID: func() bin.Object { return &RemoveRecentHashtagRequest{} }, GetLinkPreviewRequestTypeID: func() bin.Object { return &GetLinkPreviewRequest{} }, @@ -7355,6 +7432,13 @@ func TypesConstructorMap() map[uint32]func() bin.Object { EditStarSubscriptionRequestTypeID: func() bin.Object { return &EditStarSubscriptionRequest{} }, EditUserStarSubscriptionRequestTypeID: func() bin.Object { return &EditUserStarSubscriptionRequest{} }, ReuseStarSubscriptionRequestTypeID: func() bin.Object { return &ReuseStarSubscriptionRequest{} }, + SetChatAffiliateProgramRequestTypeID: func() bin.Object { return &SetChatAffiliateProgramRequest{} }, + SearchChatAffiliateProgramRequestTypeID: func() bin.Object { return &SearchChatAffiliateProgramRequest{} }, + SearchAffiliateProgramsRequestTypeID: func() bin.Object { return &SearchAffiliateProgramsRequest{} }, + ConnectChatAffiliateProgramRequestTypeID: func() bin.Object { return &ConnectChatAffiliateProgramRequest{} }, + DisconnectChatAffiliateProgramRequestTypeID: func() bin.Object { return &DisconnectChatAffiliateProgramRequest{} }, + GetChatAffiliateProgramRequestTypeID: func() bin.Object { return &GetChatAffiliateProgramRequest{} }, + GetChatAffiliateProgramsRequestTypeID: func() bin.Object { return &GetChatAffiliateProgramsRequest{} }, GetBusinessFeaturesRequestTypeID: func() bin.Object { return &GetBusinessFeaturesRequest{} }, AcceptTermsOfServiceRequestTypeID: func() bin.Object { return &AcceptTermsOfServiceRequest{} }, SearchStringsByPrefixRequestTypeID: func() bin.Object { return &SearchStringsByPrefixRequest{} }, @@ -7408,6 +7492,11 @@ func TypesConstructorMap() map[uint32]func() bin.Object { // ClassConstructorsMap maps class schema name to constructors type ids. func ClassConstructorsMap() map[string][]uint32 { return map[string][]uint32{ + AffiliateProgramSortOrderClassName: { + AffiliateProgramSortOrderProfitabilityTypeID, + AffiliateProgramSortOrderCreationDateTypeID, + AffiliateProgramSortOrderRevenueTypeID, + }, AuthenticationCodeTypeClassName: { AuthenticationCodeTypeTelegramMessageTypeID, AuthenticationCodeTypeSMSTypeID, @@ -7468,11 +7557,6 @@ func ClassConstructorsMap() map[string][]uint32 { BotCommandScopeChatAdministratorsTypeID, BotCommandScopeChatMemberTypeID, }, - BotTransactionPurposeClassName: { - BotTransactionPurposePaidMediaTypeID, - BotTransactionPurposeInvoicePaymentTypeID, - BotTransactionPurposeSubscriptionTypeID, - }, BotWriteAccessAllowReasonClassName: { BotWriteAccessAllowReasonConnectedWebsiteTypeID, BotWriteAccessAllowReasonAddedToAttachmentMenuTypeID, @@ -7681,12 +7765,6 @@ func ClassConstructorsMap() map[string][]uint32 { ChatStatisticsObjectTypeMessageTypeID, ChatStatisticsObjectTypeStoryTypeID, }, - ChatTransactionPurposeClassName: { - ChatTransactionPurposePaidMediaTypeID, - ChatTransactionPurposeJoinTypeID, - ChatTransactionPurposeReactionTypeID, - ChatTransactionPurposeGiveawayTypeID, - }, ChatTypeClassName: { ChatTypePrivateTypeID, ChatTypeBasicGroupTypeID, @@ -7766,6 +7844,10 @@ func ClassConstructorsMap() map[string][]uint32 { FileTypeSecretTypeID, FileTypeSecretThumbnailTypeID, FileTypeSecureTypeID, + FileTypeSelfDestructingPhotoTypeID, + FileTypeSelfDestructingVideoTypeID, + FileTypeSelfDestructingVideoNoteTypeID, + FileTypeSelfDestructingVoiceNoteTypeID, FileTypeStickerTypeID, FileTypeThumbnailTypeID, FileTypeUnknownTypeID, @@ -7955,6 +8037,7 @@ func ClassConstructorsMap() map[string][]uint32 { InternalLinkTypeBusinessChatTypeID, InternalLinkTypeBuyStarsTypeID, InternalLinkTypeChangePhoneNumberTypeID, + InternalLinkTypeChatAffiliateProgramTypeID, InternalLinkTypeChatBoostTypeID, InternalLinkTypeChatFolderInviteTypeID, InternalLinkTypeChatFolderSettingsTypeID, @@ -8605,18 +8688,32 @@ func ClassConstructorsMap() map[string][]uint32 { StarTransactionDirectionIncomingTypeID, StarTransactionDirectionOutgoingTypeID, }, - StarTransactionPartnerClassName: { - StarTransactionPartnerTelegramTypeID, - StarTransactionPartnerAppStoreTypeID, - StarTransactionPartnerGooglePlayTypeID, - StarTransactionPartnerFragmentTypeID, - StarTransactionPartnerTelegramAdsTypeID, - StarTransactionPartnerTelegramAPITypeID, - StarTransactionPartnerBotTypeID, - StarTransactionPartnerBusinessTypeID, - StarTransactionPartnerChatTypeID, - StarTransactionPartnerUserTypeID, - StarTransactionPartnerUnsupportedTypeID, + StarTransactionTypeClassName: { + StarTransactionTypePremiumBotDepositTypeID, + StarTransactionTypeAppStoreDepositTypeID, + StarTransactionTypeGooglePlayDepositTypeID, + StarTransactionTypeFragmentDepositTypeID, + StarTransactionTypeUserDepositTypeID, + StarTransactionTypeGiveawayDepositTypeID, + StarTransactionTypeFragmentWithdrawalTypeID, + StarTransactionTypeTelegramAdsWithdrawalTypeID, + StarTransactionTypeTelegramAPIUsageTypeID, + StarTransactionTypeBotPaidMediaPurchaseTypeID, + StarTransactionTypeBotPaidMediaSaleTypeID, + StarTransactionTypeChannelPaidMediaPurchaseTypeID, + StarTransactionTypeChannelPaidMediaSaleTypeID, + StarTransactionTypeBotInvoicePurchaseTypeID, + StarTransactionTypeBotInvoiceSaleTypeID, + StarTransactionTypeBotSubscriptionPurchaseTypeID, + StarTransactionTypeBotSubscriptionSaleTypeID, + StarTransactionTypeChannelSubscriptionPurchaseTypeID, + StarTransactionTypeChannelSubscriptionSaleTypeID, + StarTransactionTypeGiftPurchaseTypeID, + StarTransactionTypeGiftSaleTypeID, + StarTransactionTypeChannelPaidReactionSendTypeID, + StarTransactionTypeChannelPaidReactionReceiveTypeID, + StarTransactionTypeAffiliateProgramCommissionTypeID, + StarTransactionTypeUnsupportedTypeID, }, StatisticalGraphClassName: { StatisticalGraphDataTypeID, @@ -8957,11 +9054,6 @@ func ClassConstructorsMap() map[string][]uint32 { UserStatusLastWeekTypeID, UserStatusLastMonthTypeID, }, - UserTransactionPurposeClassName: { - UserTransactionPurposeGiftedStarsTypeID, - UserTransactionPurposeGiftSellTypeID, - UserTransactionPurposeGiftSendTypeID, - }, UserTypeClassName: { UserTypeRegularTypeID, UserTypeDeletedTypeID, diff --git a/tdapi/tl_search_affiliate_programs_gen.go b/tdapi/tl_search_affiliate_programs_gen.go new file mode 100644 index 0000000000..e19412df2e --- /dev/null +++ b/tdapi/tl_search_affiliate_programs_gen.go @@ -0,0 +1,318 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// SearchAffiliateProgramsRequest represents TL type `searchAffiliatePrograms#617c974c`. +type SearchAffiliateProgramsRequest struct { + // Identifier of the chat for which affiliate programs are searched for. Can be an + // identifier of the Saved Messages chat, of a chat with an owned bot, or of a channel + // chat with can_post_messages administrator right + ChatID int64 + // Sort order for the results + SortOrder AffiliateProgramSortOrderClass + // Offset of the first affiliate program to return as received from the previous request; + // use empty string to get the first chunk of results + Offset string + // The maximum number of affiliate programs to return + Limit int32 +} + +// SearchAffiliateProgramsRequestTypeID is TL type id of SearchAffiliateProgramsRequest. +const SearchAffiliateProgramsRequestTypeID = 0x617c974c + +// Ensuring interfaces in compile-time for SearchAffiliateProgramsRequest. +var ( + _ bin.Encoder = &SearchAffiliateProgramsRequest{} + _ bin.Decoder = &SearchAffiliateProgramsRequest{} + _ bin.BareEncoder = &SearchAffiliateProgramsRequest{} + _ bin.BareDecoder = &SearchAffiliateProgramsRequest{} +) + +func (s *SearchAffiliateProgramsRequest) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.SortOrder == nil) { + return false + } + if !(s.Offset == "") { + return false + } + if !(s.Limit == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SearchAffiliateProgramsRequest) String() string { + if s == nil { + return "SearchAffiliateProgramsRequest(nil)" + } + type Alias SearchAffiliateProgramsRequest + return fmt.Sprintf("SearchAffiliateProgramsRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SearchAffiliateProgramsRequest) TypeID() uint32 { + return SearchAffiliateProgramsRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SearchAffiliateProgramsRequest) TypeName() string { + return "searchAffiliatePrograms" +} + +// TypeInfo returns info about TL type. +func (s *SearchAffiliateProgramsRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "searchAffiliatePrograms", + ID: SearchAffiliateProgramsRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "SortOrder", + SchemaName: "sort_order", + }, + { + Name: "Offset", + SchemaName: "offset", + }, + { + Name: "Limit", + SchemaName: "limit", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SearchAffiliateProgramsRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode searchAffiliatePrograms#617c974c as nil") + } + b.PutID(SearchAffiliateProgramsRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SearchAffiliateProgramsRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode searchAffiliatePrograms#617c974c as nil") + } + b.PutInt53(s.ChatID) + if s.SortOrder == nil { + return fmt.Errorf("unable to encode searchAffiliatePrograms#617c974c: field sort_order is nil") + } + if err := s.SortOrder.Encode(b); err != nil { + return fmt.Errorf("unable to encode searchAffiliatePrograms#617c974c: field sort_order: %w", err) + } + b.PutString(s.Offset) + b.PutInt32(s.Limit) + return nil +} + +// Decode implements bin.Decoder. +func (s *SearchAffiliateProgramsRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode searchAffiliatePrograms#617c974c to nil") + } + if err := b.ConsumeID(SearchAffiliateProgramsRequestTypeID); err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SearchAffiliateProgramsRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode searchAffiliatePrograms#617c974c to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := DecodeAffiliateProgramSortOrder(b) + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field sort_order: %w", err) + } + s.SortOrder = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field offset: %w", err) + } + s.Offset = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field limit: %w", err) + } + s.Limit = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SearchAffiliateProgramsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode searchAffiliatePrograms#617c974c as nil") + } + b.ObjStart() + b.PutID("searchAffiliatePrograms") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("sort_order") + if s.SortOrder == nil { + return fmt.Errorf("unable to encode searchAffiliatePrograms#617c974c: field sort_order is nil") + } + if err := s.SortOrder.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode searchAffiliatePrograms#617c974c: field sort_order: %w", err) + } + b.Comma() + b.FieldStart("offset") + b.PutString(s.Offset) + b.Comma() + b.FieldStart("limit") + b.PutInt32(s.Limit) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SearchAffiliateProgramsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode searchAffiliatePrograms#617c974c to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("searchAffiliatePrograms"); err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field chat_id: %w", err) + } + s.ChatID = value + case "sort_order": + value, err := DecodeTDLibJSONAffiliateProgramSortOrder(b) + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field sort_order: %w", err) + } + s.SortOrder = value + case "offset": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field offset: %w", err) + } + s.Offset = value + case "limit": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode searchAffiliatePrograms#617c974c: field limit: %w", err) + } + s.Limit = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *SearchAffiliateProgramsRequest) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetSortOrder returns value of SortOrder field. +func (s *SearchAffiliateProgramsRequest) GetSortOrder() (value AffiliateProgramSortOrderClass) { + if s == nil { + return + } + return s.SortOrder +} + +// GetOffset returns value of Offset field. +func (s *SearchAffiliateProgramsRequest) GetOffset() (value string) { + if s == nil { + return + } + return s.Offset +} + +// GetLimit returns value of Limit field. +func (s *SearchAffiliateProgramsRequest) GetLimit() (value int32) { + if s == nil { + return + } + return s.Limit +} + +// SearchAffiliatePrograms invokes method searchAffiliatePrograms#617c974c returning error if any. +func (c *Client) SearchAffiliatePrograms(ctx context.Context, request *SearchAffiliateProgramsRequest) (*FoundAffiliatePrograms, error) { + var result FoundAffiliatePrograms + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_search_chat_affiliate_program_gen.go b/tdapi/tl_search_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..c42b3ea6dd --- /dev/null +++ b/tdapi/tl_search_chat_affiliate_program_gen.go @@ -0,0 +1,237 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// SearchChatAffiliateProgramRequest represents TL type `searchChatAffiliateProgram#b02c09ba`. +type SearchChatAffiliateProgramRequest struct { + // Username of the chat + Username string + // The referrer from an internalLinkTypeChatAffiliateProgram link + Referrer string +} + +// SearchChatAffiliateProgramRequestTypeID is TL type id of SearchChatAffiliateProgramRequest. +const SearchChatAffiliateProgramRequestTypeID = 0xb02c09ba + +// Ensuring interfaces in compile-time for SearchChatAffiliateProgramRequest. +var ( + _ bin.Encoder = &SearchChatAffiliateProgramRequest{} + _ bin.Decoder = &SearchChatAffiliateProgramRequest{} + _ bin.BareEncoder = &SearchChatAffiliateProgramRequest{} + _ bin.BareDecoder = &SearchChatAffiliateProgramRequest{} +) + +func (s *SearchChatAffiliateProgramRequest) Zero() bool { + if s == nil { + return true + } + if !(s.Username == "") { + return false + } + if !(s.Referrer == "") { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SearchChatAffiliateProgramRequest) String() string { + if s == nil { + return "SearchChatAffiliateProgramRequest(nil)" + } + type Alias SearchChatAffiliateProgramRequest + return fmt.Sprintf("SearchChatAffiliateProgramRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SearchChatAffiliateProgramRequest) TypeID() uint32 { + return SearchChatAffiliateProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SearchChatAffiliateProgramRequest) TypeName() string { + return "searchChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (s *SearchChatAffiliateProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "searchChatAffiliateProgram", + ID: SearchChatAffiliateProgramRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "Username", + SchemaName: "username", + }, + { + Name: "Referrer", + SchemaName: "referrer", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SearchChatAffiliateProgramRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode searchChatAffiliateProgram#b02c09ba as nil") + } + b.PutID(SearchChatAffiliateProgramRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SearchChatAffiliateProgramRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode searchChatAffiliateProgram#b02c09ba as nil") + } + b.PutString(s.Username) + b.PutString(s.Referrer) + return nil +} + +// Decode implements bin.Decoder. +func (s *SearchChatAffiliateProgramRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode searchChatAffiliateProgram#b02c09ba to nil") + } + if err := b.ConsumeID(SearchChatAffiliateProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SearchChatAffiliateProgramRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode searchChatAffiliateProgram#b02c09ba to nil") + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: field username: %w", err) + } + s.Username = value + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: field referrer: %w", err) + } + s.Referrer = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SearchChatAffiliateProgramRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode searchChatAffiliateProgram#b02c09ba as nil") + } + b.ObjStart() + b.PutID("searchChatAffiliateProgram") + b.Comma() + b.FieldStart("username") + b.PutString(s.Username) + b.Comma() + b.FieldStart("referrer") + b.PutString(s.Referrer) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SearchChatAffiliateProgramRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode searchChatAffiliateProgram#b02c09ba to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("searchChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: %w", err) + } + case "username": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: field username: %w", err) + } + s.Username = value + case "referrer": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchChatAffiliateProgram#b02c09ba: field referrer: %w", err) + } + s.Referrer = value + default: + return b.Skip() + } + return nil + }) +} + +// GetUsername returns value of Username field. +func (s *SearchChatAffiliateProgramRequest) GetUsername() (value string) { + if s == nil { + return + } + return s.Username +} + +// GetReferrer returns value of Referrer field. +func (s *SearchChatAffiliateProgramRequest) GetReferrer() (value string) { + if s == nil { + return + } + return s.Referrer +} + +// SearchChatAffiliateProgram invokes method searchChatAffiliateProgram#b02c09ba returning error if any. +func (c *Client) SearchChatAffiliateProgram(ctx context.Context, request *SearchChatAffiliateProgramRequest) (*Chat, error) { + var result Chat + + if err := c.rpc.Invoke(ctx, request, &result); err != nil { + return nil, err + } + return &result, nil +} diff --git a/tdapi/tl_search_stickers_gen.go b/tdapi/tl_search_stickers_gen.go index 0246498fee..d96a5a71e3 100644 --- a/tdapi/tl_search_stickers_gen.go +++ b/tdapi/tl_search_stickers_gen.go @@ -31,18 +31,25 @@ var ( _ = tdjson.Encoder{} ) -// SearchStickersRequest represents TL type `searchStickers#9a19e90b`. +// SearchStickersRequest represents TL type `searchStickers#66428c3a`. type SearchStickersRequest struct { // Type of the stickers to return StickerType StickerTypeClass - // Space-separated list of emojis to search for; must be non-empty + // Space-separated list of emojis to search for Emojis string + // Query to search for; may be empty to search for emoji only + Query string + // List of possible IETF language tags of the user's input language; may be empty if + // unknown + InputLanguageCodes []string + // The offset from which to return the stickers; must be non-negative + Offset int32 // The maximum number of stickers to be returned; 0-100 Limit int32 } // SearchStickersRequestTypeID is TL type id of SearchStickersRequest. -const SearchStickersRequestTypeID = 0x9a19e90b +const SearchStickersRequestTypeID = 0x66428c3a // Ensuring interfaces in compile-time for SearchStickersRequest. var ( @@ -62,6 +69,15 @@ func (s *SearchStickersRequest) Zero() bool { if !(s.Emojis == "") { return false } + if !(s.Query == "") { + return false + } + if !(s.InputLanguageCodes == nil) { + return false + } + if !(s.Offset == 0) { + return false + } if !(s.Limit == 0) { return false } @@ -109,6 +125,18 @@ func (s *SearchStickersRequest) TypeInfo() tdp.Type { Name: "Emojis", SchemaName: "emojis", }, + { + Name: "Query", + SchemaName: "query", + }, + { + Name: "InputLanguageCodes", + SchemaName: "input_language_codes", + }, + { + Name: "Offset", + SchemaName: "offset", + }, { Name: "Limit", SchemaName: "limit", @@ -120,7 +148,7 @@ func (s *SearchStickersRequest) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *SearchStickersRequest) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode searchStickers#9a19e90b as nil") + return fmt.Errorf("can't encode searchStickers#66428c3a as nil") } b.PutID(SearchStickersRequestTypeID) return s.EncodeBare(b) @@ -129,15 +157,21 @@ func (s *SearchStickersRequest) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *SearchStickersRequest) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode searchStickers#9a19e90b as nil") + return fmt.Errorf("can't encode searchStickers#66428c3a as nil") } if s.StickerType == nil { - return fmt.Errorf("unable to encode searchStickers#9a19e90b: field sticker_type is nil") + return fmt.Errorf("unable to encode searchStickers#66428c3a: field sticker_type is nil") } if err := s.StickerType.Encode(b); err != nil { - return fmt.Errorf("unable to encode searchStickers#9a19e90b: field sticker_type: %w", err) + return fmt.Errorf("unable to encode searchStickers#66428c3a: field sticker_type: %w", err) } b.PutString(s.Emojis) + b.PutString(s.Query) + b.PutInt(len(s.InputLanguageCodes)) + for _, v := range s.InputLanguageCodes { + b.PutString(v) + } + b.PutInt32(s.Offset) b.PutInt32(s.Limit) return nil } @@ -145,10 +179,10 @@ func (s *SearchStickersRequest) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *SearchStickersRequest) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode searchStickers#9a19e90b to nil") + return fmt.Errorf("can't decode searchStickers#66428c3a to nil") } if err := b.ConsumeID(SearchStickersRequestTypeID); err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: %w", err) } return s.DecodeBare(b) } @@ -156,26 +190,57 @@ func (s *SearchStickersRequest) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *SearchStickersRequest) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode searchStickers#9a19e90b to nil") + return fmt.Errorf("can't decode searchStickers#66428c3a to nil") } { value, err := DecodeStickerType(b) if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field sticker_type: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field sticker_type: %w", err) } s.StickerType = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field emojis: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field emojis: %w", err) } s.Emojis = value } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field query: %w", err) + } + s.Query = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field input_language_codes: %w", err) + } + + if headerLen > 0 { + s.InputLanguageCodes = make([]string, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field input_language_codes: %w", err) + } + s.InputLanguageCodes = append(s.InputLanguageCodes, value) + } + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field offset: %w", err) + } + s.Offset = value + } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field limit: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field limit: %w", err) } s.Limit = value } @@ -185,22 +250,37 @@ func (s *SearchStickersRequest) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SearchStickersRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode searchStickers#9a19e90b as nil") + return fmt.Errorf("can't encode searchStickers#66428c3a as nil") } b.ObjStart() b.PutID("searchStickers") b.Comma() b.FieldStart("sticker_type") if s.StickerType == nil { - return fmt.Errorf("unable to encode searchStickers#9a19e90b: field sticker_type is nil") + return fmt.Errorf("unable to encode searchStickers#66428c3a: field sticker_type is nil") } if err := s.StickerType.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode searchStickers#9a19e90b: field sticker_type: %w", err) + return fmt.Errorf("unable to encode searchStickers#66428c3a: field sticker_type: %w", err) } b.Comma() b.FieldStart("emojis") b.PutString(s.Emojis) b.Comma() + b.FieldStart("query") + b.PutString(s.Query) + b.Comma() + b.FieldStart("input_language_codes") + b.ArrStart() + for _, v := range s.InputLanguageCodes { + b.PutString(v) + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.FieldStart("offset") + b.PutInt32(s.Offset) + b.Comma() b.FieldStart("limit") b.PutInt32(s.Limit) b.Comma() @@ -212,31 +292,54 @@ func (s *SearchStickersRequest) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SearchStickersRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode searchStickers#9a19e90b to nil") + return fmt.Errorf("can't decode searchStickers#66428c3a to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("searchStickers"); err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: %w", err) } case "sticker_type": value, err := DecodeTDLibJSONStickerType(b) if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field sticker_type: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field sticker_type: %w", err) } s.StickerType = value case "emojis": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field emojis: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field emojis: %w", err) } s.Emojis = value + case "query": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field query: %w", err) + } + s.Query = value + case "input_language_codes": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field input_language_codes: %w", err) + } + s.InputLanguageCodes = append(s.InputLanguageCodes, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field input_language_codes: %w", err) + } + case "offset": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode searchStickers#66428c3a: field offset: %w", err) + } + s.Offset = value case "limit": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode searchStickers#9a19e90b: field limit: %w", err) + return fmt.Errorf("unable to decode searchStickers#66428c3a: field limit: %w", err) } s.Limit = value default: @@ -262,6 +365,30 @@ func (s *SearchStickersRequest) GetEmojis() (value string) { return s.Emojis } +// GetQuery returns value of Query field. +func (s *SearchStickersRequest) GetQuery() (value string) { + if s == nil { + return + } + return s.Query +} + +// GetInputLanguageCodes returns value of InputLanguageCodes field. +func (s *SearchStickersRequest) GetInputLanguageCodes() (value []string) { + if s == nil { + return + } + return s.InputLanguageCodes +} + +// GetOffset returns value of Offset field. +func (s *SearchStickersRequest) GetOffset() (value int32) { + if s == nil { + return + } + return s.Offset +} + // GetLimit returns value of Limit field. func (s *SearchStickersRequest) GetLimit() (value int32) { if s == nil { @@ -270,7 +397,7 @@ func (s *SearchStickersRequest) GetLimit() (value int32) { return s.Limit } -// SearchStickers invokes method searchStickers#9a19e90b returning error if any. +// SearchStickers invokes method searchStickers#66428c3a returning error if any. func (c *Client) SearchStickers(ctx context.Context, request *SearchStickersRequest) (*Stickers, error) { var result Stickers diff --git a/tdapi/tl_set_chat_affiliate_program_gen.go b/tdapi/tl_set_chat_affiliate_program_gen.go new file mode 100644 index 0000000000..f6bc6f0ddb --- /dev/null +++ b/tdapi/tl_set_chat_affiliate_program_gen.go @@ -0,0 +1,239 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// SetChatAffiliateProgramRequest represents TL type `setChatAffiliateProgram#e00237`. +type SetChatAffiliateProgramRequest struct { + // Identifier of the chat with an owned bot for which affiliate program is changed + ChatID int64 + // Parameters of the affiliate program; pass null to close the currently active program. + // If there is an active program, then commission and program duration can only be + // increased. + Parameters AffiliateProgramParameters +} + +// SetChatAffiliateProgramRequestTypeID is TL type id of SetChatAffiliateProgramRequest. +const SetChatAffiliateProgramRequestTypeID = 0xe00237 + +// Ensuring interfaces in compile-time for SetChatAffiliateProgramRequest. +var ( + _ bin.Encoder = &SetChatAffiliateProgramRequest{} + _ bin.Decoder = &SetChatAffiliateProgramRequest{} + _ bin.BareEncoder = &SetChatAffiliateProgramRequest{} + _ bin.BareDecoder = &SetChatAffiliateProgramRequest{} +) + +func (s *SetChatAffiliateProgramRequest) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.Parameters.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *SetChatAffiliateProgramRequest) String() string { + if s == nil { + return "SetChatAffiliateProgramRequest(nil)" + } + type Alias SetChatAffiliateProgramRequest + return fmt.Sprintf("SetChatAffiliateProgramRequest%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*SetChatAffiliateProgramRequest) TypeID() uint32 { + return SetChatAffiliateProgramRequestTypeID +} + +// TypeName returns name of type in TL schema. +func (*SetChatAffiliateProgramRequest) TypeName() string { + return "setChatAffiliateProgram" +} + +// TypeInfo returns info about TL type. +func (s *SetChatAffiliateProgramRequest) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "setChatAffiliateProgram", + ID: SetChatAffiliateProgramRequestTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "Parameters", + SchemaName: "parameters", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *SetChatAffiliateProgramRequest) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setChatAffiliateProgram#e00237 as nil") + } + b.PutID(SetChatAffiliateProgramRequestTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *SetChatAffiliateProgramRequest) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode setChatAffiliateProgram#e00237 as nil") + } + b.PutInt53(s.ChatID) + if err := s.Parameters.Encode(b); err != nil { + return fmt.Errorf("unable to encode setChatAffiliateProgram#e00237: field parameters: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *SetChatAffiliateProgramRequest) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setChatAffiliateProgram#e00237 to nil") + } + if err := b.ConsumeID(SetChatAffiliateProgramRequestTypeID); err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *SetChatAffiliateProgramRequest) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode setChatAffiliateProgram#e00237 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: field chat_id: %w", err) + } + s.ChatID = value + } + { + if err := s.Parameters.Decode(b); err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: field parameters: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *SetChatAffiliateProgramRequest) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode setChatAffiliateProgram#e00237 as nil") + } + b.ObjStart() + b.PutID("setChatAffiliateProgram") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("parameters") + if err := s.Parameters.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode setChatAffiliateProgram#e00237: field parameters: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *SetChatAffiliateProgramRequest) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode setChatAffiliateProgram#e00237 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("setChatAffiliateProgram"); err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: field chat_id: %w", err) + } + s.ChatID = value + case "parameters": + if err := s.Parameters.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode setChatAffiliateProgram#e00237: field parameters: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *SetChatAffiliateProgramRequest) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetParameters returns value of Parameters field. +func (s *SetChatAffiliateProgramRequest) GetParameters() (value AffiliateProgramParameters) { + if s == nil { + return + } + return s.Parameters +} + +// SetChatAffiliateProgram invokes method setChatAffiliateProgram#e00237 returning error if any. +func (c *Client) SetChatAffiliateProgram(ctx context.Context, request *SetChatAffiliateProgramRequest) error { + var ok Ok + + if err := c.rpc.Invoke(ctx, request, &ok); err != nil { + return err + } + return nil +} diff --git a/tdapi/tl_star_amount_gen.go b/tdapi/tl_star_amount_gen.go new file mode 100644 index 0000000000..5d431f1431 --- /dev/null +++ b/tdapi/tl_star_amount_gen.go @@ -0,0 +1,227 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// StarAmount represents TL type `starAmount#6f0e6d80`. +type StarAmount struct { + // The integer amount of Telegram Stars rounded to 0 + StarCount int64 + // The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999 + NanostarCount int32 +} + +// StarAmountTypeID is TL type id of StarAmount. +const StarAmountTypeID = 0x6f0e6d80 + +// Ensuring interfaces in compile-time for StarAmount. +var ( + _ bin.Encoder = &StarAmount{} + _ bin.Decoder = &StarAmount{} + _ bin.BareEncoder = &StarAmount{} + _ bin.BareDecoder = &StarAmount{} +) + +func (s *StarAmount) Zero() bool { + if s == nil { + return true + } + if !(s.StarCount == 0) { + return false + } + if !(s.NanostarCount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarAmount) String() string { + if s == nil { + return "StarAmount(nil)" + } + type Alias StarAmount + return fmt.Sprintf("StarAmount%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarAmount) TypeID() uint32 { + return StarAmountTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarAmount) TypeName() string { + return "starAmount" +} + +// TypeInfo returns info about TL type. +func (s *StarAmount) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starAmount", + ID: StarAmountTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "StarCount", + SchemaName: "star_count", + }, + { + Name: "NanostarCount", + SchemaName: "nanostar_count", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarAmount) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil") + } + b.PutID(StarAmountTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarAmount) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil") + } + b.PutInt53(s.StarCount) + b.PutInt32(s.NanostarCount) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarAmount) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil") + } + if err := b.ConsumeID(StarAmountTypeID); err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarAmount) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: field star_count: %w", err) + } + s.StarCount = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: field nanostar_count: %w", err) + } + s.NanostarCount = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarAmount) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starAmount#6f0e6d80 as nil") + } + b.ObjStart() + b.PutID("starAmount") + b.Comma() + b.FieldStart("star_count") + b.PutInt53(s.StarCount) + b.Comma() + b.FieldStart("nanostar_count") + b.PutInt32(s.NanostarCount) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarAmount) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starAmount#6f0e6d80 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starAmount"); err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: %w", err) + } + case "star_count": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: field star_count: %w", err) + } + s.StarCount = value + case "nanostar_count": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starAmount#6f0e6d80: field nanostar_count: %w", err) + } + s.NanostarCount = value + default: + return b.Skip() + } + return nil + }) +} + +// GetStarCount returns value of StarCount field. +func (s *StarAmount) GetStarCount() (value int64) { + if s == nil { + return + } + return s.StarCount +} + +// GetNanostarCount returns value of NanostarCount field. +func (s *StarAmount) GetNanostarCount() (value int32) { + if s == nil { + return + } + return s.NanostarCount +} diff --git a/tdapi/tl_star_revenue_status_gen.go b/tdapi/tl_star_revenue_status_gen.go index 3423111342..d730d5c177 100644 --- a/tdapi/tl_star_revenue_status_gen.go +++ b/tdapi/tl_star_revenue_status_gen.go @@ -31,14 +31,14 @@ var ( _ = tdjson.Encoder{} ) -// StarRevenueStatus represents TL type `starRevenueStatus#e85bd5fb`. +// StarRevenueStatus represents TL type `starRevenueStatus#779532e8`. type StarRevenueStatus struct { - // Total number of Telegram Stars earned - TotalCount int64 - // The number of Telegram Stars that aren't withdrawn yet - CurrentCount int64 - // The number of Telegram Stars that are available for withdrawal - AvailableCount int64 + // Total amount of Telegram Stars earned + TotalAmount StarAmount + // The amount of Telegram Stars that aren't withdrawn yet + CurrentAmount StarAmount + // The amount of Telegram Stars that are available for withdrawal + AvailableAmount StarAmount // True, if Telegram Stars can be withdrawn now or later WithdrawalEnabled bool // Time left before the next withdrawal can be started, in seconds; 0 if withdrawal can @@ -47,7 +47,7 @@ type StarRevenueStatus struct { } // StarRevenueStatusTypeID is TL type id of StarRevenueStatus. -const StarRevenueStatusTypeID = 0xe85bd5fb +const StarRevenueStatusTypeID = 0x779532e8 // Ensuring interfaces in compile-time for StarRevenueStatus. var ( @@ -61,13 +61,13 @@ func (s *StarRevenueStatus) Zero() bool { if s == nil { return true } - if !(s.TotalCount == 0) { + if !(s.TotalAmount.Zero()) { return false } - if !(s.CurrentCount == 0) { + if !(s.CurrentAmount.Zero()) { return false } - if !(s.AvailableCount == 0) { + if !(s.AvailableAmount.Zero()) { return false } if !(s.WithdrawalEnabled == false) { @@ -113,16 +113,16 @@ func (s *StarRevenueStatus) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "TotalCount", - SchemaName: "total_count", + Name: "TotalAmount", + SchemaName: "total_amount", }, { - Name: "CurrentCount", - SchemaName: "current_count", + Name: "CurrentAmount", + SchemaName: "current_amount", }, { - Name: "AvailableCount", - SchemaName: "available_count", + Name: "AvailableAmount", + SchemaName: "available_amount", }, { Name: "WithdrawalEnabled", @@ -139,7 +139,7 @@ func (s *StarRevenueStatus) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *StarRevenueStatus) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starRevenueStatus#e85bd5fb as nil") + return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil") } b.PutID(StarRevenueStatusTypeID) return s.EncodeBare(b) @@ -148,11 +148,17 @@ func (s *StarRevenueStatus) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarRevenueStatus) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starRevenueStatus#e85bd5fb as nil") + return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil") + } + if err := s.TotalAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field total_amount: %w", err) + } + if err := s.CurrentAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field current_amount: %w", err) + } + if err := s.AvailableAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field available_amount: %w", err) } - b.PutInt53(s.TotalCount) - b.PutInt53(s.CurrentCount) - b.PutInt53(s.AvailableCount) b.PutBool(s.WithdrawalEnabled) b.PutInt32(s.NextWithdrawalIn) return nil @@ -161,10 +167,10 @@ func (s *StarRevenueStatus) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StarRevenueStatus) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starRevenueStatus#e85bd5fb to nil") + return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil") } if err := b.ConsumeID(StarRevenueStatusTypeID); err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: %w", err) } return s.DecodeBare(b) } @@ -172,40 +178,34 @@ func (s *StarRevenueStatus) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarRevenueStatus) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starRevenueStatus#e85bd5fb to nil") + return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil") } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field total_count: %w", err) + if err := s.TotalAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field total_amount: %w", err) } - s.TotalCount = value } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field current_count: %w", err) + if err := s.CurrentAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field current_amount: %w", err) } - s.CurrentCount = value } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field available_count: %w", err) + if err := s.AvailableAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field available_amount: %w", err) } - s.AvailableCount = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field withdrawal_enabled: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field withdrawal_enabled: %w", err) } s.WithdrawalEnabled = value } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field next_withdrawal_in: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field next_withdrawal_in: %w", err) } s.NextWithdrawalIn = value } @@ -215,19 +215,25 @@ func (s *StarRevenueStatus) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StarRevenueStatus) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode starRevenueStatus#e85bd5fb as nil") + return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil") } b.ObjStart() b.PutID("starRevenueStatus") b.Comma() - b.FieldStart("total_count") - b.PutInt53(s.TotalCount) + b.FieldStart("total_amount") + if err := s.TotalAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field total_amount: %w", err) + } b.Comma() - b.FieldStart("current_count") - b.PutInt53(s.CurrentCount) + b.FieldStart("current_amount") + if err := s.CurrentAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field current_amount: %w", err) + } b.Comma() - b.FieldStart("available_count") - b.PutInt53(s.AvailableCount) + b.FieldStart("available_amount") + if err := s.AvailableAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field available_amount: %w", err) + } b.Comma() b.FieldStart("withdrawal_enabled") b.PutBool(s.WithdrawalEnabled) @@ -243,43 +249,37 @@ func (s *StarRevenueStatus) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StarRevenueStatus) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode starRevenueStatus#e85bd5fb to nil") + return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("starRevenueStatus"); err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: %w", err) } - case "total_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field total_count: %w", err) + case "total_amount": + if err := s.TotalAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field total_amount: %w", err) } - s.TotalCount = value - case "current_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field current_count: %w", err) + case "current_amount": + if err := s.CurrentAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field current_amount: %w", err) } - s.CurrentCount = value - case "available_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field available_count: %w", err) + case "available_amount": + if err := s.AvailableAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field available_amount: %w", err) } - s.AvailableCount = value case "withdrawal_enabled": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field withdrawal_enabled: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field withdrawal_enabled: %w", err) } s.WithdrawalEnabled = value case "next_withdrawal_in": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode starRevenueStatus#e85bd5fb: field next_withdrawal_in: %w", err) + return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field next_withdrawal_in: %w", err) } s.NextWithdrawalIn = value default: @@ -289,28 +289,28 @@ func (s *StarRevenueStatus) DecodeTDLibJSON(b tdjson.Decoder) error { }) } -// GetTotalCount returns value of TotalCount field. -func (s *StarRevenueStatus) GetTotalCount() (value int64) { +// GetTotalAmount returns value of TotalAmount field. +func (s *StarRevenueStatus) GetTotalAmount() (value StarAmount) { if s == nil { return } - return s.TotalCount + return s.TotalAmount } -// GetCurrentCount returns value of CurrentCount field. -func (s *StarRevenueStatus) GetCurrentCount() (value int64) { +// GetCurrentAmount returns value of CurrentAmount field. +func (s *StarRevenueStatus) GetCurrentAmount() (value StarAmount) { if s == nil { return } - return s.CurrentCount + return s.CurrentAmount } -// GetAvailableCount returns value of AvailableCount field. -func (s *StarRevenueStatus) GetAvailableCount() (value int64) { +// GetAvailableAmount returns value of AvailableAmount field. +func (s *StarRevenueStatus) GetAvailableAmount() (value StarAmount) { if s == nil { return } - return s.AvailableCount + return s.AvailableAmount } // GetWithdrawalEnabled returns value of WithdrawalEnabled field. diff --git a/tdapi/tl_star_subscriptions_gen.go b/tdapi/tl_star_subscriptions_gen.go index 3c0cb64a13..f557156198 100644 --- a/tdapi/tl_star_subscriptions_gen.go +++ b/tdapi/tl_star_subscriptions_gen.go @@ -31,10 +31,10 @@ var ( _ = tdjson.Encoder{} ) -// StarSubscriptions represents TL type `starSubscriptions#f7a7ae44`. +// StarSubscriptions represents TL type `starSubscriptions#a2f27c8d`. type StarSubscriptions struct { // The amount of owned Telegram Stars - StarCount int64 + StarAmount StarAmount // List of subscriptions for Telegram Stars Subscriptions []StarSubscription // The number of Telegram Stars required to buy to extend subscriptions expiring soon @@ -44,7 +44,7 @@ type StarSubscriptions struct { } // StarSubscriptionsTypeID is TL type id of StarSubscriptions. -const StarSubscriptionsTypeID = 0xf7a7ae44 +const StarSubscriptionsTypeID = 0xa2f27c8d // Ensuring interfaces in compile-time for StarSubscriptions. var ( @@ -58,7 +58,7 @@ func (s *StarSubscriptions) Zero() bool { if s == nil { return true } - if !(s.StarCount == 0) { + if !(s.StarAmount.Zero()) { return false } if !(s.Subscriptions == nil) { @@ -107,8 +107,8 @@ func (s *StarSubscriptions) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "StarCount", - SchemaName: "star_count", + Name: "StarAmount", + SchemaName: "star_amount", }, { Name: "Subscriptions", @@ -129,7 +129,7 @@ func (s *StarSubscriptions) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *StarSubscriptions) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starSubscriptions#f7a7ae44 as nil") + return fmt.Errorf("can't encode starSubscriptions#a2f27c8d as nil") } b.PutID(StarSubscriptionsTypeID) return s.EncodeBare(b) @@ -138,13 +138,15 @@ func (s *StarSubscriptions) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarSubscriptions) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starSubscriptions#f7a7ae44 as nil") + return fmt.Errorf("can't encode starSubscriptions#a2f27c8d as nil") + } + if err := s.StarAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starSubscriptions#a2f27c8d: field star_amount: %w", err) } - b.PutInt53(s.StarCount) b.PutInt(len(s.Subscriptions)) for idx, v := range s.Subscriptions { if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare starSubscriptions#f7a7ae44: field subscriptions element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode bare starSubscriptions#a2f27c8d: field subscriptions element with index %d: %w", idx, err) } } b.PutInt53(s.RequiredStarCount) @@ -155,10 +157,10 @@ func (s *StarSubscriptions) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StarSubscriptions) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starSubscriptions#f7a7ae44 to nil") + return fmt.Errorf("can't decode starSubscriptions#a2f27c8d to nil") } if err := b.ConsumeID(StarSubscriptionsTypeID); err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: %w", err) } return s.DecodeBare(b) } @@ -166,19 +168,17 @@ func (s *StarSubscriptions) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarSubscriptions) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starSubscriptions#f7a7ae44 to nil") + return fmt.Errorf("can't decode starSubscriptions#a2f27c8d to nil") } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field star_count: %w", err) + if err := s.StarAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field star_amount: %w", err) } - s.StarCount = value } { headerLen, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field subscriptions: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field subscriptions: %w", err) } if headerLen > 0 { @@ -187,7 +187,7 @@ func (s *StarSubscriptions) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StarSubscription if err := value.DecodeBare(b); err != nil { - return fmt.Errorf("unable to decode bare starSubscriptions#f7a7ae44: field subscriptions: %w", err) + return fmt.Errorf("unable to decode bare starSubscriptions#a2f27c8d: field subscriptions: %w", err) } s.Subscriptions = append(s.Subscriptions, value) } @@ -195,14 +195,14 @@ func (s *StarSubscriptions) DecodeBare(b *bin.Buffer) error { { value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field required_star_count: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field required_star_count: %w", err) } s.RequiredStarCount = value } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field next_offset: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field next_offset: %w", err) } s.NextOffset = value } @@ -212,19 +212,21 @@ func (s *StarSubscriptions) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StarSubscriptions) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode starSubscriptions#f7a7ae44 as nil") + return fmt.Errorf("can't encode starSubscriptions#a2f27c8d as nil") } b.ObjStart() b.PutID("starSubscriptions") b.Comma() - b.FieldStart("star_count") - b.PutInt53(s.StarCount) + b.FieldStart("star_amount") + if err := s.StarAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starSubscriptions#a2f27c8d: field star_amount: %w", err) + } b.Comma() b.FieldStart("subscriptions") b.ArrStart() for idx, v := range s.Subscriptions { if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starSubscriptions#f7a7ae44: field subscriptions element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode starSubscriptions#a2f27c8d: field subscriptions element with index %d: %w", idx, err) } b.Comma() } @@ -245,42 +247,40 @@ func (s *StarSubscriptions) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StarSubscriptions) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode starSubscriptions#f7a7ae44 to nil") + return fmt.Errorf("can't decode starSubscriptions#a2f27c8d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("starSubscriptions"); err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: %w", err) } - case "star_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field star_count: %w", err) + case "star_amount": + if err := s.StarAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field star_amount: %w", err) } - s.StarCount = value case "subscriptions": if err := b.Arr(func(b tdjson.Decoder) error { var value StarSubscription if err := value.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field subscriptions: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field subscriptions: %w", err) } s.Subscriptions = append(s.Subscriptions, value) return nil }); err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field subscriptions: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field subscriptions: %w", err) } case "required_star_count": value, err := b.Int53() if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field required_star_count: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field required_star_count: %w", err) } s.RequiredStarCount = value case "next_offset": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starSubscriptions#f7a7ae44: field next_offset: %w", err) + return fmt.Errorf("unable to decode starSubscriptions#a2f27c8d: field next_offset: %w", err) } s.NextOffset = value default: @@ -290,12 +290,12 @@ func (s *StarSubscriptions) DecodeTDLibJSON(b tdjson.Decoder) error { }) } -// GetStarCount returns value of StarCount field. -func (s *StarSubscriptions) GetStarCount() (value int64) { +// GetStarAmount returns value of StarAmount field. +func (s *StarSubscriptions) GetStarAmount() (value StarAmount) { if s == nil { return } - return s.StarCount + return s.StarAmount } // GetSubscriptions returns value of Subscriptions field. diff --git a/tdapi/tl_star_transaction_gen.go b/tdapi/tl_star_transaction_gen.go index b6302edc12..bcba514ff8 100644 --- a/tdapi/tl_star_transaction_gen.go +++ b/tdapi/tl_star_transaction_gen.go @@ -31,22 +31,22 @@ var ( _ = tdjson.Encoder{} ) -// StarTransaction represents TL type `starTransaction#ce1084a8`. +// StarTransaction represents TL type `starTransaction#7f820a90`. type StarTransaction struct { // Unique identifier of the transaction ID string // The amount of added owned Telegram Stars; negative for outgoing transactions - StarCount int64 + StarAmount StarAmount // True, if the transaction is a refund of a previous transaction IsRefund bool // Point in time (Unix timestamp) when the transaction was completed Date int32 - // Source of the incoming transaction, or its recipient for outgoing transactions - Partner StarTransactionPartnerClass + // Type of the transaction + Type StarTransactionTypeClass } // StarTransactionTypeID is TL type id of StarTransaction. -const StarTransactionTypeID = 0xce1084a8 +const StarTransactionTypeID = 0x7f820a90 // Ensuring interfaces in compile-time for StarTransaction. var ( @@ -63,7 +63,7 @@ func (s *StarTransaction) Zero() bool { if !(s.ID == "") { return false } - if !(s.StarCount == 0) { + if !(s.StarAmount.Zero()) { return false } if !(s.IsRefund == false) { @@ -72,7 +72,7 @@ func (s *StarTransaction) Zero() bool { if !(s.Date == 0) { return false } - if !(s.Partner == nil) { + if !(s.Type == nil) { return false } @@ -116,8 +116,8 @@ func (s *StarTransaction) TypeInfo() tdp.Type { SchemaName: "id", }, { - Name: "StarCount", - SchemaName: "star_count", + Name: "StarAmount", + SchemaName: "star_amount", }, { Name: "IsRefund", @@ -128,8 +128,8 @@ func (s *StarTransaction) TypeInfo() tdp.Type { SchemaName: "date", }, { - Name: "Partner", - SchemaName: "partner", + Name: "Type", + SchemaName: "type", }, } return typ @@ -138,7 +138,7 @@ func (s *StarTransaction) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *StarTransaction) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starTransaction#ce1084a8 as nil") + return fmt.Errorf("can't encode starTransaction#7f820a90 as nil") } b.PutID(StarTransactionTypeID) return s.EncodeBare(b) @@ -147,17 +147,19 @@ func (s *StarTransaction) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarTransaction) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starTransaction#ce1084a8 as nil") + return fmt.Errorf("can't encode starTransaction#7f820a90 as nil") } b.PutString(s.ID) - b.PutInt53(s.StarCount) + if err := s.StarAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field star_amount: %w", err) + } b.PutBool(s.IsRefund) b.PutInt32(s.Date) - if s.Partner == nil { - return fmt.Errorf("unable to encode starTransaction#ce1084a8: field partner is nil") + if s.Type == nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field type is nil") } - if err := s.Partner.Encode(b); err != nil { - return fmt.Errorf("unable to encode starTransaction#ce1084a8: field partner: %w", err) + if err := s.Type.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field type: %w", err) } return nil } @@ -165,10 +167,10 @@ func (s *StarTransaction) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StarTransaction) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starTransaction#ce1084a8 to nil") + return fmt.Errorf("can't decode starTransaction#7f820a90 to nil") } if err := b.ConsumeID(StarTransactionTypeID); err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: %w", err) } return s.DecodeBare(b) } @@ -176,42 +178,40 @@ func (s *StarTransaction) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarTransaction) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starTransaction#ce1084a8 to nil") + return fmt.Errorf("can't decode starTransaction#7f820a90 to nil") } { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field id: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field id: %w", err) } s.ID = value } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field star_count: %w", err) + if err := s.StarAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransaction#7f820a90: field star_amount: %w", err) } - s.StarCount = value } { value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field is_refund: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field is_refund: %w", err) } s.IsRefund = value } { value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field date: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field date: %w", err) } s.Date = value } { - value, err := DecodeStarTransactionPartner(b) + value, err := DecodeStarTransactionType(b) if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field partner: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field type: %w", err) } - s.Partner = value + s.Type = value } return nil } @@ -219,7 +219,7 @@ func (s *StarTransaction) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StarTransaction) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode starTransaction#ce1084a8 as nil") + return fmt.Errorf("can't encode starTransaction#7f820a90 as nil") } b.ObjStart() b.PutID("starTransaction") @@ -227,8 +227,10 @@ func (s *StarTransaction) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("id") b.PutString(s.ID) b.Comma() - b.FieldStart("star_count") - b.PutInt53(s.StarCount) + b.FieldStart("star_amount") + if err := s.StarAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field star_amount: %w", err) + } b.Comma() b.FieldStart("is_refund") b.PutBool(s.IsRefund) @@ -236,12 +238,12 @@ func (s *StarTransaction) EncodeTDLibJSON(b tdjson.Encoder) error { b.FieldStart("date") b.PutInt32(s.Date) b.Comma() - b.FieldStart("partner") - if s.Partner == nil { - return fmt.Errorf("unable to encode starTransaction#ce1084a8: field partner is nil") + b.FieldStart("type") + if s.Type == nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field type is nil") } - if err := s.Partner.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransaction#ce1084a8: field partner: %w", err) + if err := s.Type.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransaction#7f820a90: field type: %w", err) } b.Comma() b.StripComma() @@ -252,45 +254,43 @@ func (s *StarTransaction) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StarTransaction) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode starTransaction#ce1084a8 to nil") + return fmt.Errorf("can't decode starTransaction#7f820a90 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("starTransaction"); err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: %w", err) } case "id": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field id: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field id: %w", err) } s.ID = value - case "star_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field star_count: %w", err) + case "star_amount": + if err := s.StarAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransaction#7f820a90: field star_amount: %w", err) } - s.StarCount = value case "is_refund": value, err := b.Bool() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field is_refund: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field is_refund: %w", err) } s.IsRefund = value case "date": value, err := b.Int32() if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field date: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field date: %w", err) } s.Date = value - case "partner": - value, err := DecodeTDLibJSONStarTransactionPartner(b) + case "type": + value, err := DecodeTDLibJSONStarTransactionType(b) if err != nil { - return fmt.Errorf("unable to decode starTransaction#ce1084a8: field partner: %w", err) + return fmt.Errorf("unable to decode starTransaction#7f820a90: field type: %w", err) } - s.Partner = value + s.Type = value default: return b.Skip() } @@ -306,12 +306,12 @@ func (s *StarTransaction) GetID() (value string) { return s.ID } -// GetStarCount returns value of StarCount field. -func (s *StarTransaction) GetStarCount() (value int64) { +// GetStarAmount returns value of StarAmount field. +func (s *StarTransaction) GetStarAmount() (value StarAmount) { if s == nil { return } - return s.StarCount + return s.StarAmount } // GetIsRefund returns value of IsRefund field. @@ -330,10 +330,10 @@ func (s *StarTransaction) GetDate() (value int32) { return s.Date } -// GetPartner returns value of Partner field. -func (s *StarTransaction) GetPartner() (value StarTransactionPartnerClass) { +// GetType returns value of Type field. +func (s *StarTransaction) GetType() (value StarTransactionTypeClass) { if s == nil { return } - return s.Partner + return s.Type } diff --git a/tdapi/tl_star_transaction_partner_gen.go b/tdapi/tl_star_transaction_partner_gen.go deleted file mode 100644 index bbfeca96a4..0000000000 --- a/tdapi/tl_star_transaction_partner_gen.go +++ /dev/null @@ -1,2166 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tdapi - -import ( - "context" - "errors" - "fmt" - "sort" - "strings" - - "go.uber.org/multierr" - - "github.com/gotd/td/bin" - "github.com/gotd/td/tdjson" - "github.com/gotd/td/tdp" - "github.com/gotd/td/tgerr" -) - -// No-op definition for keeping imports. -var ( - _ = bin.Buffer{} - _ = context.Background() - _ = fmt.Stringer(nil) - _ = strings.Builder{} - _ = errors.Is - _ = multierr.AppendInto - _ = sort.Ints - _ = tdp.Format - _ = tgerr.Error{} - _ = tdjson.Encoder{} -) - -// StarTransactionPartnerTelegram represents TL type `starTransactionPartnerTelegram#7a899cc0`. -type StarTransactionPartnerTelegram struct { -} - -// StarTransactionPartnerTelegramTypeID is TL type id of StarTransactionPartnerTelegram. -const StarTransactionPartnerTelegramTypeID = 0x7a899cc0 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerTelegram) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerTelegram. -var ( - _ bin.Encoder = &StarTransactionPartnerTelegram{} - _ bin.Decoder = &StarTransactionPartnerTelegram{} - _ bin.BareEncoder = &StarTransactionPartnerTelegram{} - _ bin.BareDecoder = &StarTransactionPartnerTelegram{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerTelegram{} -) - -func (s *StarTransactionPartnerTelegram) Zero() bool { - if s == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerTelegram) String() string { - if s == nil { - return "StarTransactionPartnerTelegram(nil)" - } - type Alias StarTransactionPartnerTelegram - return fmt.Sprintf("StarTransactionPartnerTelegram%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerTelegram) TypeID() uint32 { - return StarTransactionPartnerTelegramTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerTelegram) TypeName() string { - return "starTransactionPartnerTelegram" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerTelegram) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerTelegram", - ID: StarTransactionPartnerTelegramTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerTelegram) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegram#7a899cc0 as nil") - } - b.PutID(StarTransactionPartnerTelegramTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerTelegram) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegram#7a899cc0 as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerTelegram) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegram#7a899cc0 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerTelegramTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegram#7a899cc0: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerTelegram) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegram#7a899cc0 to nil") - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerTelegram) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegram#7a899cc0 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerTelegram") - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerTelegram) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegram#7a899cc0 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerTelegram"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegram#7a899cc0: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// StarTransactionPartnerAppStore represents TL type `starTransactionPartnerAppStore#e34026dc`. -type StarTransactionPartnerAppStore struct { -} - -// StarTransactionPartnerAppStoreTypeID is TL type id of StarTransactionPartnerAppStore. -const StarTransactionPartnerAppStoreTypeID = 0xe34026dc - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerAppStore) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerAppStore. -var ( - _ bin.Encoder = &StarTransactionPartnerAppStore{} - _ bin.Decoder = &StarTransactionPartnerAppStore{} - _ bin.BareEncoder = &StarTransactionPartnerAppStore{} - _ bin.BareDecoder = &StarTransactionPartnerAppStore{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerAppStore{} -) - -func (s *StarTransactionPartnerAppStore) Zero() bool { - if s == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerAppStore) String() string { - if s == nil { - return "StarTransactionPartnerAppStore(nil)" - } - type Alias StarTransactionPartnerAppStore - return fmt.Sprintf("StarTransactionPartnerAppStore%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerAppStore) TypeID() uint32 { - return StarTransactionPartnerAppStoreTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerAppStore) TypeName() string { - return "starTransactionPartnerAppStore" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerAppStore) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerAppStore", - ID: StarTransactionPartnerAppStoreTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerAppStore) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerAppStore#e34026dc as nil") - } - b.PutID(StarTransactionPartnerAppStoreTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerAppStore) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerAppStore#e34026dc as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerAppStore) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerAppStore#e34026dc to nil") - } - if err := b.ConsumeID(StarTransactionPartnerAppStoreTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerAppStore#e34026dc: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerAppStore) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerAppStore#e34026dc to nil") - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerAppStore) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerAppStore#e34026dc as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerAppStore") - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerAppStore) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerAppStore#e34026dc to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerAppStore"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerAppStore#e34026dc: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// StarTransactionPartnerGooglePlay represents TL type `starTransactionPartnerGooglePlay#f229f2a0`. -type StarTransactionPartnerGooglePlay struct { -} - -// StarTransactionPartnerGooglePlayTypeID is TL type id of StarTransactionPartnerGooglePlay. -const StarTransactionPartnerGooglePlayTypeID = 0xf229f2a0 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerGooglePlay) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerGooglePlay. -var ( - _ bin.Encoder = &StarTransactionPartnerGooglePlay{} - _ bin.Decoder = &StarTransactionPartnerGooglePlay{} - _ bin.BareEncoder = &StarTransactionPartnerGooglePlay{} - _ bin.BareDecoder = &StarTransactionPartnerGooglePlay{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerGooglePlay{} -) - -func (s *StarTransactionPartnerGooglePlay) Zero() bool { - if s == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerGooglePlay) String() string { - if s == nil { - return "StarTransactionPartnerGooglePlay(nil)" - } - type Alias StarTransactionPartnerGooglePlay - return fmt.Sprintf("StarTransactionPartnerGooglePlay%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerGooglePlay) TypeID() uint32 { - return StarTransactionPartnerGooglePlayTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerGooglePlay) TypeName() string { - return "starTransactionPartnerGooglePlay" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerGooglePlay) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerGooglePlay", - ID: StarTransactionPartnerGooglePlayTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerGooglePlay) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerGooglePlay#f229f2a0 as nil") - } - b.PutID(StarTransactionPartnerGooglePlayTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerGooglePlay) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerGooglePlay#f229f2a0 as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerGooglePlay) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerGooglePlay#f229f2a0 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerGooglePlayTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerGooglePlay#f229f2a0: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerGooglePlay) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerGooglePlay#f229f2a0 to nil") - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerGooglePlay) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerGooglePlay#f229f2a0 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerGooglePlay") - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerGooglePlay) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerGooglePlay#f229f2a0 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerGooglePlay"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerGooglePlay#f229f2a0: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// StarTransactionPartnerFragment represents TL type `starTransactionPartnerFragment#da1849b5`. -type StarTransactionPartnerFragment struct { - // State of the withdrawal; may be null for refunds from Fragment or for Telegram Stars - // bought on Fragment - WithdrawalState RevenueWithdrawalStateClass -} - -// StarTransactionPartnerFragmentTypeID is TL type id of StarTransactionPartnerFragment. -const StarTransactionPartnerFragmentTypeID = 0xda1849b5 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerFragment) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerFragment. -var ( - _ bin.Encoder = &StarTransactionPartnerFragment{} - _ bin.Decoder = &StarTransactionPartnerFragment{} - _ bin.BareEncoder = &StarTransactionPartnerFragment{} - _ bin.BareDecoder = &StarTransactionPartnerFragment{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerFragment{} -) - -func (s *StarTransactionPartnerFragment) Zero() bool { - if s == nil { - return true - } - if !(s.WithdrawalState == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerFragment) String() string { - if s == nil { - return "StarTransactionPartnerFragment(nil)" - } - type Alias StarTransactionPartnerFragment - return fmt.Sprintf("StarTransactionPartnerFragment%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerFragment) TypeID() uint32 { - return StarTransactionPartnerFragmentTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerFragment) TypeName() string { - return "starTransactionPartnerFragment" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerFragment) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerFragment", - ID: StarTransactionPartnerFragmentTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "WithdrawalState", - SchemaName: "withdrawal_state", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerFragment) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerFragment#da1849b5 as nil") - } - b.PutID(StarTransactionPartnerFragmentTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerFragment) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerFragment#da1849b5 as nil") - } - if s.WithdrawalState == nil { - return fmt.Errorf("unable to encode starTransactionPartnerFragment#da1849b5: field withdrawal_state is nil") - } - if err := s.WithdrawalState.Encode(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerFragment#da1849b5: field withdrawal_state: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerFragment) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerFragment#da1849b5 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerFragmentTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerFragment#da1849b5: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerFragment) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerFragment#da1849b5 to nil") - } - { - value, err := DecodeRevenueWithdrawalState(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerFragment#da1849b5: field withdrawal_state: %w", err) - } - s.WithdrawalState = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerFragment) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerFragment#da1849b5 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerFragment") - b.Comma() - b.FieldStart("withdrawal_state") - if s.WithdrawalState == nil { - return fmt.Errorf("unable to encode starTransactionPartnerFragment#da1849b5: field withdrawal_state is nil") - } - if err := s.WithdrawalState.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerFragment#da1849b5: field withdrawal_state: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerFragment) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerFragment#da1849b5 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerFragment"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerFragment#da1849b5: %w", err) - } - case "withdrawal_state": - value, err := DecodeTDLibJSONRevenueWithdrawalState(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerFragment#da1849b5: field withdrawal_state: %w", err) - } - s.WithdrawalState = value - default: - return b.Skip() - } - return nil - }) -} - -// GetWithdrawalState returns value of WithdrawalState field. -func (s *StarTransactionPartnerFragment) GetWithdrawalState() (value RevenueWithdrawalStateClass) { - if s == nil { - return - } - return s.WithdrawalState -} - -// StarTransactionPartnerTelegramAds represents TL type `starTransactionPartnerTelegramAds#91f9c6b`. -type StarTransactionPartnerTelegramAds struct { -} - -// StarTransactionPartnerTelegramAdsTypeID is TL type id of StarTransactionPartnerTelegramAds. -const StarTransactionPartnerTelegramAdsTypeID = 0x91f9c6b - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerTelegramAds) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerTelegramAds. -var ( - _ bin.Encoder = &StarTransactionPartnerTelegramAds{} - _ bin.Decoder = &StarTransactionPartnerTelegramAds{} - _ bin.BareEncoder = &StarTransactionPartnerTelegramAds{} - _ bin.BareDecoder = &StarTransactionPartnerTelegramAds{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerTelegramAds{} -) - -func (s *StarTransactionPartnerTelegramAds) Zero() bool { - if s == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerTelegramAds) String() string { - if s == nil { - return "StarTransactionPartnerTelegramAds(nil)" - } - type Alias StarTransactionPartnerTelegramAds - return fmt.Sprintf("StarTransactionPartnerTelegramAds%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerTelegramAds) TypeID() uint32 { - return StarTransactionPartnerTelegramAdsTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerTelegramAds) TypeName() string { - return "starTransactionPartnerTelegramAds" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerTelegramAds) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerTelegramAds", - ID: StarTransactionPartnerTelegramAdsTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerTelegramAds) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramAds#91f9c6b as nil") - } - b.PutID(StarTransactionPartnerTelegramAdsTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerTelegramAds) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramAds#91f9c6b as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerTelegramAds) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramAds#91f9c6b to nil") - } - if err := b.ConsumeID(StarTransactionPartnerTelegramAdsTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramAds#91f9c6b: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerTelegramAds) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramAds#91f9c6b to nil") - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerTelegramAds) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramAds#91f9c6b as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerTelegramAds") - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerTelegramAds) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramAds#91f9c6b to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerTelegramAds"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramAds#91f9c6b: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// StarTransactionPartnerTelegramAPI represents TL type `starTransactionPartnerTelegramApi#543cc9fd`. -type StarTransactionPartnerTelegramAPI struct { - // The number of billed requests - RequestCount int32 -} - -// StarTransactionPartnerTelegramAPITypeID is TL type id of StarTransactionPartnerTelegramAPI. -const StarTransactionPartnerTelegramAPITypeID = 0x543cc9fd - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerTelegramAPI) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerTelegramAPI. -var ( - _ bin.Encoder = &StarTransactionPartnerTelegramAPI{} - _ bin.Decoder = &StarTransactionPartnerTelegramAPI{} - _ bin.BareEncoder = &StarTransactionPartnerTelegramAPI{} - _ bin.BareDecoder = &StarTransactionPartnerTelegramAPI{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerTelegramAPI{} -) - -func (s *StarTransactionPartnerTelegramAPI) Zero() bool { - if s == nil { - return true - } - if !(s.RequestCount == 0) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerTelegramAPI) String() string { - if s == nil { - return "StarTransactionPartnerTelegramAPI(nil)" - } - type Alias StarTransactionPartnerTelegramAPI - return fmt.Sprintf("StarTransactionPartnerTelegramAPI%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerTelegramAPI) TypeID() uint32 { - return StarTransactionPartnerTelegramAPITypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerTelegramAPI) TypeName() string { - return "starTransactionPartnerTelegramApi" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerTelegramAPI) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerTelegramApi", - ID: StarTransactionPartnerTelegramAPITypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "RequestCount", - SchemaName: "request_count", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerTelegramAPI) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramApi#543cc9fd as nil") - } - b.PutID(StarTransactionPartnerTelegramAPITypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerTelegramAPI) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramApi#543cc9fd as nil") - } - b.PutInt32(s.RequestCount) - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerTelegramAPI) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramApi#543cc9fd to nil") - } - if err := b.ConsumeID(StarTransactionPartnerTelegramAPITypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramApi#543cc9fd: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerTelegramAPI) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramApi#543cc9fd to nil") - } - { - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramApi#543cc9fd: field request_count: %w", err) - } - s.RequestCount = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerTelegramAPI) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerTelegramApi#543cc9fd as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerTelegramApi") - b.Comma() - b.FieldStart("request_count") - b.PutInt32(s.RequestCount) - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerTelegramAPI) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerTelegramApi#543cc9fd to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerTelegramApi"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramApi#543cc9fd: %w", err) - } - case "request_count": - value, err := b.Int32() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerTelegramApi#543cc9fd: field request_count: %w", err) - } - s.RequestCount = value - default: - return b.Skip() - } - return nil - }) -} - -// GetRequestCount returns value of RequestCount field. -func (s *StarTransactionPartnerTelegramAPI) GetRequestCount() (value int32) { - if s == nil { - return - } - return s.RequestCount -} - -// StarTransactionPartnerBot represents TL type `starTransactionPartnerBot#4ece3a40`. -type StarTransactionPartnerBot struct { - // Identifier of the bot - UserID int64 - // Purpose of the transaction - Purpose BotTransactionPurposeClass -} - -// StarTransactionPartnerBotTypeID is TL type id of StarTransactionPartnerBot. -const StarTransactionPartnerBotTypeID = 0x4ece3a40 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerBot) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerBot. -var ( - _ bin.Encoder = &StarTransactionPartnerBot{} - _ bin.Decoder = &StarTransactionPartnerBot{} - _ bin.BareEncoder = &StarTransactionPartnerBot{} - _ bin.BareDecoder = &StarTransactionPartnerBot{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerBot{} -) - -func (s *StarTransactionPartnerBot) Zero() bool { - if s == nil { - return true - } - if !(s.UserID == 0) { - return false - } - if !(s.Purpose == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerBot) String() string { - if s == nil { - return "StarTransactionPartnerBot(nil)" - } - type Alias StarTransactionPartnerBot - return fmt.Sprintf("StarTransactionPartnerBot%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerBot) TypeID() uint32 { - return StarTransactionPartnerBotTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerBot) TypeName() string { - return "starTransactionPartnerBot" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerBot) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerBot", - ID: StarTransactionPartnerBotTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Purpose", - SchemaName: "purpose", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerBot) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBot#4ece3a40 as nil") - } - b.PutID(StarTransactionPartnerBotTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerBot) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBot#4ece3a40 as nil") - } - b.PutInt53(s.UserID) - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerBot#4ece3a40: field purpose is nil") - } - if err := s.Purpose.Encode(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerBot#4ece3a40: field purpose: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerBot) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBot#4ece3a40 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerBotTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerBot) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBot#4ece3a40 to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: field user_id: %w", err) - } - s.UserID = value - } - { - value, err := DecodeBotTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: field purpose: %w", err) - } - s.Purpose = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerBot) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBot#4ece3a40 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerBot") - b.Comma() - b.FieldStart("user_id") - b.PutInt53(s.UserID) - b.Comma() - b.FieldStart("purpose") - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerBot#4ece3a40: field purpose is nil") - } - if err := s.Purpose.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerBot#4ece3a40: field purpose: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerBot) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBot#4ece3a40 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerBot"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: %w", err) - } - case "user_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: field user_id: %w", err) - } - s.UserID = value - case "purpose": - value, err := DecodeTDLibJSONBotTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBot#4ece3a40: field purpose: %w", err) - } - s.Purpose = value - default: - return b.Skip() - } - return nil - }) -} - -// GetUserID returns value of UserID field. -func (s *StarTransactionPartnerBot) GetUserID() (value int64) { - if s == nil { - return - } - return s.UserID -} - -// GetPurpose returns value of Purpose field. -func (s *StarTransactionPartnerBot) GetPurpose() (value BotTransactionPurposeClass) { - if s == nil { - return - } - return s.Purpose -} - -// StarTransactionPartnerBusiness represents TL type `starTransactionPartnerBusiness#7af9fb52`. -type StarTransactionPartnerBusiness struct { - // Identifier of the business account user - UserID int64 - // The bought media if the transaction wasn't refunded - Media []PaidMediaClass -} - -// StarTransactionPartnerBusinessTypeID is TL type id of StarTransactionPartnerBusiness. -const StarTransactionPartnerBusinessTypeID = 0x7af9fb52 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerBusiness) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerBusiness. -var ( - _ bin.Encoder = &StarTransactionPartnerBusiness{} - _ bin.Decoder = &StarTransactionPartnerBusiness{} - _ bin.BareEncoder = &StarTransactionPartnerBusiness{} - _ bin.BareDecoder = &StarTransactionPartnerBusiness{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerBusiness{} -) - -func (s *StarTransactionPartnerBusiness) Zero() bool { - if s == nil { - return true - } - if !(s.UserID == 0) { - return false - } - if !(s.Media == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerBusiness) String() string { - if s == nil { - return "StarTransactionPartnerBusiness(nil)" - } - type Alias StarTransactionPartnerBusiness - return fmt.Sprintf("StarTransactionPartnerBusiness%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerBusiness) TypeID() uint32 { - return StarTransactionPartnerBusinessTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerBusiness) TypeName() string { - return "starTransactionPartnerBusiness" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerBusiness) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerBusiness", - ID: StarTransactionPartnerBusinessTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Media", - SchemaName: "media", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerBusiness) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBusiness#7af9fb52 as nil") - } - b.PutID(StarTransactionPartnerBusinessTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerBusiness) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBusiness#7af9fb52 as nil") - } - b.PutInt53(s.UserID) - b.PutInt(len(s.Media)) - for idx, v := range s.Media { - if v == nil { - return fmt.Errorf("unable to encode starTransactionPartnerBusiness#7af9fb52: field media element with index %d is nil", idx) - } - if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare starTransactionPartnerBusiness#7af9fb52: field media element with index %d: %w", idx, err) - } - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerBusiness) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBusiness#7af9fb52 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerBusinessTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerBusiness) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBusiness#7af9fb52 to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field user_id: %w", err) - } - s.UserID = value - } - { - headerLen, err := b.Int() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field media: %w", err) - } - - if headerLen > 0 { - s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) - } - for idx := 0; idx < headerLen; idx++ { - value, err := DecodePaidMedia(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field media: %w", err) - } - s.Media = append(s.Media, value) - } - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerBusiness) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerBusiness#7af9fb52 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerBusiness") - b.Comma() - b.FieldStart("user_id") - b.PutInt53(s.UserID) - b.Comma() - b.FieldStart("media") - b.ArrStart() - for idx, v := range s.Media { - if v == nil { - return fmt.Errorf("unable to encode starTransactionPartnerBusiness#7af9fb52: field media element with index %d is nil", idx) - } - if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerBusiness#7af9fb52: field media element with index %d: %w", idx, err) - } - b.Comma() - } - b.StripComma() - b.ArrEnd() - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerBusiness) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerBusiness#7af9fb52 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerBusiness"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: %w", err) - } - case "user_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field user_id: %w", err) - } - s.UserID = value - case "media": - if err := b.Arr(func(b tdjson.Decoder) error { - value, err := DecodeTDLibJSONPaidMedia(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field media: %w", err) - } - s.Media = append(s.Media, value) - return nil - }); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerBusiness#7af9fb52: field media: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// GetUserID returns value of UserID field. -func (s *StarTransactionPartnerBusiness) GetUserID() (value int64) { - if s == nil { - return - } - return s.UserID -} - -// GetMedia returns value of Media field. -func (s *StarTransactionPartnerBusiness) GetMedia() (value []PaidMediaClass) { - if s == nil { - return - } - return s.Media -} - -// StarTransactionPartnerChat represents TL type `starTransactionPartnerChat#71db4d40`. -type StarTransactionPartnerChat struct { - // Identifier of the chat - ChatID int64 - // Purpose of the transaction - Purpose ChatTransactionPurposeClass -} - -// StarTransactionPartnerChatTypeID is TL type id of StarTransactionPartnerChat. -const StarTransactionPartnerChatTypeID = 0x71db4d40 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerChat) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerChat. -var ( - _ bin.Encoder = &StarTransactionPartnerChat{} - _ bin.Decoder = &StarTransactionPartnerChat{} - _ bin.BareEncoder = &StarTransactionPartnerChat{} - _ bin.BareDecoder = &StarTransactionPartnerChat{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerChat{} -) - -func (s *StarTransactionPartnerChat) Zero() bool { - if s == nil { - return true - } - if !(s.ChatID == 0) { - return false - } - if !(s.Purpose == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerChat) String() string { - if s == nil { - return "StarTransactionPartnerChat(nil)" - } - type Alias StarTransactionPartnerChat - return fmt.Sprintf("StarTransactionPartnerChat%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerChat) TypeID() uint32 { - return StarTransactionPartnerChatTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerChat) TypeName() string { - return "starTransactionPartnerChat" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerChat) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerChat", - ID: StarTransactionPartnerChatTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "ChatID", - SchemaName: "chat_id", - }, - { - Name: "Purpose", - SchemaName: "purpose", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerChat) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerChat#71db4d40 as nil") - } - b.PutID(StarTransactionPartnerChatTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerChat) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerChat#71db4d40 as nil") - } - b.PutInt53(s.ChatID) - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerChat#71db4d40: field purpose is nil") - } - if err := s.Purpose.Encode(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerChat#71db4d40: field purpose: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerChat) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerChat#71db4d40 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerChatTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerChat) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerChat#71db4d40 to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: field chat_id: %w", err) - } - s.ChatID = value - } - { - value, err := DecodeChatTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: field purpose: %w", err) - } - s.Purpose = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerChat) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerChat#71db4d40 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerChat") - b.Comma() - b.FieldStart("chat_id") - b.PutInt53(s.ChatID) - b.Comma() - b.FieldStart("purpose") - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerChat#71db4d40: field purpose is nil") - } - if err := s.Purpose.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerChat#71db4d40: field purpose: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerChat) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerChat#71db4d40 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerChat"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: %w", err) - } - case "chat_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: field chat_id: %w", err) - } - s.ChatID = value - case "purpose": - value, err := DecodeTDLibJSONChatTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerChat#71db4d40: field purpose: %w", err) - } - s.Purpose = value - default: - return b.Skip() - } - return nil - }) -} - -// GetChatID returns value of ChatID field. -func (s *StarTransactionPartnerChat) GetChatID() (value int64) { - if s == nil { - return - } - return s.ChatID -} - -// GetPurpose returns value of Purpose field. -func (s *StarTransactionPartnerChat) GetPurpose() (value ChatTransactionPurposeClass) { - if s == nil { - return - } - return s.Purpose -} - -// StarTransactionPartnerUser represents TL type `starTransactionPartnerUser#6f4d43d1`. -type StarTransactionPartnerUser struct { - // Identifier of the user; 0 if the user was anonymous - UserID int64 - // Purpose of the transaction - Purpose UserTransactionPurposeClass -} - -// StarTransactionPartnerUserTypeID is TL type id of StarTransactionPartnerUser. -const StarTransactionPartnerUserTypeID = 0x6f4d43d1 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerUser) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerUser. -var ( - _ bin.Encoder = &StarTransactionPartnerUser{} - _ bin.Decoder = &StarTransactionPartnerUser{} - _ bin.BareEncoder = &StarTransactionPartnerUser{} - _ bin.BareDecoder = &StarTransactionPartnerUser{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerUser{} -) - -func (s *StarTransactionPartnerUser) Zero() bool { - if s == nil { - return true - } - if !(s.UserID == 0) { - return false - } - if !(s.Purpose == nil) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerUser) String() string { - if s == nil { - return "StarTransactionPartnerUser(nil)" - } - type Alias StarTransactionPartnerUser - return fmt.Sprintf("StarTransactionPartnerUser%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerUser) TypeID() uint32 { - return StarTransactionPartnerUserTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerUser) TypeName() string { - return "starTransactionPartnerUser" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerUser) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerUser", - ID: StarTransactionPartnerUserTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "UserID", - SchemaName: "user_id", - }, - { - Name: "Purpose", - SchemaName: "purpose", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerUser) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUser#6f4d43d1 as nil") - } - b.PutID(StarTransactionPartnerUserTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerUser) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUser#6f4d43d1 as nil") - } - b.PutInt53(s.UserID) - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerUser#6f4d43d1: field purpose is nil") - } - if err := s.Purpose.Encode(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerUser#6f4d43d1: field purpose: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerUser) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUser#6f4d43d1 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerUserTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerUser) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUser#6f4d43d1 to nil") - } - { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: field user_id: %w", err) - } - s.UserID = value - } - { - value, err := DecodeUserTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: field purpose: %w", err) - } - s.Purpose = value - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerUser) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUser#6f4d43d1 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerUser") - b.Comma() - b.FieldStart("user_id") - b.PutInt53(s.UserID) - b.Comma() - b.FieldStart("purpose") - if s.Purpose == nil { - return fmt.Errorf("unable to encode starTransactionPartnerUser#6f4d43d1: field purpose is nil") - } - if err := s.Purpose.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactionPartnerUser#6f4d43d1: field purpose: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerUser) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUser#6f4d43d1 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerUser"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: %w", err) - } - case "user_id": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: field user_id: %w", err) - } - s.UserID = value - case "purpose": - value, err := DecodeTDLibJSONUserTransactionPurpose(b) - if err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUser#6f4d43d1: field purpose: %w", err) - } - s.Purpose = value - default: - return b.Skip() - } - return nil - }) -} - -// GetUserID returns value of UserID field. -func (s *StarTransactionPartnerUser) GetUserID() (value int64) { - if s == nil { - return - } - return s.UserID -} - -// GetPurpose returns value of Purpose field. -func (s *StarTransactionPartnerUser) GetPurpose() (value UserTransactionPurposeClass) { - if s == nil { - return - } - return s.Purpose -} - -// StarTransactionPartnerUnsupported represents TL type `starTransactionPartnerUnsupported#c4b20d73`. -type StarTransactionPartnerUnsupported struct { -} - -// StarTransactionPartnerUnsupportedTypeID is TL type id of StarTransactionPartnerUnsupported. -const StarTransactionPartnerUnsupportedTypeID = 0xc4b20d73 - -// construct implements constructor of StarTransactionPartnerClass. -func (s StarTransactionPartnerUnsupported) construct() StarTransactionPartnerClass { return &s } - -// Ensuring interfaces in compile-time for StarTransactionPartnerUnsupported. -var ( - _ bin.Encoder = &StarTransactionPartnerUnsupported{} - _ bin.Decoder = &StarTransactionPartnerUnsupported{} - _ bin.BareEncoder = &StarTransactionPartnerUnsupported{} - _ bin.BareDecoder = &StarTransactionPartnerUnsupported{} - - _ StarTransactionPartnerClass = &StarTransactionPartnerUnsupported{} -) - -func (s *StarTransactionPartnerUnsupported) Zero() bool { - if s == nil { - return true - } - - return true -} - -// String implements fmt.Stringer. -func (s *StarTransactionPartnerUnsupported) String() string { - if s == nil { - return "StarTransactionPartnerUnsupported(nil)" - } - type Alias StarTransactionPartnerUnsupported - return fmt.Sprintf("StarTransactionPartnerUnsupported%+v", Alias(*s)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*StarTransactionPartnerUnsupported) TypeID() uint32 { - return StarTransactionPartnerUnsupportedTypeID -} - -// TypeName returns name of type in TL schema. -func (*StarTransactionPartnerUnsupported) TypeName() string { - return "starTransactionPartnerUnsupported" -} - -// TypeInfo returns info about TL type. -func (s *StarTransactionPartnerUnsupported) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "starTransactionPartnerUnsupported", - ID: StarTransactionPartnerUnsupportedTypeID, - } - if s == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{} - return typ -} - -// Encode implements bin.Encoder. -func (s *StarTransactionPartnerUnsupported) Encode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUnsupported#c4b20d73 as nil") - } - b.PutID(StarTransactionPartnerUnsupportedTypeID) - return s.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (s *StarTransactionPartnerUnsupported) EncodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUnsupported#c4b20d73 as nil") - } - return nil -} - -// Decode implements bin.Decoder. -func (s *StarTransactionPartnerUnsupported) Decode(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUnsupported#c4b20d73 to nil") - } - if err := b.ConsumeID(StarTransactionPartnerUnsupportedTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUnsupported#c4b20d73: %w", err) - } - return s.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (s *StarTransactionPartnerUnsupported) DecodeBare(b *bin.Buffer) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUnsupported#c4b20d73 to nil") - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (s *StarTransactionPartnerUnsupported) EncodeTDLibJSON(b tdjson.Encoder) error { - if s == nil { - return fmt.Errorf("can't encode starTransactionPartnerUnsupported#c4b20d73 as nil") - } - b.ObjStart() - b.PutID("starTransactionPartnerUnsupported") - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (s *StarTransactionPartnerUnsupported) DecodeTDLibJSON(b tdjson.Decoder) error { - if s == nil { - return fmt.Errorf("can't decode starTransactionPartnerUnsupported#c4b20d73 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("starTransactionPartnerUnsupported"); err != nil { - return fmt.Errorf("unable to decode starTransactionPartnerUnsupported#c4b20d73: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// StarTransactionPartnerClassName is schema name of StarTransactionPartnerClass. -const StarTransactionPartnerClassName = "StarTransactionPartner" - -// StarTransactionPartnerClass represents StarTransactionPartner generic type. -// -// Example: -// -// g, err := tdapi.DecodeStarTransactionPartner(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tdapi.StarTransactionPartnerTelegram: // starTransactionPartnerTelegram#7a899cc0 -// case *tdapi.StarTransactionPartnerAppStore: // starTransactionPartnerAppStore#e34026dc -// case *tdapi.StarTransactionPartnerGooglePlay: // starTransactionPartnerGooglePlay#f229f2a0 -// case *tdapi.StarTransactionPartnerFragment: // starTransactionPartnerFragment#da1849b5 -// case *tdapi.StarTransactionPartnerTelegramAds: // starTransactionPartnerTelegramAds#91f9c6b -// case *tdapi.StarTransactionPartnerTelegramAPI: // starTransactionPartnerTelegramApi#543cc9fd -// case *tdapi.StarTransactionPartnerBot: // starTransactionPartnerBot#4ece3a40 -// case *tdapi.StarTransactionPartnerBusiness: // starTransactionPartnerBusiness#7af9fb52 -// case *tdapi.StarTransactionPartnerChat: // starTransactionPartnerChat#71db4d40 -// case *tdapi.StarTransactionPartnerUser: // starTransactionPartnerUser#6f4d43d1 -// case *tdapi.StarTransactionPartnerUnsupported: // starTransactionPartnerUnsupported#c4b20d73 -// default: panic(v) -// } -type StarTransactionPartnerClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() StarTransactionPartnerClass - - // TypeID returns type id in TL schema. - // - // See https://core.telegram.org/mtproto/TL-tl#remarks. - TypeID() uint32 - // TypeName returns name of type in TL schema. - TypeName() string - // String implements fmt.Stringer. - String() string - // Zero returns true if current object has a zero value. - Zero() bool - - EncodeTDLibJSON(b tdjson.Encoder) error - DecodeTDLibJSON(b tdjson.Decoder) error -} - -// DecodeStarTransactionPartner implements binary de-serialization for StarTransactionPartnerClass. -func DecodeStarTransactionPartner(buf *bin.Buffer) (StarTransactionPartnerClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case StarTransactionPartnerTelegramTypeID: - // Decoding starTransactionPartnerTelegram#7a899cc0. - v := StarTransactionPartnerTelegram{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerAppStoreTypeID: - // Decoding starTransactionPartnerAppStore#e34026dc. - v := StarTransactionPartnerAppStore{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerGooglePlayTypeID: - // Decoding starTransactionPartnerGooglePlay#f229f2a0. - v := StarTransactionPartnerGooglePlay{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerFragmentTypeID: - // Decoding starTransactionPartnerFragment#da1849b5. - v := StarTransactionPartnerFragment{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerTelegramAdsTypeID: - // Decoding starTransactionPartnerTelegramAds#91f9c6b. - v := StarTransactionPartnerTelegramAds{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerTelegramAPITypeID: - // Decoding starTransactionPartnerTelegramApi#543cc9fd. - v := StarTransactionPartnerTelegramAPI{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerBotTypeID: - // Decoding starTransactionPartnerBot#4ece3a40. - v := StarTransactionPartnerBot{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerBusinessTypeID: - // Decoding starTransactionPartnerBusiness#7af9fb52. - v := StarTransactionPartnerBusiness{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerChatTypeID: - // Decoding starTransactionPartnerChat#71db4d40. - v := StarTransactionPartnerChat{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerUserTypeID: - // Decoding starTransactionPartnerUser#6f4d43d1. - v := StarTransactionPartnerUser{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case StarTransactionPartnerUnsupportedTypeID: - // Decoding starTransactionPartnerUnsupported#c4b20d73. - v := StarTransactionPartnerUnsupported{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", bin.NewUnexpectedID(id)) - } -} - -// DecodeTDLibJSONStarTransactionPartner implements binary de-serialization for StarTransactionPartnerClass. -func DecodeTDLibJSONStarTransactionPartner(buf tdjson.Decoder) (StarTransactionPartnerClass, error) { - id, err := buf.FindTypeID() - if err != nil { - return nil, err - } - switch id { - case "starTransactionPartnerTelegram": - // Decoding starTransactionPartnerTelegram#7a899cc0. - v := StarTransactionPartnerTelegram{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerAppStore": - // Decoding starTransactionPartnerAppStore#e34026dc. - v := StarTransactionPartnerAppStore{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerGooglePlay": - // Decoding starTransactionPartnerGooglePlay#f229f2a0. - v := StarTransactionPartnerGooglePlay{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerFragment": - // Decoding starTransactionPartnerFragment#da1849b5. - v := StarTransactionPartnerFragment{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerTelegramAds": - // Decoding starTransactionPartnerTelegramAds#91f9c6b. - v := StarTransactionPartnerTelegramAds{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerTelegramApi": - // Decoding starTransactionPartnerTelegramApi#543cc9fd. - v := StarTransactionPartnerTelegramAPI{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerBot": - // Decoding starTransactionPartnerBot#4ece3a40. - v := StarTransactionPartnerBot{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerBusiness": - // Decoding starTransactionPartnerBusiness#7af9fb52. - v := StarTransactionPartnerBusiness{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerChat": - // Decoding starTransactionPartnerChat#71db4d40. - v := StarTransactionPartnerChat{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerUser": - // Decoding starTransactionPartnerUser#6f4d43d1. - v := StarTransactionPartnerUser{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - case "starTransactionPartnerUnsupported": - // Decoding starTransactionPartnerUnsupported#c4b20d73. - v := StarTransactionPartnerUnsupported{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode StarTransactionPartnerClass: %w", tdjson.NewUnexpectedID(id)) - } -} - -// StarTransactionPartner boxes the StarTransactionPartnerClass providing a helper. -type StarTransactionPartnerBox struct { - StarTransactionPartner StarTransactionPartnerClass -} - -// Decode implements bin.Decoder for StarTransactionPartnerBox. -func (b *StarTransactionPartnerBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode StarTransactionPartnerBox to nil") - } - v, err := DecodeStarTransactionPartner(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.StarTransactionPartner = v - return nil -} - -// Encode implements bin.Encode for StarTransactionPartnerBox. -func (b *StarTransactionPartnerBox) Encode(buf *bin.Buffer) error { - if b == nil || b.StarTransactionPartner == nil { - return fmt.Errorf("unable to encode StarTransactionPartnerClass as nil") - } - return b.StarTransactionPartner.Encode(buf) -} - -// DecodeTDLibJSON implements bin.Decoder for StarTransactionPartnerBox. -func (b *StarTransactionPartnerBox) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("unable to decode StarTransactionPartnerBox to nil") - } - v, err := DecodeTDLibJSONStarTransactionPartner(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.StarTransactionPartner = v - return nil -} - -// EncodeTDLibJSON implements bin.Encode for StarTransactionPartnerBox. -func (b *StarTransactionPartnerBox) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil || b.StarTransactionPartner == nil { - return fmt.Errorf("unable to encode StarTransactionPartnerClass as nil") - } - return b.StarTransactionPartner.EncodeTDLibJSON(buf) -} diff --git a/tdapi/tl_star_transaction_type_gen.go b/tdapi/tl_star_transaction_type_gen.go new file mode 100644 index 0000000000..7244bc5b16 --- /dev/null +++ b/tdapi/tl_star_transaction_type_gen.go @@ -0,0 +1,5531 @@ +// Code generated by gotdgen, DO NOT EDIT. + +package tdapi + +import ( + "context" + "errors" + "fmt" + "sort" + "strings" + + "go.uber.org/multierr" + + "github.com/gotd/td/bin" + "github.com/gotd/td/tdjson" + "github.com/gotd/td/tdp" + "github.com/gotd/td/tgerr" +) + +// No-op definition for keeping imports. +var ( + _ = bin.Buffer{} + _ = context.Background() + _ = fmt.Stringer(nil) + _ = strings.Builder{} + _ = errors.Is + _ = multierr.AppendInto + _ = sort.Ints + _ = tdp.Format + _ = tgerr.Error{} + _ = tdjson.Encoder{} +) + +// StarTransactionTypePremiumBotDeposit represents TL type `starTransactionTypePremiumBotDeposit#d879090e`. +type StarTransactionTypePremiumBotDeposit struct { +} + +// StarTransactionTypePremiumBotDepositTypeID is TL type id of StarTransactionTypePremiumBotDeposit. +const StarTransactionTypePremiumBotDepositTypeID = 0xd879090e + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypePremiumBotDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypePremiumBotDeposit. +var ( + _ bin.Encoder = &StarTransactionTypePremiumBotDeposit{} + _ bin.Decoder = &StarTransactionTypePremiumBotDeposit{} + _ bin.BareEncoder = &StarTransactionTypePremiumBotDeposit{} + _ bin.BareDecoder = &StarTransactionTypePremiumBotDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypePremiumBotDeposit{} +) + +func (s *StarTransactionTypePremiumBotDeposit) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypePremiumBotDeposit) String() string { + if s == nil { + return "StarTransactionTypePremiumBotDeposit(nil)" + } + type Alias StarTransactionTypePremiumBotDeposit + return fmt.Sprintf("StarTransactionTypePremiumBotDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypePremiumBotDeposit) TypeID() uint32 { + return StarTransactionTypePremiumBotDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypePremiumBotDeposit) TypeName() string { + return "starTransactionTypePremiumBotDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypePremiumBotDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypePremiumBotDeposit", + ID: StarTransactionTypePremiumBotDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypePremiumBotDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypePremiumBotDeposit#d879090e as nil") + } + b.PutID(StarTransactionTypePremiumBotDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypePremiumBotDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypePremiumBotDeposit#d879090e as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypePremiumBotDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil") + } + if err := b.ConsumeID(StarTransactionTypePremiumBotDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypePremiumBotDeposit#d879090e: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypePremiumBotDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypePremiumBotDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypePremiumBotDeposit#d879090e as nil") + } + b.ObjStart() + b.PutID("starTransactionTypePremiumBotDeposit") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypePremiumBotDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypePremiumBotDeposit#d879090e to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypePremiumBotDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypePremiumBotDeposit#d879090e: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeAppStoreDeposit represents TL type `starTransactionTypeAppStoreDeposit#8283941`. +type StarTransactionTypeAppStoreDeposit struct { +} + +// StarTransactionTypeAppStoreDepositTypeID is TL type id of StarTransactionTypeAppStoreDeposit. +const StarTransactionTypeAppStoreDepositTypeID = 0x8283941 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeAppStoreDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeAppStoreDeposit. +var ( + _ bin.Encoder = &StarTransactionTypeAppStoreDeposit{} + _ bin.Decoder = &StarTransactionTypeAppStoreDeposit{} + _ bin.BareEncoder = &StarTransactionTypeAppStoreDeposit{} + _ bin.BareDecoder = &StarTransactionTypeAppStoreDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypeAppStoreDeposit{} +) + +func (s *StarTransactionTypeAppStoreDeposit) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeAppStoreDeposit) String() string { + if s == nil { + return "StarTransactionTypeAppStoreDeposit(nil)" + } + type Alias StarTransactionTypeAppStoreDeposit + return fmt.Sprintf("StarTransactionTypeAppStoreDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeAppStoreDeposit) TypeID() uint32 { + return StarTransactionTypeAppStoreDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeAppStoreDeposit) TypeName() string { + return "starTransactionTypeAppStoreDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeAppStoreDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeAppStoreDeposit", + ID: StarTransactionTypeAppStoreDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeAppStoreDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAppStoreDeposit#8283941 as nil") + } + b.PutID(StarTransactionTypeAppStoreDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeAppStoreDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAppStoreDeposit#8283941 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeAppStoreDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil") + } + if err := b.ConsumeID(StarTransactionTypeAppStoreDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAppStoreDeposit#8283941: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeAppStoreDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeAppStoreDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAppStoreDeposit#8283941 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeAppStoreDeposit") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeAppStoreDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAppStoreDeposit#8283941 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeAppStoreDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAppStoreDeposit#8283941: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeGooglePlayDeposit represents TL type `starTransactionTypeGooglePlayDeposit#ecbdb656`. +type StarTransactionTypeGooglePlayDeposit struct { +} + +// StarTransactionTypeGooglePlayDepositTypeID is TL type id of StarTransactionTypeGooglePlayDeposit. +const StarTransactionTypeGooglePlayDepositTypeID = 0xecbdb656 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeGooglePlayDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeGooglePlayDeposit. +var ( + _ bin.Encoder = &StarTransactionTypeGooglePlayDeposit{} + _ bin.Decoder = &StarTransactionTypeGooglePlayDeposit{} + _ bin.BareEncoder = &StarTransactionTypeGooglePlayDeposit{} + _ bin.BareDecoder = &StarTransactionTypeGooglePlayDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypeGooglePlayDeposit{} +) + +func (s *StarTransactionTypeGooglePlayDeposit) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeGooglePlayDeposit) String() string { + if s == nil { + return "StarTransactionTypeGooglePlayDeposit(nil)" + } + type Alias StarTransactionTypeGooglePlayDeposit + return fmt.Sprintf("StarTransactionTypeGooglePlayDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeGooglePlayDeposit) TypeID() uint32 { + return StarTransactionTypeGooglePlayDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeGooglePlayDeposit) TypeName() string { + return "starTransactionTypeGooglePlayDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeGooglePlayDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeGooglePlayDeposit", + ID: StarTransactionTypeGooglePlayDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeGooglePlayDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGooglePlayDeposit#ecbdb656 as nil") + } + b.PutID(StarTransactionTypeGooglePlayDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeGooglePlayDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGooglePlayDeposit#ecbdb656 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeGooglePlayDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil") + } + if err := b.ConsumeID(StarTransactionTypeGooglePlayDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGooglePlayDeposit#ecbdb656: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeGooglePlayDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeGooglePlayDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGooglePlayDeposit#ecbdb656 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeGooglePlayDeposit") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeGooglePlayDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGooglePlayDeposit#ecbdb656 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeGooglePlayDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGooglePlayDeposit#ecbdb656: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeFragmentDeposit represents TL type `starTransactionTypeFragmentDeposit#7625e44`. +type StarTransactionTypeFragmentDeposit struct { +} + +// StarTransactionTypeFragmentDepositTypeID is TL type id of StarTransactionTypeFragmentDeposit. +const StarTransactionTypeFragmentDepositTypeID = 0x7625e44 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeFragmentDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeFragmentDeposit. +var ( + _ bin.Encoder = &StarTransactionTypeFragmentDeposit{} + _ bin.Decoder = &StarTransactionTypeFragmentDeposit{} + _ bin.BareEncoder = &StarTransactionTypeFragmentDeposit{} + _ bin.BareDecoder = &StarTransactionTypeFragmentDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypeFragmentDeposit{} +) + +func (s *StarTransactionTypeFragmentDeposit) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeFragmentDeposit) String() string { + if s == nil { + return "StarTransactionTypeFragmentDeposit(nil)" + } + type Alias StarTransactionTypeFragmentDeposit + return fmt.Sprintf("StarTransactionTypeFragmentDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeFragmentDeposit) TypeID() uint32 { + return StarTransactionTypeFragmentDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeFragmentDeposit) TypeName() string { + return "starTransactionTypeFragmentDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeFragmentDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeFragmentDeposit", + ID: StarTransactionTypeFragmentDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeFragmentDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil") + } + b.PutID(StarTransactionTypeFragmentDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeFragmentDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeFragmentDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil") + } + if err := b.ConsumeID(StarTransactionTypeFragmentDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentDeposit#7625e44: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeFragmentDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeFragmentDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentDeposit#7625e44 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeFragmentDeposit") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeFragmentDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentDeposit#7625e44 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeFragmentDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentDeposit#7625e44: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeUserDeposit represents TL type `starTransactionTypeUserDeposit#c2a18e9`. +type StarTransactionTypeUserDeposit struct { + // Identifier of the user that gifted Telegram Stars; 0 if the user was anonymous + UserID int64 + // The sticker to be shown in the transaction information; may be null if unknown + Sticker Sticker +} + +// StarTransactionTypeUserDepositTypeID is TL type id of StarTransactionTypeUserDeposit. +const StarTransactionTypeUserDepositTypeID = 0xc2a18e9 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeUserDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeUserDeposit. +var ( + _ bin.Encoder = &StarTransactionTypeUserDeposit{} + _ bin.Decoder = &StarTransactionTypeUserDeposit{} + _ bin.BareEncoder = &StarTransactionTypeUserDeposit{} + _ bin.BareDecoder = &StarTransactionTypeUserDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypeUserDeposit{} +) + +func (s *StarTransactionTypeUserDeposit) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.Sticker.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeUserDeposit) String() string { + if s == nil { + return "StarTransactionTypeUserDeposit(nil)" + } + type Alias StarTransactionTypeUserDeposit + return fmt.Sprintf("StarTransactionTypeUserDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeUserDeposit) TypeID() uint32 { + return StarTransactionTypeUserDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeUserDeposit) TypeName() string { + return "starTransactionTypeUserDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeUserDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeUserDeposit", + ID: StarTransactionTypeUserDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Sticker", + SchemaName: "sticker", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeUserDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil") + } + b.PutID(StarTransactionTypeUserDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeUserDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil") + } + b.PutInt53(s.UserID) + if err := s.Sticker.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeUserDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil") + } + if err := b.ConsumeID(StarTransactionTypeUserDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeUserDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.Sticker.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeUserDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUserDeposit#c2a18e9 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeUserDeposit") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("sticker") + if err := s.Sticker.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeUserDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUserDeposit#c2a18e9 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeUserDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field user_id: %w", err) + } + s.UserID = value + case "sticker": + if err := s.Sticker.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUserDeposit#c2a18e9: field sticker: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeUserDeposit) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetSticker returns value of Sticker field. +func (s *StarTransactionTypeUserDeposit) GetSticker() (value Sticker) { + if s == nil { + return + } + return s.Sticker +} + +// StarTransactionTypeGiveawayDeposit represents TL type `starTransactionTypeGiveawayDeposit#b16200c6`. +type StarTransactionTypeGiveawayDeposit struct { + // Identifier of a supergroup or a channel chat that created the giveaway + ChatID int64 + // Identifier of the message with the giveaway; can be 0 or an identifier of a deleted + // message + GiveawayMessageID int64 +} + +// StarTransactionTypeGiveawayDepositTypeID is TL type id of StarTransactionTypeGiveawayDeposit. +const StarTransactionTypeGiveawayDepositTypeID = 0xb16200c6 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeGiveawayDeposit) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeGiveawayDeposit. +var ( + _ bin.Encoder = &StarTransactionTypeGiveawayDeposit{} + _ bin.Decoder = &StarTransactionTypeGiveawayDeposit{} + _ bin.BareEncoder = &StarTransactionTypeGiveawayDeposit{} + _ bin.BareDecoder = &StarTransactionTypeGiveawayDeposit{} + + _ StarTransactionTypeClass = &StarTransactionTypeGiveawayDeposit{} +) + +func (s *StarTransactionTypeGiveawayDeposit) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.GiveawayMessageID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeGiveawayDeposit) String() string { + if s == nil { + return "StarTransactionTypeGiveawayDeposit(nil)" + } + type Alias StarTransactionTypeGiveawayDeposit + return fmt.Sprintf("StarTransactionTypeGiveawayDeposit%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeGiveawayDeposit) TypeID() uint32 { + return StarTransactionTypeGiveawayDepositTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeGiveawayDeposit) TypeName() string { + return "starTransactionTypeGiveawayDeposit" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeGiveawayDeposit) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeGiveawayDeposit", + ID: StarTransactionTypeGiveawayDepositTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "GiveawayMessageID", + SchemaName: "giveaway_message_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeGiveawayDeposit) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil") + } + b.PutID(StarTransactionTypeGiveawayDepositTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeGiveawayDeposit) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil") + } + b.PutInt53(s.ChatID) + b.PutInt53(s.GiveawayMessageID) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeGiveawayDeposit) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil") + } + if err := b.ConsumeID(StarTransactionTypeGiveawayDepositTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeGiveawayDeposit) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field giveaway_message_id: %w", err) + } + s.GiveawayMessageID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeGiveawayDeposit) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiveawayDeposit#b16200c6 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeGiveawayDeposit") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("giveaway_message_id") + b.PutInt53(s.GiveawayMessageID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeGiveawayDeposit) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiveawayDeposit#b16200c6 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeGiveawayDeposit"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field chat_id: %w", err) + } + s.ChatID = value + case "giveaway_message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiveawayDeposit#b16200c6: field giveaway_message_id: %w", err) + } + s.GiveawayMessageID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *StarTransactionTypeGiveawayDeposit) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetGiveawayMessageID returns value of GiveawayMessageID field. +func (s *StarTransactionTypeGiveawayDeposit) GetGiveawayMessageID() (value int64) { + if s == nil { + return + } + return s.GiveawayMessageID +} + +// StarTransactionTypeFragmentWithdrawal represents TL type `starTransactionTypeFragmentWithdrawal#af3a2992`. +type StarTransactionTypeFragmentWithdrawal struct { + // State of the withdrawal; may be null for refunds from Fragment + WithdrawalState RevenueWithdrawalStateClass +} + +// StarTransactionTypeFragmentWithdrawalTypeID is TL type id of StarTransactionTypeFragmentWithdrawal. +const StarTransactionTypeFragmentWithdrawalTypeID = 0xaf3a2992 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeFragmentWithdrawal) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeFragmentWithdrawal. +var ( + _ bin.Encoder = &StarTransactionTypeFragmentWithdrawal{} + _ bin.Decoder = &StarTransactionTypeFragmentWithdrawal{} + _ bin.BareEncoder = &StarTransactionTypeFragmentWithdrawal{} + _ bin.BareDecoder = &StarTransactionTypeFragmentWithdrawal{} + + _ StarTransactionTypeClass = &StarTransactionTypeFragmentWithdrawal{} +) + +func (s *StarTransactionTypeFragmentWithdrawal) Zero() bool { + if s == nil { + return true + } + if !(s.WithdrawalState == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeFragmentWithdrawal) String() string { + if s == nil { + return "StarTransactionTypeFragmentWithdrawal(nil)" + } + type Alias StarTransactionTypeFragmentWithdrawal + return fmt.Sprintf("StarTransactionTypeFragmentWithdrawal%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeFragmentWithdrawal) TypeID() uint32 { + return StarTransactionTypeFragmentWithdrawalTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeFragmentWithdrawal) TypeName() string { + return "starTransactionTypeFragmentWithdrawal" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeFragmentWithdrawal) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeFragmentWithdrawal", + ID: StarTransactionTypeFragmentWithdrawalTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "WithdrawalState", + SchemaName: "withdrawal_state", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeFragmentWithdrawal) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil") + } + b.PutID(StarTransactionTypeFragmentWithdrawalTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeFragmentWithdrawal) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil") + } + if s.WithdrawalState == nil { + return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state is nil") + } + if err := s.WithdrawalState.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeFragmentWithdrawal) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil") + } + if err := b.ConsumeID(StarTransactionTypeFragmentWithdrawalTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeFragmentWithdrawal) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil") + } + { + value, err := DecodeRevenueWithdrawalState(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err) + } + s.WithdrawalState = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeFragmentWithdrawal) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeFragmentWithdrawal#af3a2992 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeFragmentWithdrawal") + b.Comma() + b.FieldStart("withdrawal_state") + if s.WithdrawalState == nil { + return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state is nil") + } + if err := s.WithdrawalState.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeFragmentWithdrawal) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeFragmentWithdrawal#af3a2992 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeFragmentWithdrawal"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: %w", err) + } + case "withdrawal_state": + value, err := DecodeTDLibJSONRevenueWithdrawalState(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeFragmentWithdrawal#af3a2992: field withdrawal_state: %w", err) + } + s.WithdrawalState = value + default: + return b.Skip() + } + return nil + }) +} + +// GetWithdrawalState returns value of WithdrawalState field. +func (s *StarTransactionTypeFragmentWithdrawal) GetWithdrawalState() (value RevenueWithdrawalStateClass) { + if s == nil { + return + } + return s.WithdrawalState +} + +// StarTransactionTypeTelegramAdsWithdrawal represents TL type `starTransactionTypeTelegramAdsWithdrawal#a58e8469`. +type StarTransactionTypeTelegramAdsWithdrawal struct { +} + +// StarTransactionTypeTelegramAdsWithdrawalTypeID is TL type id of StarTransactionTypeTelegramAdsWithdrawal. +const StarTransactionTypeTelegramAdsWithdrawalTypeID = 0xa58e8469 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeTelegramAdsWithdrawal) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeTelegramAdsWithdrawal. +var ( + _ bin.Encoder = &StarTransactionTypeTelegramAdsWithdrawal{} + _ bin.Decoder = &StarTransactionTypeTelegramAdsWithdrawal{} + _ bin.BareEncoder = &StarTransactionTypeTelegramAdsWithdrawal{} + _ bin.BareDecoder = &StarTransactionTypeTelegramAdsWithdrawal{} + + _ StarTransactionTypeClass = &StarTransactionTypeTelegramAdsWithdrawal{} +) + +func (s *StarTransactionTypeTelegramAdsWithdrawal) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeTelegramAdsWithdrawal) String() string { + if s == nil { + return "StarTransactionTypeTelegramAdsWithdrawal(nil)" + } + type Alias StarTransactionTypeTelegramAdsWithdrawal + return fmt.Sprintf("StarTransactionTypeTelegramAdsWithdrawal%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeTelegramAdsWithdrawal) TypeID() uint32 { + return StarTransactionTypeTelegramAdsWithdrawalTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeTelegramAdsWithdrawal) TypeName() string { + return "starTransactionTypeTelegramAdsWithdrawal" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeTelegramAdsWithdrawal) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeTelegramAdsWithdrawal", + ID: StarTransactionTypeTelegramAdsWithdrawalTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramAdsWithdrawal#a58e8469 as nil") + } + b.PutID(StarTransactionTypeTelegramAdsWithdrawalTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramAdsWithdrawal#a58e8469 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil") + } + if err := b.ConsumeID(StarTransactionTypeTelegramAdsWithdrawalTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramAdsWithdrawal#a58e8469: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramAdsWithdrawal#a58e8469 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeTelegramAdsWithdrawal") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeTelegramAdsWithdrawal) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramAdsWithdrawal#a58e8469 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeTelegramAdsWithdrawal"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramAdsWithdrawal#a58e8469: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeTelegramAPIUsage represents TL type `starTransactionTypeTelegramApiUsage#27a82afe`. +type StarTransactionTypeTelegramAPIUsage struct { + // The number of billed requests + RequestCount int32 +} + +// StarTransactionTypeTelegramAPIUsageTypeID is TL type id of StarTransactionTypeTelegramAPIUsage. +const StarTransactionTypeTelegramAPIUsageTypeID = 0x27a82afe + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeTelegramAPIUsage) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeTelegramAPIUsage. +var ( + _ bin.Encoder = &StarTransactionTypeTelegramAPIUsage{} + _ bin.Decoder = &StarTransactionTypeTelegramAPIUsage{} + _ bin.BareEncoder = &StarTransactionTypeTelegramAPIUsage{} + _ bin.BareDecoder = &StarTransactionTypeTelegramAPIUsage{} + + _ StarTransactionTypeClass = &StarTransactionTypeTelegramAPIUsage{} +) + +func (s *StarTransactionTypeTelegramAPIUsage) Zero() bool { + if s == nil { + return true + } + if !(s.RequestCount == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeTelegramAPIUsage) String() string { + if s == nil { + return "StarTransactionTypeTelegramAPIUsage(nil)" + } + type Alias StarTransactionTypeTelegramAPIUsage + return fmt.Sprintf("StarTransactionTypeTelegramAPIUsage%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeTelegramAPIUsage) TypeID() uint32 { + return StarTransactionTypeTelegramAPIUsageTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeTelegramAPIUsage) TypeName() string { + return "starTransactionTypeTelegramApiUsage" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeTelegramAPIUsage) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeTelegramApiUsage", + ID: StarTransactionTypeTelegramAPIUsageTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "RequestCount", + SchemaName: "request_count", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeTelegramAPIUsage) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil") + } + b.PutID(StarTransactionTypeTelegramAPIUsageTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeTelegramAPIUsage) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil") + } + b.PutInt32(s.RequestCount) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeTelegramAPIUsage) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil") + } + if err := b.ConsumeID(StarTransactionTypeTelegramAPIUsageTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeTelegramAPIUsage) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil") + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: field request_count: %w", err) + } + s.RequestCount = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeTelegramAPIUsage) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeTelegramApiUsage#27a82afe as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeTelegramApiUsage") + b.Comma() + b.FieldStart("request_count") + b.PutInt32(s.RequestCount) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeTelegramAPIUsage) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeTelegramApiUsage#27a82afe to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeTelegramApiUsage"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: %w", err) + } + case "request_count": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeTelegramApiUsage#27a82afe: field request_count: %w", err) + } + s.RequestCount = value + default: + return b.Skip() + } + return nil + }) +} + +// GetRequestCount returns value of RequestCount field. +func (s *StarTransactionTypeTelegramAPIUsage) GetRequestCount() (value int32) { + if s == nil { + return + } + return s.RequestCount +} + +// StarTransactionTypeBotPaidMediaPurchase represents TL type `starTransactionTypeBotPaidMediaPurchase#7f48cc6a`. +type StarTransactionTypeBotPaidMediaPurchase struct { + // Identifier of the bot or the business account user that sent the paid media + UserID int64 + // The bought media if the transaction wasn't refunded + Media []PaidMediaClass +} + +// StarTransactionTypeBotPaidMediaPurchaseTypeID is TL type id of StarTransactionTypeBotPaidMediaPurchase. +const StarTransactionTypeBotPaidMediaPurchaseTypeID = 0x7f48cc6a + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotPaidMediaPurchase) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotPaidMediaPurchase. +var ( + _ bin.Encoder = &StarTransactionTypeBotPaidMediaPurchase{} + _ bin.Decoder = &StarTransactionTypeBotPaidMediaPurchase{} + _ bin.BareEncoder = &StarTransactionTypeBotPaidMediaPurchase{} + _ bin.BareDecoder = &StarTransactionTypeBotPaidMediaPurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotPaidMediaPurchase{} +) + +func (s *StarTransactionTypeBotPaidMediaPurchase) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotPaidMediaPurchase) String() string { + if s == nil { + return "StarTransactionTypeBotPaidMediaPurchase(nil)" + } + type Alias StarTransactionTypeBotPaidMediaPurchase + return fmt.Sprintf("StarTransactionTypeBotPaidMediaPurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotPaidMediaPurchase) TypeID() uint32 { + return StarTransactionTypeBotPaidMediaPurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotPaidMediaPurchase) TypeName() string { + return "starTransactionTypeBotPaidMediaPurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotPaidMediaPurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotPaidMediaPurchase", + ID: StarTransactionTypeBotPaidMediaPurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil") + } + b.PutID(StarTransactionTypeBotPaidMediaPurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil") + } + b.PutInt53(s.UserID) + b.PutInt(len(s.Media)) + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d is nil", idx) + } + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotPaidMediaPurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field user_id: %w", err) + } + s.UserID = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err) + } + + if headerLen > 0 { + s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodePaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err) + } + s.Media = append(s.Media, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotPaidMediaPurchase") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("media") + b.ArrStart() + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d is nil", idx) + } + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotPaidMediaPurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotPaidMediaPurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field user_id: %w", err) + } + s.UserID = value + case "media": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := DecodeTDLibJSONPaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err) + } + s.Media = append(s.Media, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaPurchase#7f48cc6a: field media: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotPaidMediaPurchase) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetMedia returns value of Media field. +func (s *StarTransactionTypeBotPaidMediaPurchase) GetMedia() (value []PaidMediaClass) { + if s == nil { + return + } + return s.Media +} + +// StarTransactionTypeBotPaidMediaSale represents TL type `starTransactionTypeBotPaidMediaSale#6e07eeb2`. +type StarTransactionTypeBotPaidMediaSale struct { + // Identifier of the user that bought the media + UserID int64 + // The bought media + Media []PaidMediaClass + // Bot-provided payload + Payload string + // Information about the affiliate which received commission from the transaction; may be + // null if none + Affiliate AffiliateInfo +} + +// StarTransactionTypeBotPaidMediaSaleTypeID is TL type id of StarTransactionTypeBotPaidMediaSale. +const StarTransactionTypeBotPaidMediaSaleTypeID = 0x6e07eeb2 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotPaidMediaSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotPaidMediaSale. +var ( + _ bin.Encoder = &StarTransactionTypeBotPaidMediaSale{} + _ bin.Decoder = &StarTransactionTypeBotPaidMediaSale{} + _ bin.BareEncoder = &StarTransactionTypeBotPaidMediaSale{} + _ bin.BareDecoder = &StarTransactionTypeBotPaidMediaSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotPaidMediaSale{} +) + +func (s *StarTransactionTypeBotPaidMediaSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.Media == nil) { + return false + } + if !(s.Payload == "") { + return false + } + if !(s.Affiliate.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotPaidMediaSale) String() string { + if s == nil { + return "StarTransactionTypeBotPaidMediaSale(nil)" + } + type Alias StarTransactionTypeBotPaidMediaSale + return fmt.Sprintf("StarTransactionTypeBotPaidMediaSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotPaidMediaSale) TypeID() uint32 { + return StarTransactionTypeBotPaidMediaSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotPaidMediaSale) TypeName() string { + return "starTransactionTypeBotPaidMediaSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotPaidMediaSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotPaidMediaSale", + ID: StarTransactionTypeBotPaidMediaSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Media", + SchemaName: "media", + }, + { + Name: "Payload", + SchemaName: "payload", + }, + { + Name: "Affiliate", + SchemaName: "affiliate", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotPaidMediaSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil") + } + b.PutID(StarTransactionTypeBotPaidMediaSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotPaidMediaSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil") + } + b.PutInt53(s.UserID) + b.PutInt(len(s.Media)) + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d is nil", idx) + } + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d: %w", idx, err) + } + } + b.PutString(s.Payload) + if err := s.Affiliate.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotPaidMediaSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotPaidMediaSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotPaidMediaSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field user_id: %w", err) + } + s.UserID = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err) + } + + if headerLen > 0 { + s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodePaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err) + } + s.Media = append(s.Media, value) + } + } + { + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field payload: %w", err) + } + s.Payload = value + } + { + if err := s.Affiliate.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotPaidMediaSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotPaidMediaSale#6e07eeb2 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotPaidMediaSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("media") + b.ArrStart() + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d is nil", idx) + } + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.FieldStart("payload") + b.PutString(s.Payload) + b.Comma() + b.FieldStart("affiliate") + if err := s.Affiliate.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotPaidMediaSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotPaidMediaSale#6e07eeb2 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotPaidMediaSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field user_id: %w", err) + } + s.UserID = value + case "media": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := DecodeTDLibJSONPaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err) + } + s.Media = append(s.Media, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field media: %w", err) + } + case "payload": + value, err := b.String() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field payload: %w", err) + } + s.Payload = value + case "affiliate": + if err := s.Affiliate.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotPaidMediaSale#6e07eeb2: field affiliate: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotPaidMediaSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetMedia returns value of Media field. +func (s *StarTransactionTypeBotPaidMediaSale) GetMedia() (value []PaidMediaClass) { + if s == nil { + return + } + return s.Media +} + +// GetPayload returns value of Payload field. +func (s *StarTransactionTypeBotPaidMediaSale) GetPayload() (value string) { + if s == nil { + return + } + return s.Payload +} + +// GetAffiliate returns value of Affiliate field. +func (s *StarTransactionTypeBotPaidMediaSale) GetAffiliate() (value AffiliateInfo) { + if s == nil { + return + } + return s.Affiliate +} + +// StarTransactionTypeChannelPaidMediaPurchase represents TL type `starTransactionTypeChannelPaidMediaPurchase#9016d4f5`. +type StarTransactionTypeChannelPaidMediaPurchase struct { + // Identifier of the channel chat that sent the paid media + ChatID int64 + // Identifier of the corresponding message with paid media; can be 0 or an identifier of + // a deleted message + MessageID int64 + // The bought media if the transaction wasn't refunded + Media []PaidMediaClass +} + +// StarTransactionTypeChannelPaidMediaPurchaseTypeID is TL type id of StarTransactionTypeChannelPaidMediaPurchase. +const StarTransactionTypeChannelPaidMediaPurchaseTypeID = 0x9016d4f5 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelPaidMediaPurchase) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelPaidMediaPurchase. +var ( + _ bin.Encoder = &StarTransactionTypeChannelPaidMediaPurchase{} + _ bin.Decoder = &StarTransactionTypeChannelPaidMediaPurchase{} + _ bin.BareEncoder = &StarTransactionTypeChannelPaidMediaPurchase{} + _ bin.BareDecoder = &StarTransactionTypeChannelPaidMediaPurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelPaidMediaPurchase{} +) + +func (s *StarTransactionTypeChannelPaidMediaPurchase) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.MessageID == 0) { + return false + } + if !(s.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelPaidMediaPurchase) String() string { + if s == nil { + return "StarTransactionTypeChannelPaidMediaPurchase(nil)" + } + type Alias StarTransactionTypeChannelPaidMediaPurchase + return fmt.Sprintf("StarTransactionTypeChannelPaidMediaPurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelPaidMediaPurchase) TypeID() uint32 { + return StarTransactionTypeChannelPaidMediaPurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelPaidMediaPurchase) TypeName() string { + return "starTransactionTypeChannelPaidMediaPurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelPaidMediaPurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelPaidMediaPurchase", + ID: StarTransactionTypeChannelPaidMediaPurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "MessageID", + SchemaName: "message_id", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil") + } + b.PutID(StarTransactionTypeChannelPaidMediaPurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil") + } + b.PutInt53(s.ChatID) + b.PutInt53(s.MessageID) + b.PutInt(len(s.Media)) + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d is nil", idx) + } + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelPaidMediaPurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field message_id: %w", err) + } + s.MessageID = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err) + } + + if headerLen > 0 { + s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodePaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err) + } + s.Media = append(s.Media, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelPaidMediaPurchase") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("message_id") + b.PutInt53(s.MessageID) + b.Comma() + b.FieldStart("media") + b.ArrStart() + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d is nil", idx) + } + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelPaidMediaPurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelPaidMediaPurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field chat_id: %w", err) + } + s.ChatID = value + case "message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field message_id: %w", err) + } + s.MessageID = value + case "media": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := DecodeTDLibJSONPaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err) + } + s.Media = append(s.Media, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaPurchase#9016d4f5: field media: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *StarTransactionTypeChannelPaidMediaPurchase) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetMessageID returns value of MessageID field. +func (s *StarTransactionTypeChannelPaidMediaPurchase) GetMessageID() (value int64) { + if s == nil { + return + } + return s.MessageID +} + +// GetMedia returns value of Media field. +func (s *StarTransactionTypeChannelPaidMediaPurchase) GetMedia() (value []PaidMediaClass) { + if s == nil { + return + } + return s.Media +} + +// StarTransactionTypeChannelPaidMediaSale represents TL type `starTransactionTypeChannelPaidMediaSale#eace92ef`. +type StarTransactionTypeChannelPaidMediaSale struct { + // Identifier of the user that bought the media + UserID int64 + // Identifier of the corresponding message with paid media; can be 0 or an identifier of + // a deleted message + MessageID int64 + // The bought media + Media []PaidMediaClass +} + +// StarTransactionTypeChannelPaidMediaSaleTypeID is TL type id of StarTransactionTypeChannelPaidMediaSale. +const StarTransactionTypeChannelPaidMediaSaleTypeID = 0xeace92ef + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelPaidMediaSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelPaidMediaSale. +var ( + _ bin.Encoder = &StarTransactionTypeChannelPaidMediaSale{} + _ bin.Decoder = &StarTransactionTypeChannelPaidMediaSale{} + _ bin.BareEncoder = &StarTransactionTypeChannelPaidMediaSale{} + _ bin.BareDecoder = &StarTransactionTypeChannelPaidMediaSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelPaidMediaSale{} +) + +func (s *StarTransactionTypeChannelPaidMediaSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.MessageID == 0) { + return false + } + if !(s.Media == nil) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelPaidMediaSale) String() string { + if s == nil { + return "StarTransactionTypeChannelPaidMediaSale(nil)" + } + type Alias StarTransactionTypeChannelPaidMediaSale + return fmt.Sprintf("StarTransactionTypeChannelPaidMediaSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelPaidMediaSale) TypeID() uint32 { + return StarTransactionTypeChannelPaidMediaSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelPaidMediaSale) TypeName() string { + return "starTransactionTypeChannelPaidMediaSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelPaidMediaSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelPaidMediaSale", + ID: StarTransactionTypeChannelPaidMediaSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "MessageID", + SchemaName: "message_id", + }, + { + Name: "Media", + SchemaName: "media", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelPaidMediaSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil") + } + b.PutID(StarTransactionTypeChannelPaidMediaSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelPaidMediaSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil") + } + b.PutInt53(s.UserID) + b.PutInt53(s.MessageID) + b.PutInt(len(s.Media)) + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d is nil", idx) + } + if err := v.EncodeBare(b); err != nil { + return fmt.Errorf("unable to encode bare starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d: %w", idx, err) + } + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelPaidMediaSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelPaidMediaSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelPaidMediaSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field message_id: %w", err) + } + s.MessageID = value + } + { + headerLen, err := b.Int() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err) + } + + if headerLen > 0 { + s.Media = make([]PaidMediaClass, 0, headerLen%bin.PreallocateLimit) + } + for idx := 0; idx < headerLen; idx++ { + value, err := DecodePaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err) + } + s.Media = append(s.Media, value) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelPaidMediaSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidMediaSale#eace92ef as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelPaidMediaSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("message_id") + b.PutInt53(s.MessageID) + b.Comma() + b.FieldStart("media") + b.ArrStart() + for idx, v := range s.Media { + if v == nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d is nil", idx) + } + if err := v.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeChannelPaidMediaSale#eace92ef: field media element with index %d: %w", idx, err) + } + b.Comma() + } + b.StripComma() + b.ArrEnd() + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelPaidMediaSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidMediaSale#eace92ef to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelPaidMediaSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field user_id: %w", err) + } + s.UserID = value + case "message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field message_id: %w", err) + } + s.MessageID = value + case "media": + if err := b.Arr(func(b tdjson.Decoder) error { + value, err := DecodeTDLibJSONPaidMedia(b) + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err) + } + s.Media = append(s.Media, value) + return nil + }); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidMediaSale#eace92ef: field media: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeChannelPaidMediaSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetMessageID returns value of MessageID field. +func (s *StarTransactionTypeChannelPaidMediaSale) GetMessageID() (value int64) { + if s == nil { + return + } + return s.MessageID +} + +// GetMedia returns value of Media field. +func (s *StarTransactionTypeChannelPaidMediaSale) GetMedia() (value []PaidMediaClass) { + if s == nil { + return + } + return s.Media +} + +// StarTransactionTypeBotInvoicePurchase represents TL type `starTransactionTypeBotInvoicePurchase#1dddac0c`. +type StarTransactionTypeBotInvoicePurchase struct { + // Identifier of the bot or the business account user that created the invoice + UserID int64 + // Information about the bought product + ProductInfo ProductInfo +} + +// StarTransactionTypeBotInvoicePurchaseTypeID is TL type id of StarTransactionTypeBotInvoicePurchase. +const StarTransactionTypeBotInvoicePurchaseTypeID = 0x1dddac0c + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotInvoicePurchase) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotInvoicePurchase. +var ( + _ bin.Encoder = &StarTransactionTypeBotInvoicePurchase{} + _ bin.Decoder = &StarTransactionTypeBotInvoicePurchase{} + _ bin.BareEncoder = &StarTransactionTypeBotInvoicePurchase{} + _ bin.BareDecoder = &StarTransactionTypeBotInvoicePurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotInvoicePurchase{} +) + +func (s *StarTransactionTypeBotInvoicePurchase) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.ProductInfo.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotInvoicePurchase) String() string { + if s == nil { + return "StarTransactionTypeBotInvoicePurchase(nil)" + } + type Alias StarTransactionTypeBotInvoicePurchase + return fmt.Sprintf("StarTransactionTypeBotInvoicePurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotInvoicePurchase) TypeID() uint32 { + return StarTransactionTypeBotInvoicePurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotInvoicePurchase) TypeName() string { + return "starTransactionTypeBotInvoicePurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotInvoicePurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotInvoicePurchase", + ID: StarTransactionTypeBotInvoicePurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "ProductInfo", + SchemaName: "product_info", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotInvoicePurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil") + } + b.PutID(StarTransactionTypeBotInvoicePurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotInvoicePurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil") + } + b.PutInt53(s.UserID) + if err := s.ProductInfo.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotInvoicePurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotInvoicePurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotInvoicePurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.ProductInfo.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotInvoicePurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoicePurchase#1dddac0c as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotInvoicePurchase") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("product_info") + if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotInvoicePurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoicePurchase#1dddac0c to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotInvoicePurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field user_id: %w", err) + } + s.UserID = value + case "product_info": + if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoicePurchase#1dddac0c: field product_info: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotInvoicePurchase) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetProductInfo returns value of ProductInfo field. +func (s *StarTransactionTypeBotInvoicePurchase) GetProductInfo() (value ProductInfo) { + if s == nil { + return + } + return s.ProductInfo +} + +// StarTransactionTypeBotInvoiceSale represents TL type `starTransactionTypeBotInvoiceSale#5b7d8d2f`. +type StarTransactionTypeBotInvoiceSale struct { + // Identifier of the user that bought the product + UserID int64 + // Information about the bought product + ProductInfo ProductInfo + // Invoice payload + InvoicePayload []byte + // Information about the affiliate which received commission from the transaction; may be + // null if none + Affiliate AffiliateInfo +} + +// StarTransactionTypeBotInvoiceSaleTypeID is TL type id of StarTransactionTypeBotInvoiceSale. +const StarTransactionTypeBotInvoiceSaleTypeID = 0x5b7d8d2f + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotInvoiceSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotInvoiceSale. +var ( + _ bin.Encoder = &StarTransactionTypeBotInvoiceSale{} + _ bin.Decoder = &StarTransactionTypeBotInvoiceSale{} + _ bin.BareEncoder = &StarTransactionTypeBotInvoiceSale{} + _ bin.BareDecoder = &StarTransactionTypeBotInvoiceSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotInvoiceSale{} +) + +func (s *StarTransactionTypeBotInvoiceSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.ProductInfo.Zero()) { + return false + } + if !(s.InvoicePayload == nil) { + return false + } + if !(s.Affiliate.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotInvoiceSale) String() string { + if s == nil { + return "StarTransactionTypeBotInvoiceSale(nil)" + } + type Alias StarTransactionTypeBotInvoiceSale + return fmt.Sprintf("StarTransactionTypeBotInvoiceSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotInvoiceSale) TypeID() uint32 { + return StarTransactionTypeBotInvoiceSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotInvoiceSale) TypeName() string { + return "starTransactionTypeBotInvoiceSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotInvoiceSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotInvoiceSale", + ID: StarTransactionTypeBotInvoiceSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "ProductInfo", + SchemaName: "product_info", + }, + { + Name: "InvoicePayload", + SchemaName: "invoice_payload", + }, + { + Name: "Affiliate", + SchemaName: "affiliate", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotInvoiceSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil") + } + b.PutID(StarTransactionTypeBotInvoiceSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotInvoiceSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil") + } + b.PutInt53(s.UserID) + if err := s.ProductInfo.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err) + } + b.PutBytes(s.InvoicePayload) + if err := s.Affiliate.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotInvoiceSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotInvoiceSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotInvoiceSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.ProductInfo.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err) + } + } + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field invoice_payload: %w", err) + } + s.InvoicePayload = value + } + { + if err := s.Affiliate.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotInvoiceSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotInvoiceSale#5b7d8d2f as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotInvoiceSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("product_info") + if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err) + } + b.Comma() + b.FieldStart("invoice_payload") + b.PutBytes(s.InvoicePayload) + b.Comma() + b.FieldStart("affiliate") + if err := s.Affiliate.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotInvoiceSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotInvoiceSale#5b7d8d2f to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotInvoiceSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field user_id: %w", err) + } + s.UserID = value + case "product_info": + if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field product_info: %w", err) + } + case "invoice_payload": + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field invoice_payload: %w", err) + } + s.InvoicePayload = value + case "affiliate": + if err := s.Affiliate.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotInvoiceSale#5b7d8d2f: field affiliate: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotInvoiceSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetProductInfo returns value of ProductInfo field. +func (s *StarTransactionTypeBotInvoiceSale) GetProductInfo() (value ProductInfo) { + if s == nil { + return + } + return s.ProductInfo +} + +// GetInvoicePayload returns value of InvoicePayload field. +func (s *StarTransactionTypeBotInvoiceSale) GetInvoicePayload() (value []byte) { + if s == nil { + return + } + return s.InvoicePayload +} + +// GetAffiliate returns value of Affiliate field. +func (s *StarTransactionTypeBotInvoiceSale) GetAffiliate() (value AffiliateInfo) { + if s == nil { + return + } + return s.Affiliate +} + +// StarTransactionTypeBotSubscriptionPurchase represents TL type `starTransactionTypeBotSubscriptionPurchase#40bf1355`. +type StarTransactionTypeBotSubscriptionPurchase struct { + // Identifier of the bot or the business account user that created the subscription link + UserID int64 + // The number of seconds between consecutive Telegram Star debitings + SubscriptionPeriod int32 + // Information about the bought subscription + ProductInfo ProductInfo +} + +// StarTransactionTypeBotSubscriptionPurchaseTypeID is TL type id of StarTransactionTypeBotSubscriptionPurchase. +const StarTransactionTypeBotSubscriptionPurchaseTypeID = 0x40bf1355 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotSubscriptionPurchase) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotSubscriptionPurchase. +var ( + _ bin.Encoder = &StarTransactionTypeBotSubscriptionPurchase{} + _ bin.Decoder = &StarTransactionTypeBotSubscriptionPurchase{} + _ bin.BareEncoder = &StarTransactionTypeBotSubscriptionPurchase{} + _ bin.BareDecoder = &StarTransactionTypeBotSubscriptionPurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotSubscriptionPurchase{} +) + +func (s *StarTransactionTypeBotSubscriptionPurchase) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.SubscriptionPeriod == 0) { + return false + } + if !(s.ProductInfo.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotSubscriptionPurchase) String() string { + if s == nil { + return "StarTransactionTypeBotSubscriptionPurchase(nil)" + } + type Alias StarTransactionTypeBotSubscriptionPurchase + return fmt.Sprintf("StarTransactionTypeBotSubscriptionPurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotSubscriptionPurchase) TypeID() uint32 { + return StarTransactionTypeBotSubscriptionPurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotSubscriptionPurchase) TypeName() string { + return "starTransactionTypeBotSubscriptionPurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotSubscriptionPurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotSubscriptionPurchase", + ID: StarTransactionTypeBotSubscriptionPurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "SubscriptionPeriod", + SchemaName: "subscription_period", + }, + { + Name: "ProductInfo", + SchemaName: "product_info", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil") + } + b.PutID(StarTransactionTypeBotSubscriptionPurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil") + } + b.PutInt53(s.UserID) + b.PutInt32(s.SubscriptionPeriod) + if err := s.ProductInfo.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotSubscriptionPurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + } + { + if err := s.ProductInfo.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionPurchase#40bf1355 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotSubscriptionPurchase") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("subscription_period") + b.PutInt32(s.SubscriptionPeriod) + b.Comma() + b.FieldStart("product_info") + if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotSubscriptionPurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionPurchase#40bf1355 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotSubscriptionPurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field user_id: %w", err) + } + s.UserID = value + case "subscription_period": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + case "product_info": + if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionPurchase#40bf1355: field product_info: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotSubscriptionPurchase) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetSubscriptionPeriod returns value of SubscriptionPeriod field. +func (s *StarTransactionTypeBotSubscriptionPurchase) GetSubscriptionPeriod() (value int32) { + if s == nil { + return + } + return s.SubscriptionPeriod +} + +// GetProductInfo returns value of ProductInfo field. +func (s *StarTransactionTypeBotSubscriptionPurchase) GetProductInfo() (value ProductInfo) { + if s == nil { + return + } + return s.ProductInfo +} + +// StarTransactionTypeBotSubscriptionSale represents TL type `starTransactionTypeBotSubscriptionSale#1f686889`. +type StarTransactionTypeBotSubscriptionSale struct { + // Identifier of the user that bought the subscription + UserID int64 + // The number of seconds between consecutive Telegram Star debitings + SubscriptionPeriod int32 + // Information about the bought subscription + ProductInfo ProductInfo + // Invoice payload + InvoicePayload []byte + // Information about the affiliate which received commission from the transaction; may be + // null if none + Affiliate AffiliateInfo +} + +// StarTransactionTypeBotSubscriptionSaleTypeID is TL type id of StarTransactionTypeBotSubscriptionSale. +const StarTransactionTypeBotSubscriptionSaleTypeID = 0x1f686889 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeBotSubscriptionSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeBotSubscriptionSale. +var ( + _ bin.Encoder = &StarTransactionTypeBotSubscriptionSale{} + _ bin.Decoder = &StarTransactionTypeBotSubscriptionSale{} + _ bin.BareEncoder = &StarTransactionTypeBotSubscriptionSale{} + _ bin.BareDecoder = &StarTransactionTypeBotSubscriptionSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeBotSubscriptionSale{} +) + +func (s *StarTransactionTypeBotSubscriptionSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.SubscriptionPeriod == 0) { + return false + } + if !(s.ProductInfo.Zero()) { + return false + } + if !(s.InvoicePayload == nil) { + return false + } + if !(s.Affiliate.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeBotSubscriptionSale) String() string { + if s == nil { + return "StarTransactionTypeBotSubscriptionSale(nil)" + } + type Alias StarTransactionTypeBotSubscriptionSale + return fmt.Sprintf("StarTransactionTypeBotSubscriptionSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeBotSubscriptionSale) TypeID() uint32 { + return StarTransactionTypeBotSubscriptionSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeBotSubscriptionSale) TypeName() string { + return "starTransactionTypeBotSubscriptionSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeBotSubscriptionSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeBotSubscriptionSale", + ID: StarTransactionTypeBotSubscriptionSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "SubscriptionPeriod", + SchemaName: "subscription_period", + }, + { + Name: "ProductInfo", + SchemaName: "product_info", + }, + { + Name: "InvoicePayload", + SchemaName: "invoice_payload", + }, + { + Name: "Affiliate", + SchemaName: "affiliate", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeBotSubscriptionSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil") + } + b.PutID(StarTransactionTypeBotSubscriptionSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeBotSubscriptionSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil") + } + b.PutInt53(s.UserID) + b.PutInt32(s.SubscriptionPeriod) + if err := s.ProductInfo.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err) + } + b.PutBytes(s.InvoicePayload) + if err := s.Affiliate.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeBotSubscriptionSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil") + } + if err := b.ConsumeID(StarTransactionTypeBotSubscriptionSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeBotSubscriptionSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + } + { + if err := s.ProductInfo.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err) + } + } + { + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field invoice_payload: %w", err) + } + s.InvoicePayload = value + } + { + if err := s.Affiliate.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeBotSubscriptionSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeBotSubscriptionSale#1f686889 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeBotSubscriptionSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("subscription_period") + b.PutInt32(s.SubscriptionPeriod) + b.Comma() + b.FieldStart("product_info") + if err := s.ProductInfo.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err) + } + b.Comma() + b.FieldStart("invoice_payload") + b.PutBytes(s.InvoicePayload) + b.Comma() + b.FieldStart("affiliate") + if err := s.Affiliate.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeBotSubscriptionSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeBotSubscriptionSale#1f686889 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeBotSubscriptionSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field user_id: %w", err) + } + s.UserID = value + case "subscription_period": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + case "product_info": + if err := s.ProductInfo.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field product_info: %w", err) + } + case "invoice_payload": + value, err := b.Bytes() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field invoice_payload: %w", err) + } + s.InvoicePayload = value + case "affiliate": + if err := s.Affiliate.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeBotSubscriptionSale#1f686889: field affiliate: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeBotSubscriptionSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetSubscriptionPeriod returns value of SubscriptionPeriod field. +func (s *StarTransactionTypeBotSubscriptionSale) GetSubscriptionPeriod() (value int32) { + if s == nil { + return + } + return s.SubscriptionPeriod +} + +// GetProductInfo returns value of ProductInfo field. +func (s *StarTransactionTypeBotSubscriptionSale) GetProductInfo() (value ProductInfo) { + if s == nil { + return + } + return s.ProductInfo +} + +// GetInvoicePayload returns value of InvoicePayload field. +func (s *StarTransactionTypeBotSubscriptionSale) GetInvoicePayload() (value []byte) { + if s == nil { + return + } + return s.InvoicePayload +} + +// GetAffiliate returns value of Affiliate field. +func (s *StarTransactionTypeBotSubscriptionSale) GetAffiliate() (value AffiliateInfo) { + if s == nil { + return + } + return s.Affiliate +} + +// StarTransactionTypeChannelSubscriptionPurchase represents TL type `starTransactionTypeChannelSubscriptionPurchase#380eb3d1`. +type StarTransactionTypeChannelSubscriptionPurchase struct { + // Identifier of the channel chat that created the subscription + ChatID int64 + // The number of seconds between consecutive Telegram Star debitings + SubscriptionPeriod int32 +} + +// StarTransactionTypeChannelSubscriptionPurchaseTypeID is TL type id of StarTransactionTypeChannelSubscriptionPurchase. +const StarTransactionTypeChannelSubscriptionPurchaseTypeID = 0x380eb3d1 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelSubscriptionPurchase) construct() StarTransactionTypeClass { + return &s +} + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelSubscriptionPurchase. +var ( + _ bin.Encoder = &StarTransactionTypeChannelSubscriptionPurchase{} + _ bin.Decoder = &StarTransactionTypeChannelSubscriptionPurchase{} + _ bin.BareEncoder = &StarTransactionTypeChannelSubscriptionPurchase{} + _ bin.BareDecoder = &StarTransactionTypeChannelSubscriptionPurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelSubscriptionPurchase{} +) + +func (s *StarTransactionTypeChannelSubscriptionPurchase) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.SubscriptionPeriod == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelSubscriptionPurchase) String() string { + if s == nil { + return "StarTransactionTypeChannelSubscriptionPurchase(nil)" + } + type Alias StarTransactionTypeChannelSubscriptionPurchase + return fmt.Sprintf("StarTransactionTypeChannelSubscriptionPurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelSubscriptionPurchase) TypeID() uint32 { + return StarTransactionTypeChannelSubscriptionPurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelSubscriptionPurchase) TypeName() string { + return "starTransactionTypeChannelSubscriptionPurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelSubscriptionPurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelSubscriptionPurchase", + ID: StarTransactionTypeChannelSubscriptionPurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "SubscriptionPeriod", + SchemaName: "subscription_period", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil") + } + b.PutID(StarTransactionTypeChannelSubscriptionPurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil") + } + b.PutInt53(s.ChatID) + b.PutInt32(s.SubscriptionPeriod) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelSubscriptionPurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelSubscriptionPurchase") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("subscription_period") + b.PutInt32(s.SubscriptionPeriod) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelSubscriptionPurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelSubscriptionPurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field chat_id: %w", err) + } + s.ChatID = value + case "subscription_period": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionPurchase#380eb3d1: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *StarTransactionTypeChannelSubscriptionPurchase) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetSubscriptionPeriod returns value of SubscriptionPeriod field. +func (s *StarTransactionTypeChannelSubscriptionPurchase) GetSubscriptionPeriod() (value int32) { + if s == nil { + return + } + return s.SubscriptionPeriod +} + +// StarTransactionTypeChannelSubscriptionSale represents TL type `starTransactionTypeChannelSubscriptionSale#fe127c82`. +type StarTransactionTypeChannelSubscriptionSale struct { + // Identifier of the user that bought the subscription + UserID int64 + // The number of seconds between consecutive Telegram Star debitings + SubscriptionPeriod int32 +} + +// StarTransactionTypeChannelSubscriptionSaleTypeID is TL type id of StarTransactionTypeChannelSubscriptionSale. +const StarTransactionTypeChannelSubscriptionSaleTypeID = 0xfe127c82 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelSubscriptionSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelSubscriptionSale. +var ( + _ bin.Encoder = &StarTransactionTypeChannelSubscriptionSale{} + _ bin.Decoder = &StarTransactionTypeChannelSubscriptionSale{} + _ bin.BareEncoder = &StarTransactionTypeChannelSubscriptionSale{} + _ bin.BareDecoder = &StarTransactionTypeChannelSubscriptionSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelSubscriptionSale{} +) + +func (s *StarTransactionTypeChannelSubscriptionSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.SubscriptionPeriod == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelSubscriptionSale) String() string { + if s == nil { + return "StarTransactionTypeChannelSubscriptionSale(nil)" + } + type Alias StarTransactionTypeChannelSubscriptionSale + return fmt.Sprintf("StarTransactionTypeChannelSubscriptionSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelSubscriptionSale) TypeID() uint32 { + return StarTransactionTypeChannelSubscriptionSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelSubscriptionSale) TypeName() string { + return "starTransactionTypeChannelSubscriptionSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelSubscriptionSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelSubscriptionSale", + ID: StarTransactionTypeChannelSubscriptionSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "SubscriptionPeriod", + SchemaName: "subscription_period", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelSubscriptionSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil") + } + b.PutID(StarTransactionTypeChannelSubscriptionSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelSubscriptionSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil") + } + b.PutInt53(s.UserID) + b.PutInt32(s.SubscriptionPeriod) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelSubscriptionSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelSubscriptionSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelSubscriptionSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelSubscriptionSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelSubscriptionSale#fe127c82 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelSubscriptionSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("subscription_period") + b.PutInt32(s.SubscriptionPeriod) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelSubscriptionSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelSubscriptionSale#fe127c82 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelSubscriptionSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field user_id: %w", err) + } + s.UserID = value + case "subscription_period": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelSubscriptionSale#fe127c82: field subscription_period: %w", err) + } + s.SubscriptionPeriod = value + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeChannelSubscriptionSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetSubscriptionPeriod returns value of SubscriptionPeriod field. +func (s *StarTransactionTypeChannelSubscriptionSale) GetSubscriptionPeriod() (value int32) { + if s == nil { + return + } + return s.SubscriptionPeriod +} + +// StarTransactionTypeGiftPurchase represents TL type `starTransactionTypeGiftPurchase#ef5f1d52`. +type StarTransactionTypeGiftPurchase struct { + // Identifier of the user that received the gift + UserID int64 + // The gift + Gift Gift +} + +// StarTransactionTypeGiftPurchaseTypeID is TL type id of StarTransactionTypeGiftPurchase. +const StarTransactionTypeGiftPurchaseTypeID = 0xef5f1d52 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeGiftPurchase) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeGiftPurchase. +var ( + _ bin.Encoder = &StarTransactionTypeGiftPurchase{} + _ bin.Decoder = &StarTransactionTypeGiftPurchase{} + _ bin.BareEncoder = &StarTransactionTypeGiftPurchase{} + _ bin.BareDecoder = &StarTransactionTypeGiftPurchase{} + + _ StarTransactionTypeClass = &StarTransactionTypeGiftPurchase{} +) + +func (s *StarTransactionTypeGiftPurchase) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.Gift.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeGiftPurchase) String() string { + if s == nil { + return "StarTransactionTypeGiftPurchase(nil)" + } + type Alias StarTransactionTypeGiftPurchase + return fmt.Sprintf("StarTransactionTypeGiftPurchase%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeGiftPurchase) TypeID() uint32 { + return StarTransactionTypeGiftPurchaseTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeGiftPurchase) TypeName() string { + return "starTransactionTypeGiftPurchase" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeGiftPurchase) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeGiftPurchase", + ID: StarTransactionTypeGiftPurchaseTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Gift", + SchemaName: "gift", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeGiftPurchase) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#ef5f1d52 as nil") + } + b.PutID(StarTransactionTypeGiftPurchaseTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeGiftPurchase) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#ef5f1d52 as nil") + } + b.PutInt53(s.UserID) + if err := s.Gift.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#ef5f1d52: field gift: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeGiftPurchase) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#ef5f1d52 to nil") + } + if err := b.ConsumeID(StarTransactionTypeGiftPurchaseTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeGiftPurchase) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#ef5f1d52 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.Gift.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: field gift: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeGiftPurchase) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftPurchase#ef5f1d52 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeGiftPurchase") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("gift") + if err := s.Gift.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeGiftPurchase#ef5f1d52: field gift: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeGiftPurchase) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftPurchase#ef5f1d52 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeGiftPurchase"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: field user_id: %w", err) + } + s.UserID = value + case "gift": + if err := s.Gift.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftPurchase#ef5f1d52: field gift: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeGiftPurchase) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetGift returns value of Gift field. +func (s *StarTransactionTypeGiftPurchase) GetGift() (value Gift) { + if s == nil { + return + } + return s.Gift +} + +// StarTransactionTypeGiftSale represents TL type `starTransactionTypeGiftSale#64d61157`. +type StarTransactionTypeGiftSale struct { + // Identifier of the user that sent the gift + UserID int64 + // The gift + Gift Gift +} + +// StarTransactionTypeGiftSaleTypeID is TL type id of StarTransactionTypeGiftSale. +const StarTransactionTypeGiftSaleTypeID = 0x64d61157 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeGiftSale) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeGiftSale. +var ( + _ bin.Encoder = &StarTransactionTypeGiftSale{} + _ bin.Decoder = &StarTransactionTypeGiftSale{} + _ bin.BareEncoder = &StarTransactionTypeGiftSale{} + _ bin.BareDecoder = &StarTransactionTypeGiftSale{} + + _ StarTransactionTypeClass = &StarTransactionTypeGiftSale{} +) + +func (s *StarTransactionTypeGiftSale) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.Gift.Zero()) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeGiftSale) String() string { + if s == nil { + return "StarTransactionTypeGiftSale(nil)" + } + type Alias StarTransactionTypeGiftSale + return fmt.Sprintf("StarTransactionTypeGiftSale%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeGiftSale) TypeID() uint32 { + return StarTransactionTypeGiftSaleTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeGiftSale) TypeName() string { + return "starTransactionTypeGiftSale" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeGiftSale) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeGiftSale", + ID: StarTransactionTypeGiftSaleTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "Gift", + SchemaName: "gift", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeGiftSale) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil") + } + b.PutID(StarTransactionTypeGiftSaleTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeGiftSale) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil") + } + b.PutInt53(s.UserID) + if err := s.Gift.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeGiftSale#64d61157: field gift: %w", err) + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeGiftSale) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil") + } + if err := b.ConsumeID(StarTransactionTypeGiftSaleTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeGiftSale) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field user_id: %w", err) + } + s.UserID = value + } + { + if err := s.Gift.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field gift: %w", err) + } + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeGiftSale) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeGiftSale#64d61157 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeGiftSale") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("gift") + if err := s.Gift.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactionTypeGiftSale#64d61157: field gift: %w", err) + } + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeGiftSale) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeGiftSale#64d61157 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeGiftSale"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field user_id: %w", err) + } + s.UserID = value + case "gift": + if err := s.Gift.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeGiftSale#64d61157: field gift: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeGiftSale) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetGift returns value of Gift field. +func (s *StarTransactionTypeGiftSale) GetGift() (value Gift) { + if s == nil { + return + } + return s.Gift +} + +// StarTransactionTypeChannelPaidReactionSend represents TL type `starTransactionTypeChannelPaidReactionSend#c02667c0`. +type StarTransactionTypeChannelPaidReactionSend struct { + // Identifier of the channel chat + ChatID int64 + // Identifier of the reacted message; can be 0 or an identifier of a deleted message + MessageID int64 +} + +// StarTransactionTypeChannelPaidReactionSendTypeID is TL type id of StarTransactionTypeChannelPaidReactionSend. +const StarTransactionTypeChannelPaidReactionSendTypeID = 0xc02667c0 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelPaidReactionSend) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelPaidReactionSend. +var ( + _ bin.Encoder = &StarTransactionTypeChannelPaidReactionSend{} + _ bin.Decoder = &StarTransactionTypeChannelPaidReactionSend{} + _ bin.BareEncoder = &StarTransactionTypeChannelPaidReactionSend{} + _ bin.BareDecoder = &StarTransactionTypeChannelPaidReactionSend{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelPaidReactionSend{} +) + +func (s *StarTransactionTypeChannelPaidReactionSend) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.MessageID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelPaidReactionSend) String() string { + if s == nil { + return "StarTransactionTypeChannelPaidReactionSend(nil)" + } + type Alias StarTransactionTypeChannelPaidReactionSend + return fmt.Sprintf("StarTransactionTypeChannelPaidReactionSend%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelPaidReactionSend) TypeID() uint32 { + return StarTransactionTypeChannelPaidReactionSendTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelPaidReactionSend) TypeName() string { + return "starTransactionTypeChannelPaidReactionSend" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelPaidReactionSend) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelPaidReactionSend", + ID: StarTransactionTypeChannelPaidReactionSendTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "MessageID", + SchemaName: "message_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelPaidReactionSend) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil") + } + b.PutID(StarTransactionTypeChannelPaidReactionSendTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelPaidReactionSend) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil") + } + b.PutInt53(s.ChatID) + b.PutInt53(s.MessageID) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelPaidReactionSend) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelPaidReactionSendTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelPaidReactionSend) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field message_id: %w", err) + } + s.MessageID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelPaidReactionSend) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionSend#c02667c0 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelPaidReactionSend") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("message_id") + b.PutInt53(s.MessageID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelPaidReactionSend) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionSend#c02667c0 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelPaidReactionSend"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field chat_id: %w", err) + } + s.ChatID = value + case "message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionSend#c02667c0: field message_id: %w", err) + } + s.MessageID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *StarTransactionTypeChannelPaidReactionSend) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetMessageID returns value of MessageID field. +func (s *StarTransactionTypeChannelPaidReactionSend) GetMessageID() (value int64) { + if s == nil { + return + } + return s.MessageID +} + +// StarTransactionTypeChannelPaidReactionReceive represents TL type `starTransactionTypeChannelPaidReactionReceive#23d6f9eb`. +type StarTransactionTypeChannelPaidReactionReceive struct { + // Identifier of the user that added the paid reaction + UserID int64 + // Identifier of the reacted message; can be 0 or an identifier of a deleted message + MessageID int64 +} + +// StarTransactionTypeChannelPaidReactionReceiveTypeID is TL type id of StarTransactionTypeChannelPaidReactionReceive. +const StarTransactionTypeChannelPaidReactionReceiveTypeID = 0x23d6f9eb + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeChannelPaidReactionReceive) construct() StarTransactionTypeClass { + return &s +} + +// Ensuring interfaces in compile-time for StarTransactionTypeChannelPaidReactionReceive. +var ( + _ bin.Encoder = &StarTransactionTypeChannelPaidReactionReceive{} + _ bin.Decoder = &StarTransactionTypeChannelPaidReactionReceive{} + _ bin.BareEncoder = &StarTransactionTypeChannelPaidReactionReceive{} + _ bin.BareDecoder = &StarTransactionTypeChannelPaidReactionReceive{} + + _ StarTransactionTypeClass = &StarTransactionTypeChannelPaidReactionReceive{} +) + +func (s *StarTransactionTypeChannelPaidReactionReceive) Zero() bool { + if s == nil { + return true + } + if !(s.UserID == 0) { + return false + } + if !(s.MessageID == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeChannelPaidReactionReceive) String() string { + if s == nil { + return "StarTransactionTypeChannelPaidReactionReceive(nil)" + } + type Alias StarTransactionTypeChannelPaidReactionReceive + return fmt.Sprintf("StarTransactionTypeChannelPaidReactionReceive%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeChannelPaidReactionReceive) TypeID() uint32 { + return StarTransactionTypeChannelPaidReactionReceiveTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeChannelPaidReactionReceive) TypeName() string { + return "starTransactionTypeChannelPaidReactionReceive" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeChannelPaidReactionReceive) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeChannelPaidReactionReceive", + ID: StarTransactionTypeChannelPaidReactionReceiveTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "UserID", + SchemaName: "user_id", + }, + { + Name: "MessageID", + SchemaName: "message_id", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil") + } + b.PutID(StarTransactionTypeChannelPaidReactionReceiveTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil") + } + b.PutInt53(s.UserID) + b.PutInt53(s.MessageID) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil") + } + if err := b.ConsumeID(StarTransactionTypeChannelPaidReactionReceiveTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field user_id: %w", err) + } + s.UserID = value + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field message_id: %w", err) + } + s.MessageID = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeChannelPaidReactionReceive#23d6f9eb as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeChannelPaidReactionReceive") + b.Comma() + b.FieldStart("user_id") + b.PutInt53(s.UserID) + b.Comma() + b.FieldStart("message_id") + b.PutInt53(s.MessageID) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeChannelPaidReactionReceive) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeChannelPaidReactionReceive"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: %w", err) + } + case "user_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field user_id: %w", err) + } + s.UserID = value + case "message_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeChannelPaidReactionReceive#23d6f9eb: field message_id: %w", err) + } + s.MessageID = value + default: + return b.Skip() + } + return nil + }) +} + +// GetUserID returns value of UserID field. +func (s *StarTransactionTypeChannelPaidReactionReceive) GetUserID() (value int64) { + if s == nil { + return + } + return s.UserID +} + +// GetMessageID returns value of MessageID field. +func (s *StarTransactionTypeChannelPaidReactionReceive) GetMessageID() (value int64) { + if s == nil { + return + } + return s.MessageID +} + +// StarTransactionTypeAffiliateProgramCommission represents TL type `starTransactionTypeAffiliateProgramCommission#9a637573`. +type StarTransactionTypeAffiliateProgramCommission struct { + // Identifier of the chat that created the affiliate program + ChatID int64 + // The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars + // received by the program owner + CommissionPerMille int32 +} + +// StarTransactionTypeAffiliateProgramCommissionTypeID is TL type id of StarTransactionTypeAffiliateProgramCommission. +const StarTransactionTypeAffiliateProgramCommissionTypeID = 0x9a637573 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeAffiliateProgramCommission) construct() StarTransactionTypeClass { + return &s +} + +// Ensuring interfaces in compile-time for StarTransactionTypeAffiliateProgramCommission. +var ( + _ bin.Encoder = &StarTransactionTypeAffiliateProgramCommission{} + _ bin.Decoder = &StarTransactionTypeAffiliateProgramCommission{} + _ bin.BareEncoder = &StarTransactionTypeAffiliateProgramCommission{} + _ bin.BareDecoder = &StarTransactionTypeAffiliateProgramCommission{} + + _ StarTransactionTypeClass = &StarTransactionTypeAffiliateProgramCommission{} +) + +func (s *StarTransactionTypeAffiliateProgramCommission) Zero() bool { + if s == nil { + return true + } + if !(s.ChatID == 0) { + return false + } + if !(s.CommissionPerMille == 0) { + return false + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeAffiliateProgramCommission) String() string { + if s == nil { + return "StarTransactionTypeAffiliateProgramCommission(nil)" + } + type Alias StarTransactionTypeAffiliateProgramCommission + return fmt.Sprintf("StarTransactionTypeAffiliateProgramCommission%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeAffiliateProgramCommission) TypeID() uint32 { + return StarTransactionTypeAffiliateProgramCommissionTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeAffiliateProgramCommission) TypeName() string { + return "starTransactionTypeAffiliateProgramCommission" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeAffiliateProgramCommission) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeAffiliateProgramCommission", + ID: StarTransactionTypeAffiliateProgramCommissionTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{ + { + Name: "ChatID", + SchemaName: "chat_id", + }, + { + Name: "CommissionPerMille", + SchemaName: "commission_per_mille", + }, + } + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeAffiliateProgramCommission) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil") + } + b.PutID(StarTransactionTypeAffiliateProgramCommissionTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeAffiliateProgramCommission) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil") + } + b.PutInt53(s.ChatID) + b.PutInt32(s.CommissionPerMille) + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeAffiliateProgramCommission) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil") + } + if err := b.ConsumeID(StarTransactionTypeAffiliateProgramCommissionTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeAffiliateProgramCommission) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil") + } + { + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field chat_id: %w", err) + } + s.ChatID = value + } + { + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field commission_per_mille: %w", err) + } + s.CommissionPerMille = value + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeAffiliateProgramCommission) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeAffiliateProgramCommission#9a637573 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeAffiliateProgramCommission") + b.Comma() + b.FieldStart("chat_id") + b.PutInt53(s.ChatID) + b.Comma() + b.FieldStart("commission_per_mille") + b.PutInt32(s.CommissionPerMille) + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeAffiliateProgramCommission) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeAffiliateProgramCommission#9a637573 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeAffiliateProgramCommission"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: %w", err) + } + case "chat_id": + value, err := b.Int53() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field chat_id: %w", err) + } + s.ChatID = value + case "commission_per_mille": + value, err := b.Int32() + if err != nil { + return fmt.Errorf("unable to decode starTransactionTypeAffiliateProgramCommission#9a637573: field commission_per_mille: %w", err) + } + s.CommissionPerMille = value + default: + return b.Skip() + } + return nil + }) +} + +// GetChatID returns value of ChatID field. +func (s *StarTransactionTypeAffiliateProgramCommission) GetChatID() (value int64) { + if s == nil { + return + } + return s.ChatID +} + +// GetCommissionPerMille returns value of CommissionPerMille field. +func (s *StarTransactionTypeAffiliateProgramCommission) GetCommissionPerMille() (value int32) { + if s == nil { + return + } + return s.CommissionPerMille +} + +// StarTransactionTypeUnsupported represents TL type `starTransactionTypeUnsupported#76cfcab2`. +type StarTransactionTypeUnsupported struct { +} + +// StarTransactionTypeUnsupportedTypeID is TL type id of StarTransactionTypeUnsupported. +const StarTransactionTypeUnsupportedTypeID = 0x76cfcab2 + +// construct implements constructor of StarTransactionTypeClass. +func (s StarTransactionTypeUnsupported) construct() StarTransactionTypeClass { return &s } + +// Ensuring interfaces in compile-time for StarTransactionTypeUnsupported. +var ( + _ bin.Encoder = &StarTransactionTypeUnsupported{} + _ bin.Decoder = &StarTransactionTypeUnsupported{} + _ bin.BareEncoder = &StarTransactionTypeUnsupported{} + _ bin.BareDecoder = &StarTransactionTypeUnsupported{} + + _ StarTransactionTypeClass = &StarTransactionTypeUnsupported{} +) + +func (s *StarTransactionTypeUnsupported) Zero() bool { + if s == nil { + return true + } + + return true +} + +// String implements fmt.Stringer. +func (s *StarTransactionTypeUnsupported) String() string { + if s == nil { + return "StarTransactionTypeUnsupported(nil)" + } + type Alias StarTransactionTypeUnsupported + return fmt.Sprintf("StarTransactionTypeUnsupported%+v", Alias(*s)) +} + +// TypeID returns type id in TL schema. +// +// See https://core.telegram.org/mtproto/TL-tl#remarks. +func (*StarTransactionTypeUnsupported) TypeID() uint32 { + return StarTransactionTypeUnsupportedTypeID +} + +// TypeName returns name of type in TL schema. +func (*StarTransactionTypeUnsupported) TypeName() string { + return "starTransactionTypeUnsupported" +} + +// TypeInfo returns info about TL type. +func (s *StarTransactionTypeUnsupported) TypeInfo() tdp.Type { + typ := tdp.Type{ + Name: "starTransactionTypeUnsupported", + ID: StarTransactionTypeUnsupportedTypeID, + } + if s == nil { + typ.Null = true + return typ + } + typ.Fields = []tdp.Field{} + return typ +} + +// Encode implements bin.Encoder. +func (s *StarTransactionTypeUnsupported) Encode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil") + } + b.PutID(StarTransactionTypeUnsupportedTypeID) + return s.EncodeBare(b) +} + +// EncodeBare implements bin.BareEncoder. +func (s *StarTransactionTypeUnsupported) EncodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil") + } + return nil +} + +// Decode implements bin.Decoder. +func (s *StarTransactionTypeUnsupported) Decode(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil") + } + if err := b.ConsumeID(StarTransactionTypeUnsupportedTypeID); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUnsupported#76cfcab2: %w", err) + } + return s.DecodeBare(b) +} + +// DecodeBare implements bin.BareDecoder. +func (s *StarTransactionTypeUnsupported) DecodeBare(b *bin.Buffer) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil") + } + return nil +} + +// EncodeTDLibJSON implements tdjson.TDLibEncoder. +func (s *StarTransactionTypeUnsupported) EncodeTDLibJSON(b tdjson.Encoder) error { + if s == nil { + return fmt.Errorf("can't encode starTransactionTypeUnsupported#76cfcab2 as nil") + } + b.ObjStart() + b.PutID("starTransactionTypeUnsupported") + b.Comma() + b.StripComma() + b.ObjEnd() + return nil +} + +// DecodeTDLibJSON implements tdjson.TDLibDecoder. +func (s *StarTransactionTypeUnsupported) DecodeTDLibJSON(b tdjson.Decoder) error { + if s == nil { + return fmt.Errorf("can't decode starTransactionTypeUnsupported#76cfcab2 to nil") + } + + return b.Obj(func(b tdjson.Decoder, key []byte) error { + switch string(key) { + case tdjson.TypeField: + if err := b.ConsumeID("starTransactionTypeUnsupported"); err != nil { + return fmt.Errorf("unable to decode starTransactionTypeUnsupported#76cfcab2: %w", err) + } + default: + return b.Skip() + } + return nil + }) +} + +// StarTransactionTypeClassName is schema name of StarTransactionTypeClass. +const StarTransactionTypeClassName = "StarTransactionType" + +// StarTransactionTypeClass represents StarTransactionType generic type. +// +// Example: +// +// g, err := tdapi.DecodeStarTransactionType(buf) +// if err != nil { +// panic(err) +// } +// switch v := g.(type) { +// case *tdapi.StarTransactionTypePremiumBotDeposit: // starTransactionTypePremiumBotDeposit#d879090e +// case *tdapi.StarTransactionTypeAppStoreDeposit: // starTransactionTypeAppStoreDeposit#8283941 +// case *tdapi.StarTransactionTypeGooglePlayDeposit: // starTransactionTypeGooglePlayDeposit#ecbdb656 +// case *tdapi.StarTransactionTypeFragmentDeposit: // starTransactionTypeFragmentDeposit#7625e44 +// case *tdapi.StarTransactionTypeUserDeposit: // starTransactionTypeUserDeposit#c2a18e9 +// case *tdapi.StarTransactionTypeGiveawayDeposit: // starTransactionTypeGiveawayDeposit#b16200c6 +// case *tdapi.StarTransactionTypeFragmentWithdrawal: // starTransactionTypeFragmentWithdrawal#af3a2992 +// case *tdapi.StarTransactionTypeTelegramAdsWithdrawal: // starTransactionTypeTelegramAdsWithdrawal#a58e8469 +// case *tdapi.StarTransactionTypeTelegramAPIUsage: // starTransactionTypeTelegramApiUsage#27a82afe +// case *tdapi.StarTransactionTypeBotPaidMediaPurchase: // starTransactionTypeBotPaidMediaPurchase#7f48cc6a +// case *tdapi.StarTransactionTypeBotPaidMediaSale: // starTransactionTypeBotPaidMediaSale#6e07eeb2 +// case *tdapi.StarTransactionTypeChannelPaidMediaPurchase: // starTransactionTypeChannelPaidMediaPurchase#9016d4f5 +// case *tdapi.StarTransactionTypeChannelPaidMediaSale: // starTransactionTypeChannelPaidMediaSale#eace92ef +// case *tdapi.StarTransactionTypeBotInvoicePurchase: // starTransactionTypeBotInvoicePurchase#1dddac0c +// case *tdapi.StarTransactionTypeBotInvoiceSale: // starTransactionTypeBotInvoiceSale#5b7d8d2f +// case *tdapi.StarTransactionTypeBotSubscriptionPurchase: // starTransactionTypeBotSubscriptionPurchase#40bf1355 +// case *tdapi.StarTransactionTypeBotSubscriptionSale: // starTransactionTypeBotSubscriptionSale#1f686889 +// case *tdapi.StarTransactionTypeChannelSubscriptionPurchase: // starTransactionTypeChannelSubscriptionPurchase#380eb3d1 +// case *tdapi.StarTransactionTypeChannelSubscriptionSale: // starTransactionTypeChannelSubscriptionSale#fe127c82 +// case *tdapi.StarTransactionTypeGiftPurchase: // starTransactionTypeGiftPurchase#ef5f1d52 +// case *tdapi.StarTransactionTypeGiftSale: // starTransactionTypeGiftSale#64d61157 +// case *tdapi.StarTransactionTypeChannelPaidReactionSend: // starTransactionTypeChannelPaidReactionSend#c02667c0 +// case *tdapi.StarTransactionTypeChannelPaidReactionReceive: // starTransactionTypeChannelPaidReactionReceive#23d6f9eb +// case *tdapi.StarTransactionTypeAffiliateProgramCommission: // starTransactionTypeAffiliateProgramCommission#9a637573 +// case *tdapi.StarTransactionTypeUnsupported: // starTransactionTypeUnsupported#76cfcab2 +// default: panic(v) +// } +type StarTransactionTypeClass interface { + bin.Encoder + bin.Decoder + bin.BareEncoder + bin.BareDecoder + construct() StarTransactionTypeClass + + // TypeID returns type id in TL schema. + // + // See https://core.telegram.org/mtproto/TL-tl#remarks. + TypeID() uint32 + // TypeName returns name of type in TL schema. + TypeName() string + // String implements fmt.Stringer. + String() string + // Zero returns true if current object has a zero value. + Zero() bool + + EncodeTDLibJSON(b tdjson.Encoder) error + DecodeTDLibJSON(b tdjson.Decoder) error +} + +// DecodeStarTransactionType implements binary de-serialization for StarTransactionTypeClass. +func DecodeStarTransactionType(buf *bin.Buffer) (StarTransactionTypeClass, error) { + id, err := buf.PeekID() + if err != nil { + return nil, err + } + switch id { + case StarTransactionTypePremiumBotDepositTypeID: + // Decoding starTransactionTypePremiumBotDeposit#d879090e. + v := StarTransactionTypePremiumBotDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeAppStoreDepositTypeID: + // Decoding starTransactionTypeAppStoreDeposit#8283941. + v := StarTransactionTypeAppStoreDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeGooglePlayDepositTypeID: + // Decoding starTransactionTypeGooglePlayDeposit#ecbdb656. + v := StarTransactionTypeGooglePlayDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeFragmentDepositTypeID: + // Decoding starTransactionTypeFragmentDeposit#7625e44. + v := StarTransactionTypeFragmentDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeUserDepositTypeID: + // Decoding starTransactionTypeUserDeposit#c2a18e9. + v := StarTransactionTypeUserDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeGiveawayDepositTypeID: + // Decoding starTransactionTypeGiveawayDeposit#b16200c6. + v := StarTransactionTypeGiveawayDeposit{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeFragmentWithdrawalTypeID: + // Decoding starTransactionTypeFragmentWithdrawal#af3a2992. + v := StarTransactionTypeFragmentWithdrawal{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeTelegramAdsWithdrawalTypeID: + // Decoding starTransactionTypeTelegramAdsWithdrawal#a58e8469. + v := StarTransactionTypeTelegramAdsWithdrawal{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeTelegramAPIUsageTypeID: + // Decoding starTransactionTypeTelegramApiUsage#27a82afe. + v := StarTransactionTypeTelegramAPIUsage{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotPaidMediaPurchaseTypeID: + // Decoding starTransactionTypeBotPaidMediaPurchase#7f48cc6a. + v := StarTransactionTypeBotPaidMediaPurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotPaidMediaSaleTypeID: + // Decoding starTransactionTypeBotPaidMediaSale#6e07eeb2. + v := StarTransactionTypeBotPaidMediaSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelPaidMediaPurchaseTypeID: + // Decoding starTransactionTypeChannelPaidMediaPurchase#9016d4f5. + v := StarTransactionTypeChannelPaidMediaPurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelPaidMediaSaleTypeID: + // Decoding starTransactionTypeChannelPaidMediaSale#eace92ef. + v := StarTransactionTypeChannelPaidMediaSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotInvoicePurchaseTypeID: + // Decoding starTransactionTypeBotInvoicePurchase#1dddac0c. + v := StarTransactionTypeBotInvoicePurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotInvoiceSaleTypeID: + // Decoding starTransactionTypeBotInvoiceSale#5b7d8d2f. + v := StarTransactionTypeBotInvoiceSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotSubscriptionPurchaseTypeID: + // Decoding starTransactionTypeBotSubscriptionPurchase#40bf1355. + v := StarTransactionTypeBotSubscriptionPurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeBotSubscriptionSaleTypeID: + // Decoding starTransactionTypeBotSubscriptionSale#1f686889. + v := StarTransactionTypeBotSubscriptionSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelSubscriptionPurchaseTypeID: + // Decoding starTransactionTypeChannelSubscriptionPurchase#380eb3d1. + v := StarTransactionTypeChannelSubscriptionPurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelSubscriptionSaleTypeID: + // Decoding starTransactionTypeChannelSubscriptionSale#fe127c82. + v := StarTransactionTypeChannelSubscriptionSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeGiftPurchaseTypeID: + // Decoding starTransactionTypeGiftPurchase#ef5f1d52. + v := StarTransactionTypeGiftPurchase{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeGiftSaleTypeID: + // Decoding starTransactionTypeGiftSale#64d61157. + v := StarTransactionTypeGiftSale{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelPaidReactionSendTypeID: + // Decoding starTransactionTypeChannelPaidReactionSend#c02667c0. + v := StarTransactionTypeChannelPaidReactionSend{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeChannelPaidReactionReceiveTypeID: + // Decoding starTransactionTypeChannelPaidReactionReceive#23d6f9eb. + v := StarTransactionTypeChannelPaidReactionReceive{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeAffiliateProgramCommissionTypeID: + // Decoding starTransactionTypeAffiliateProgramCommission#9a637573. + v := StarTransactionTypeAffiliateProgramCommission{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case StarTransactionTypeUnsupportedTypeID: + // Decoding starTransactionTypeUnsupported#76cfcab2. + v := StarTransactionTypeUnsupported{} + if err := v.Decode(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", bin.NewUnexpectedID(id)) + } +} + +// DecodeTDLibJSONStarTransactionType implements binary de-serialization for StarTransactionTypeClass. +func DecodeTDLibJSONStarTransactionType(buf tdjson.Decoder) (StarTransactionTypeClass, error) { + id, err := buf.FindTypeID() + if err != nil { + return nil, err + } + switch id { + case "starTransactionTypePremiumBotDeposit": + // Decoding starTransactionTypePremiumBotDeposit#d879090e. + v := StarTransactionTypePremiumBotDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeAppStoreDeposit": + // Decoding starTransactionTypeAppStoreDeposit#8283941. + v := StarTransactionTypeAppStoreDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeGooglePlayDeposit": + // Decoding starTransactionTypeGooglePlayDeposit#ecbdb656. + v := StarTransactionTypeGooglePlayDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeFragmentDeposit": + // Decoding starTransactionTypeFragmentDeposit#7625e44. + v := StarTransactionTypeFragmentDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeUserDeposit": + // Decoding starTransactionTypeUserDeposit#c2a18e9. + v := StarTransactionTypeUserDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeGiveawayDeposit": + // Decoding starTransactionTypeGiveawayDeposit#b16200c6. + v := StarTransactionTypeGiveawayDeposit{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeFragmentWithdrawal": + // Decoding starTransactionTypeFragmentWithdrawal#af3a2992. + v := StarTransactionTypeFragmentWithdrawal{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeTelegramAdsWithdrawal": + // Decoding starTransactionTypeTelegramAdsWithdrawal#a58e8469. + v := StarTransactionTypeTelegramAdsWithdrawal{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeTelegramApiUsage": + // Decoding starTransactionTypeTelegramApiUsage#27a82afe. + v := StarTransactionTypeTelegramAPIUsage{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotPaidMediaPurchase": + // Decoding starTransactionTypeBotPaidMediaPurchase#7f48cc6a. + v := StarTransactionTypeBotPaidMediaPurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotPaidMediaSale": + // Decoding starTransactionTypeBotPaidMediaSale#6e07eeb2. + v := StarTransactionTypeBotPaidMediaSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelPaidMediaPurchase": + // Decoding starTransactionTypeChannelPaidMediaPurchase#9016d4f5. + v := StarTransactionTypeChannelPaidMediaPurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelPaidMediaSale": + // Decoding starTransactionTypeChannelPaidMediaSale#eace92ef. + v := StarTransactionTypeChannelPaidMediaSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotInvoicePurchase": + // Decoding starTransactionTypeBotInvoicePurchase#1dddac0c. + v := StarTransactionTypeBotInvoicePurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotInvoiceSale": + // Decoding starTransactionTypeBotInvoiceSale#5b7d8d2f. + v := StarTransactionTypeBotInvoiceSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotSubscriptionPurchase": + // Decoding starTransactionTypeBotSubscriptionPurchase#40bf1355. + v := StarTransactionTypeBotSubscriptionPurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeBotSubscriptionSale": + // Decoding starTransactionTypeBotSubscriptionSale#1f686889. + v := StarTransactionTypeBotSubscriptionSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelSubscriptionPurchase": + // Decoding starTransactionTypeChannelSubscriptionPurchase#380eb3d1. + v := StarTransactionTypeChannelSubscriptionPurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelSubscriptionSale": + // Decoding starTransactionTypeChannelSubscriptionSale#fe127c82. + v := StarTransactionTypeChannelSubscriptionSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeGiftPurchase": + // Decoding starTransactionTypeGiftPurchase#ef5f1d52. + v := StarTransactionTypeGiftPurchase{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeGiftSale": + // Decoding starTransactionTypeGiftSale#64d61157. + v := StarTransactionTypeGiftSale{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelPaidReactionSend": + // Decoding starTransactionTypeChannelPaidReactionSend#c02667c0. + v := StarTransactionTypeChannelPaidReactionSend{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeChannelPaidReactionReceive": + // Decoding starTransactionTypeChannelPaidReactionReceive#23d6f9eb. + v := StarTransactionTypeChannelPaidReactionReceive{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeAffiliateProgramCommission": + // Decoding starTransactionTypeAffiliateProgramCommission#9a637573. + v := StarTransactionTypeAffiliateProgramCommission{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + case "starTransactionTypeUnsupported": + // Decoding starTransactionTypeUnsupported#76cfcab2. + v := StarTransactionTypeUnsupported{} + if err := v.DecodeTDLibJSON(buf); err != nil { + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", err) + } + return &v, nil + default: + return nil, fmt.Errorf("unable to decode StarTransactionTypeClass: %w", tdjson.NewUnexpectedID(id)) + } +} + +// StarTransactionType boxes the StarTransactionTypeClass providing a helper. +type StarTransactionTypeBox struct { + StarTransactionType StarTransactionTypeClass +} + +// Decode implements bin.Decoder for StarTransactionTypeBox. +func (b *StarTransactionTypeBox) Decode(buf *bin.Buffer) error { + if b == nil { + return fmt.Errorf("unable to decode StarTransactionTypeBox to nil") + } + v, err := DecodeStarTransactionType(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.StarTransactionType = v + return nil +} + +// Encode implements bin.Encode for StarTransactionTypeBox. +func (b *StarTransactionTypeBox) Encode(buf *bin.Buffer) error { + if b == nil || b.StarTransactionType == nil { + return fmt.Errorf("unable to encode StarTransactionTypeClass as nil") + } + return b.StarTransactionType.Encode(buf) +} + +// DecodeTDLibJSON implements bin.Decoder for StarTransactionTypeBox. +func (b *StarTransactionTypeBox) DecodeTDLibJSON(buf tdjson.Decoder) error { + if b == nil { + return fmt.Errorf("unable to decode StarTransactionTypeBox to nil") + } + v, err := DecodeTDLibJSONStarTransactionType(buf) + if err != nil { + return fmt.Errorf("unable to decode boxed value: %w", err) + } + b.StarTransactionType = v + return nil +} + +// EncodeTDLibJSON implements bin.Encode for StarTransactionTypeBox. +func (b *StarTransactionTypeBox) EncodeTDLibJSON(buf tdjson.Encoder) error { + if b == nil || b.StarTransactionType == nil { + return fmt.Errorf("unable to encode StarTransactionTypeClass as nil") + } + return b.StarTransactionType.EncodeTDLibJSON(buf) +} diff --git a/tdapi/tl_star_transactions_gen.go b/tdapi/tl_star_transactions_gen.go index abc135536f..79d265adf1 100644 --- a/tdapi/tl_star_transactions_gen.go +++ b/tdapi/tl_star_transactions_gen.go @@ -31,10 +31,10 @@ var ( _ = tdjson.Encoder{} ) -// StarTransactions represents TL type `starTransactions#306a010e`. +// StarTransactions represents TL type `starTransactions#b5f5820b`. type StarTransactions struct { // The amount of owned Telegram Stars - StarCount int64 + StarAmount StarAmount // List of transactions with Telegram Stars Transactions []StarTransaction // The offset for the next request. If empty, then there are no more results @@ -42,7 +42,7 @@ type StarTransactions struct { } // StarTransactionsTypeID is TL type id of StarTransactions. -const StarTransactionsTypeID = 0x306a010e +const StarTransactionsTypeID = 0xb5f5820b // Ensuring interfaces in compile-time for StarTransactions. var ( @@ -56,7 +56,7 @@ func (s *StarTransactions) Zero() bool { if s == nil { return true } - if !(s.StarCount == 0) { + if !(s.StarAmount.Zero()) { return false } if !(s.Transactions == nil) { @@ -102,8 +102,8 @@ func (s *StarTransactions) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "StarCount", - SchemaName: "star_count", + Name: "StarAmount", + SchemaName: "star_amount", }, { Name: "Transactions", @@ -120,7 +120,7 @@ func (s *StarTransactions) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (s *StarTransactions) Encode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starTransactions#306a010e as nil") + return fmt.Errorf("can't encode starTransactions#b5f5820b as nil") } b.PutID(StarTransactionsTypeID) return s.EncodeBare(b) @@ -129,13 +129,15 @@ func (s *StarTransactions) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (s *StarTransactions) EncodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't encode starTransactions#306a010e as nil") + return fmt.Errorf("can't encode starTransactions#b5f5820b as nil") + } + if err := s.StarAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode starTransactions#b5f5820b: field star_amount: %w", err) } - b.PutInt53(s.StarCount) b.PutInt(len(s.Transactions)) for idx, v := range s.Transactions { if err := v.EncodeBare(b); err != nil { - return fmt.Errorf("unable to encode bare starTransactions#306a010e: field transactions element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode bare starTransactions#b5f5820b: field transactions element with index %d: %w", idx, err) } } b.PutString(s.NextOffset) @@ -145,10 +147,10 @@ func (s *StarTransactions) EncodeBare(b *bin.Buffer) error { // Decode implements bin.Decoder. func (s *StarTransactions) Decode(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starTransactions#306a010e to nil") + return fmt.Errorf("can't decode starTransactions#b5f5820b to nil") } if err := b.ConsumeID(StarTransactionsTypeID); err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: %w", err) } return s.DecodeBare(b) } @@ -156,19 +158,17 @@ func (s *StarTransactions) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (s *StarTransactions) DecodeBare(b *bin.Buffer) error { if s == nil { - return fmt.Errorf("can't decode starTransactions#306a010e to nil") + return fmt.Errorf("can't decode starTransactions#b5f5820b to nil") } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field star_count: %w", err) + if err := s.StarAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field star_amount: %w", err) } - s.StarCount = value } { headerLen, err := b.Int() if err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field transactions: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field transactions: %w", err) } if headerLen > 0 { @@ -177,7 +177,7 @@ func (s *StarTransactions) DecodeBare(b *bin.Buffer) error { for idx := 0; idx < headerLen; idx++ { var value StarTransaction if err := value.DecodeBare(b); err != nil { - return fmt.Errorf("unable to decode bare starTransactions#306a010e: field transactions: %w", err) + return fmt.Errorf("unable to decode bare starTransactions#b5f5820b: field transactions: %w", err) } s.Transactions = append(s.Transactions, value) } @@ -185,7 +185,7 @@ func (s *StarTransactions) DecodeBare(b *bin.Buffer) error { { value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field next_offset: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field next_offset: %w", err) } s.NextOffset = value } @@ -195,19 +195,21 @@ func (s *StarTransactions) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StarTransactions) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { - return fmt.Errorf("can't encode starTransactions#306a010e as nil") + return fmt.Errorf("can't encode starTransactions#b5f5820b as nil") } b.ObjStart() b.PutID("starTransactions") b.Comma() - b.FieldStart("star_count") - b.PutInt53(s.StarCount) + b.FieldStart("star_amount") + if err := s.StarAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode starTransactions#b5f5820b: field star_amount: %w", err) + } b.Comma() b.FieldStart("transactions") b.ArrStart() for idx, v := range s.Transactions { if err := v.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode starTransactions#306a010e: field transactions element with index %d: %w", idx, err) + return fmt.Errorf("unable to encode starTransactions#b5f5820b: field transactions element with index %d: %w", idx, err) } b.Comma() } @@ -225,36 +227,34 @@ func (s *StarTransactions) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StarTransactions) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { - return fmt.Errorf("can't decode starTransactions#306a010e to nil") + return fmt.Errorf("can't decode starTransactions#b5f5820b to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("starTransactions"); err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: %w", err) } - case "star_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field star_count: %w", err) + case "star_amount": + if err := s.StarAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field star_amount: %w", err) } - s.StarCount = value case "transactions": if err := b.Arr(func(b tdjson.Decoder) error { var value StarTransaction if err := value.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field transactions: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field transactions: %w", err) } s.Transactions = append(s.Transactions, value) return nil }); err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field transactions: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field transactions: %w", err) } case "next_offset": value, err := b.String() if err != nil { - return fmt.Errorf("unable to decode starTransactions#306a010e: field next_offset: %w", err) + return fmt.Errorf("unable to decode starTransactions#b5f5820b: field next_offset: %w", err) } s.NextOffset = value default: @@ -264,12 +264,12 @@ func (s *StarTransactions) DecodeTDLibJSON(b tdjson.Decoder) error { }) } -// GetStarCount returns value of StarCount field. -func (s *StarTransactions) GetStarCount() (value int64) { +// GetStarAmount returns value of StarAmount field. +func (s *StarTransactions) GetStarAmount() (value StarAmount) { if s == nil { return } - return s.StarCount + return s.StarAmount } // GetTransactions returns value of Transactions field. diff --git a/tdapi/tl_update_gen.go b/tdapi/tl_update_gen.go index c004d2a6ae..9a3cae24fe 100644 --- a/tdapi/tl_update_gen.go +++ b/tdapi/tl_update_gen.go @@ -25052,14 +25052,14 @@ func (u *UpdateActiveLiveLocationMessages) GetMessages() (value []Message) { return u.Messages } -// UpdateOwnedStarCount represents TL type `updateOwnedStarCount#de995b79`. +// UpdateOwnedStarCount represents TL type `updateOwnedStarCount#af7ebf88`. type UpdateOwnedStarCount struct { - // The new number of Telegram Stars owned - StarCount int64 + // The new amount of owned Telegram Stars + StarAmount StarAmount } // UpdateOwnedStarCountTypeID is TL type id of UpdateOwnedStarCount. -const UpdateOwnedStarCountTypeID = 0xde995b79 +const UpdateOwnedStarCountTypeID = 0xaf7ebf88 // construct implements constructor of UpdateClass. func (u UpdateOwnedStarCount) construct() UpdateClass { return &u } @@ -25078,7 +25078,7 @@ func (u *UpdateOwnedStarCount) Zero() bool { if u == nil { return true } - if !(u.StarCount == 0) { + if !(u.StarAmount.Zero()) { return false } @@ -25118,8 +25118,8 @@ func (u *UpdateOwnedStarCount) TypeInfo() tdp.Type { } typ.Fields = []tdp.Field{ { - Name: "StarCount", - SchemaName: "star_count", + Name: "StarAmount", + SchemaName: "star_amount", }, } return typ @@ -25128,7 +25128,7 @@ func (u *UpdateOwnedStarCount) TypeInfo() tdp.Type { // Encode implements bin.Encoder. func (u *UpdateOwnedStarCount) Encode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateOwnedStarCount#de995b79 as nil") + return fmt.Errorf("can't encode updateOwnedStarCount#af7ebf88 as nil") } b.PutID(UpdateOwnedStarCountTypeID) return u.EncodeBare(b) @@ -25137,19 +25137,21 @@ func (u *UpdateOwnedStarCount) Encode(b *bin.Buffer) error { // EncodeBare implements bin.BareEncoder. func (u *UpdateOwnedStarCount) EncodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't encode updateOwnedStarCount#de995b79 as nil") + return fmt.Errorf("can't encode updateOwnedStarCount#af7ebf88 as nil") + } + if err := u.StarAmount.Encode(b); err != nil { + return fmt.Errorf("unable to encode updateOwnedStarCount#af7ebf88: field star_amount: %w", err) } - b.PutInt53(u.StarCount) return nil } // Decode implements bin.Decoder. func (u *UpdateOwnedStarCount) Decode(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateOwnedStarCount#de995b79 to nil") + return fmt.Errorf("can't decode updateOwnedStarCount#af7ebf88 to nil") } if err := b.ConsumeID(UpdateOwnedStarCountTypeID); err != nil { - return fmt.Errorf("unable to decode updateOwnedStarCount#de995b79: %w", err) + return fmt.Errorf("unable to decode updateOwnedStarCount#af7ebf88: %w", err) } return u.DecodeBare(b) } @@ -25157,14 +25159,12 @@ func (u *UpdateOwnedStarCount) Decode(b *bin.Buffer) error { // DecodeBare implements bin.BareDecoder. func (u *UpdateOwnedStarCount) DecodeBare(b *bin.Buffer) error { if u == nil { - return fmt.Errorf("can't decode updateOwnedStarCount#de995b79 to nil") + return fmt.Errorf("can't decode updateOwnedStarCount#af7ebf88 to nil") } { - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode updateOwnedStarCount#de995b79: field star_count: %w", err) + if err := u.StarAmount.Decode(b); err != nil { + return fmt.Errorf("unable to decode updateOwnedStarCount#af7ebf88: field star_amount: %w", err) } - u.StarCount = value } return nil } @@ -25172,13 +25172,15 @@ func (u *UpdateOwnedStarCount) DecodeBare(b *bin.Buffer) error { // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (u *UpdateOwnedStarCount) EncodeTDLibJSON(b tdjson.Encoder) error { if u == nil { - return fmt.Errorf("can't encode updateOwnedStarCount#de995b79 as nil") + return fmt.Errorf("can't encode updateOwnedStarCount#af7ebf88 as nil") } b.ObjStart() b.PutID("updateOwnedStarCount") b.Comma() - b.FieldStart("star_count") - b.PutInt53(u.StarCount) + b.FieldStart("star_amount") + if err := u.StarAmount.EncodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to encode updateOwnedStarCount#af7ebf88: field star_amount: %w", err) + } b.Comma() b.StripComma() b.ObjEnd() @@ -25188,21 +25190,19 @@ func (u *UpdateOwnedStarCount) EncodeTDLibJSON(b tdjson.Encoder) error { // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (u *UpdateOwnedStarCount) DecodeTDLibJSON(b tdjson.Decoder) error { if u == nil { - return fmt.Errorf("can't decode updateOwnedStarCount#de995b79 to nil") + return fmt.Errorf("can't decode updateOwnedStarCount#af7ebf88 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("updateOwnedStarCount"); err != nil { - return fmt.Errorf("unable to decode updateOwnedStarCount#de995b79: %w", err) + return fmt.Errorf("unable to decode updateOwnedStarCount#af7ebf88: %w", err) } - case "star_count": - value, err := b.Int53() - if err != nil { - return fmt.Errorf("unable to decode updateOwnedStarCount#de995b79: field star_count: %w", err) + case "star_amount": + if err := u.StarAmount.DecodeTDLibJSON(b); err != nil { + return fmt.Errorf("unable to decode updateOwnedStarCount#af7ebf88: field star_amount: %w", err) } - u.StarCount = value default: return b.Skip() } @@ -25210,12 +25210,12 @@ func (u *UpdateOwnedStarCount) DecodeTDLibJSON(b tdjson.Decoder) error { }) } -// GetStarCount returns value of StarCount field. -func (u *UpdateOwnedStarCount) GetStarCount() (value int64) { +// GetStarAmount returns value of StarAmount field. +func (u *UpdateOwnedStarCount) GetStarAmount() (value StarAmount) { if u == nil { return } - return u.StarCount + return u.StarAmount } // UpdateChatRevenueAmount represents TL type `updateChatRevenueAmount#c6c9bcc4`. @@ -33246,7 +33246,7 @@ const UpdateClassName = "Update" // case *tdapi.UpdateDefaultReactionType: // updateDefaultReactionType#4b615105 // case *tdapi.UpdateSavedMessagesTags: // updateSavedMessagesTags#7386424a // case *tdapi.UpdateActiveLiveLocationMessages: // updateActiveLiveLocationMessages#a20b9b1f -// case *tdapi.UpdateOwnedStarCount: // updateOwnedStarCount#de995b79 +// case *tdapi.UpdateOwnedStarCount: // updateOwnedStarCount#af7ebf88 // case *tdapi.UpdateChatRevenueAmount: // updateChatRevenueAmount#c6c9bcc4 // case *tdapi.UpdateStarRevenueStatus: // updateStarRevenueStatus#ef4bfccb // case *tdapi.UpdateSpeechRecognitionTrial: // updateSpeechRecognitionTrial#ff4efcc1 @@ -34143,7 +34143,7 @@ func DecodeUpdate(buf *bin.Buffer) (UpdateClass, error) { } return &v, nil case UpdateOwnedStarCountTypeID: - // Decoding updateOwnedStarCount#de995b79. + // Decoding updateOwnedStarCount#af7ebf88. v := UpdateOwnedStarCount{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) @@ -35212,7 +35212,7 @@ func DecodeTDLibJSONUpdate(buf tdjson.Decoder) (UpdateClass, error) { } return &v, nil case "updateOwnedStarCount": - // Decoding updateOwnedStarCount#de995b79. + // Decoding updateOwnedStarCount#af7ebf88. v := UpdateOwnedStarCount{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode UpdateClass: %w", err) diff --git a/tdapi/tl_user_transaction_purpose_gen.go b/tdapi/tl_user_transaction_purpose_gen.go deleted file mode 100644 index 15b9ad4bd2..0000000000 --- a/tdapi/tl_user_transaction_purpose_gen.go +++ /dev/null @@ -1,682 +0,0 @@ -// Code generated by gotdgen, DO NOT EDIT. - -package tdapi - -import ( - "context" - "errors" - "fmt" - "sort" - "strings" - - "go.uber.org/multierr" - - "github.com/gotd/td/bin" - "github.com/gotd/td/tdjson" - "github.com/gotd/td/tdp" - "github.com/gotd/td/tgerr" -) - -// No-op definition for keeping imports. -var ( - _ = bin.Buffer{} - _ = context.Background() - _ = fmt.Stringer(nil) - _ = strings.Builder{} - _ = errors.Is - _ = multierr.AppendInto - _ = sort.Ints - _ = tdp.Format - _ = tgerr.Error{} - _ = tdjson.Encoder{} -) - -// UserTransactionPurposeGiftedStars represents TL type `userTransactionPurposeGiftedStars#1fb3401`. -type UserTransactionPurposeGiftedStars struct { - // A sticker to be shown in the transaction information; may be null if unknown - Sticker Sticker -} - -// UserTransactionPurposeGiftedStarsTypeID is TL type id of UserTransactionPurposeGiftedStars. -const UserTransactionPurposeGiftedStarsTypeID = 0x1fb3401 - -// construct implements constructor of UserTransactionPurposeClass. -func (u UserTransactionPurposeGiftedStars) construct() UserTransactionPurposeClass { return &u } - -// Ensuring interfaces in compile-time for UserTransactionPurposeGiftedStars. -var ( - _ bin.Encoder = &UserTransactionPurposeGiftedStars{} - _ bin.Decoder = &UserTransactionPurposeGiftedStars{} - _ bin.BareEncoder = &UserTransactionPurposeGiftedStars{} - _ bin.BareDecoder = &UserTransactionPurposeGiftedStars{} - - _ UserTransactionPurposeClass = &UserTransactionPurposeGiftedStars{} -) - -func (u *UserTransactionPurposeGiftedStars) Zero() bool { - if u == nil { - return true - } - if !(u.Sticker.Zero()) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (u *UserTransactionPurposeGiftedStars) String() string { - if u == nil { - return "UserTransactionPurposeGiftedStars(nil)" - } - type Alias UserTransactionPurposeGiftedStars - return fmt.Sprintf("UserTransactionPurposeGiftedStars%+v", Alias(*u)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*UserTransactionPurposeGiftedStars) TypeID() uint32 { - return UserTransactionPurposeGiftedStarsTypeID -} - -// TypeName returns name of type in TL schema. -func (*UserTransactionPurposeGiftedStars) TypeName() string { - return "userTransactionPurposeGiftedStars" -} - -// TypeInfo returns info about TL type. -func (u *UserTransactionPurposeGiftedStars) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "userTransactionPurposeGiftedStars", - ID: UserTransactionPurposeGiftedStarsTypeID, - } - if u == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Sticker", - SchemaName: "sticker", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (u *UserTransactionPurposeGiftedStars) Encode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftedStars#1fb3401 as nil") - } - b.PutID(UserTransactionPurposeGiftedStarsTypeID) - return u.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (u *UserTransactionPurposeGiftedStars) EncodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftedStars#1fb3401 as nil") - } - if err := u.Sticker.Encode(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftedStars#1fb3401: field sticker: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (u *UserTransactionPurposeGiftedStars) Decode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftedStars#1fb3401 to nil") - } - if err := b.ConsumeID(UserTransactionPurposeGiftedStarsTypeID); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftedStars#1fb3401: %w", err) - } - return u.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (u *UserTransactionPurposeGiftedStars) DecodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftedStars#1fb3401 to nil") - } - { - if err := u.Sticker.Decode(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftedStars#1fb3401: field sticker: %w", err) - } - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (u *UserTransactionPurposeGiftedStars) EncodeTDLibJSON(b tdjson.Encoder) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftedStars#1fb3401 as nil") - } - b.ObjStart() - b.PutID("userTransactionPurposeGiftedStars") - b.Comma() - b.FieldStart("sticker") - if err := u.Sticker.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftedStars#1fb3401: field sticker: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (u *UserTransactionPurposeGiftedStars) DecodeTDLibJSON(b tdjson.Decoder) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftedStars#1fb3401 to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("userTransactionPurposeGiftedStars"); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftedStars#1fb3401: %w", err) - } - case "sticker": - if err := u.Sticker.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftedStars#1fb3401: field sticker: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// GetSticker returns value of Sticker field. -func (u *UserTransactionPurposeGiftedStars) GetSticker() (value Sticker) { - if u == nil { - return - } - return u.Sticker -} - -// UserTransactionPurposeGiftSell represents TL type `userTransactionPurposeGiftSell#195fcd8e`. -type UserTransactionPurposeGiftSell struct { - // The gift - Gift Gift -} - -// UserTransactionPurposeGiftSellTypeID is TL type id of UserTransactionPurposeGiftSell. -const UserTransactionPurposeGiftSellTypeID = 0x195fcd8e - -// construct implements constructor of UserTransactionPurposeClass. -func (u UserTransactionPurposeGiftSell) construct() UserTransactionPurposeClass { return &u } - -// Ensuring interfaces in compile-time for UserTransactionPurposeGiftSell. -var ( - _ bin.Encoder = &UserTransactionPurposeGiftSell{} - _ bin.Decoder = &UserTransactionPurposeGiftSell{} - _ bin.BareEncoder = &UserTransactionPurposeGiftSell{} - _ bin.BareDecoder = &UserTransactionPurposeGiftSell{} - - _ UserTransactionPurposeClass = &UserTransactionPurposeGiftSell{} -) - -func (u *UserTransactionPurposeGiftSell) Zero() bool { - if u == nil { - return true - } - if !(u.Gift.Zero()) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (u *UserTransactionPurposeGiftSell) String() string { - if u == nil { - return "UserTransactionPurposeGiftSell(nil)" - } - type Alias UserTransactionPurposeGiftSell - return fmt.Sprintf("UserTransactionPurposeGiftSell%+v", Alias(*u)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*UserTransactionPurposeGiftSell) TypeID() uint32 { - return UserTransactionPurposeGiftSellTypeID -} - -// TypeName returns name of type in TL schema. -func (*UserTransactionPurposeGiftSell) TypeName() string { - return "userTransactionPurposeGiftSell" -} - -// TypeInfo returns info about TL type. -func (u *UserTransactionPurposeGiftSell) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "userTransactionPurposeGiftSell", - ID: UserTransactionPurposeGiftSellTypeID, - } - if u == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Gift", - SchemaName: "gift", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (u *UserTransactionPurposeGiftSell) Encode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSell#195fcd8e as nil") - } - b.PutID(UserTransactionPurposeGiftSellTypeID) - return u.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (u *UserTransactionPurposeGiftSell) EncodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSell#195fcd8e as nil") - } - if err := u.Gift.Encode(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftSell#195fcd8e: field gift: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (u *UserTransactionPurposeGiftSell) Decode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSell#195fcd8e to nil") - } - if err := b.ConsumeID(UserTransactionPurposeGiftSellTypeID); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSell#195fcd8e: %w", err) - } - return u.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (u *UserTransactionPurposeGiftSell) DecodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSell#195fcd8e to nil") - } - { - if err := u.Gift.Decode(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSell#195fcd8e: field gift: %w", err) - } - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (u *UserTransactionPurposeGiftSell) EncodeTDLibJSON(b tdjson.Encoder) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSell#195fcd8e as nil") - } - b.ObjStart() - b.PutID("userTransactionPurposeGiftSell") - b.Comma() - b.FieldStart("gift") - if err := u.Gift.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftSell#195fcd8e: field gift: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (u *UserTransactionPurposeGiftSell) DecodeTDLibJSON(b tdjson.Decoder) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSell#195fcd8e to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("userTransactionPurposeGiftSell"); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSell#195fcd8e: %w", err) - } - case "gift": - if err := u.Gift.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSell#195fcd8e: field gift: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// GetGift returns value of Gift field. -func (u *UserTransactionPurposeGiftSell) GetGift() (value Gift) { - if u == nil { - return - } - return u.Gift -} - -// UserTransactionPurposeGiftSend represents TL type `userTransactionPurposeGiftSend#b36e54df`. -type UserTransactionPurposeGiftSend struct { - // The gift - Gift Gift -} - -// UserTransactionPurposeGiftSendTypeID is TL type id of UserTransactionPurposeGiftSend. -const UserTransactionPurposeGiftSendTypeID = 0xb36e54df - -// construct implements constructor of UserTransactionPurposeClass. -func (u UserTransactionPurposeGiftSend) construct() UserTransactionPurposeClass { return &u } - -// Ensuring interfaces in compile-time for UserTransactionPurposeGiftSend. -var ( - _ bin.Encoder = &UserTransactionPurposeGiftSend{} - _ bin.Decoder = &UserTransactionPurposeGiftSend{} - _ bin.BareEncoder = &UserTransactionPurposeGiftSend{} - _ bin.BareDecoder = &UserTransactionPurposeGiftSend{} - - _ UserTransactionPurposeClass = &UserTransactionPurposeGiftSend{} -) - -func (u *UserTransactionPurposeGiftSend) Zero() bool { - if u == nil { - return true - } - if !(u.Gift.Zero()) { - return false - } - - return true -} - -// String implements fmt.Stringer. -func (u *UserTransactionPurposeGiftSend) String() string { - if u == nil { - return "UserTransactionPurposeGiftSend(nil)" - } - type Alias UserTransactionPurposeGiftSend - return fmt.Sprintf("UserTransactionPurposeGiftSend%+v", Alias(*u)) -} - -// TypeID returns type id in TL schema. -// -// See https://core.telegram.org/mtproto/TL-tl#remarks. -func (*UserTransactionPurposeGiftSend) TypeID() uint32 { - return UserTransactionPurposeGiftSendTypeID -} - -// TypeName returns name of type in TL schema. -func (*UserTransactionPurposeGiftSend) TypeName() string { - return "userTransactionPurposeGiftSend" -} - -// TypeInfo returns info about TL type. -func (u *UserTransactionPurposeGiftSend) TypeInfo() tdp.Type { - typ := tdp.Type{ - Name: "userTransactionPurposeGiftSend", - ID: UserTransactionPurposeGiftSendTypeID, - } - if u == nil { - typ.Null = true - return typ - } - typ.Fields = []tdp.Field{ - { - Name: "Gift", - SchemaName: "gift", - }, - } - return typ -} - -// Encode implements bin.Encoder. -func (u *UserTransactionPurposeGiftSend) Encode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSend#b36e54df as nil") - } - b.PutID(UserTransactionPurposeGiftSendTypeID) - return u.EncodeBare(b) -} - -// EncodeBare implements bin.BareEncoder. -func (u *UserTransactionPurposeGiftSend) EncodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSend#b36e54df as nil") - } - if err := u.Gift.Encode(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftSend#b36e54df: field gift: %w", err) - } - return nil -} - -// Decode implements bin.Decoder. -func (u *UserTransactionPurposeGiftSend) Decode(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSend#b36e54df to nil") - } - if err := b.ConsumeID(UserTransactionPurposeGiftSendTypeID); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSend#b36e54df: %w", err) - } - return u.DecodeBare(b) -} - -// DecodeBare implements bin.BareDecoder. -func (u *UserTransactionPurposeGiftSend) DecodeBare(b *bin.Buffer) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSend#b36e54df to nil") - } - { - if err := u.Gift.Decode(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSend#b36e54df: field gift: %w", err) - } - } - return nil -} - -// EncodeTDLibJSON implements tdjson.TDLibEncoder. -func (u *UserTransactionPurposeGiftSend) EncodeTDLibJSON(b tdjson.Encoder) error { - if u == nil { - return fmt.Errorf("can't encode userTransactionPurposeGiftSend#b36e54df as nil") - } - b.ObjStart() - b.PutID("userTransactionPurposeGiftSend") - b.Comma() - b.FieldStart("gift") - if err := u.Gift.EncodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to encode userTransactionPurposeGiftSend#b36e54df: field gift: %w", err) - } - b.Comma() - b.StripComma() - b.ObjEnd() - return nil -} - -// DecodeTDLibJSON implements tdjson.TDLibDecoder. -func (u *UserTransactionPurposeGiftSend) DecodeTDLibJSON(b tdjson.Decoder) error { - if u == nil { - return fmt.Errorf("can't decode userTransactionPurposeGiftSend#b36e54df to nil") - } - - return b.Obj(func(b tdjson.Decoder, key []byte) error { - switch string(key) { - case tdjson.TypeField: - if err := b.ConsumeID("userTransactionPurposeGiftSend"); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSend#b36e54df: %w", err) - } - case "gift": - if err := u.Gift.DecodeTDLibJSON(b); err != nil { - return fmt.Errorf("unable to decode userTransactionPurposeGiftSend#b36e54df: field gift: %w", err) - } - default: - return b.Skip() - } - return nil - }) -} - -// GetGift returns value of Gift field. -func (u *UserTransactionPurposeGiftSend) GetGift() (value Gift) { - if u == nil { - return - } - return u.Gift -} - -// UserTransactionPurposeClassName is schema name of UserTransactionPurposeClass. -const UserTransactionPurposeClassName = "UserTransactionPurpose" - -// UserTransactionPurposeClass represents UserTransactionPurpose generic type. -// -// Example: -// -// g, err := tdapi.DecodeUserTransactionPurpose(buf) -// if err != nil { -// panic(err) -// } -// switch v := g.(type) { -// case *tdapi.UserTransactionPurposeGiftedStars: // userTransactionPurposeGiftedStars#1fb3401 -// case *tdapi.UserTransactionPurposeGiftSell: // userTransactionPurposeGiftSell#195fcd8e -// case *tdapi.UserTransactionPurposeGiftSend: // userTransactionPurposeGiftSend#b36e54df -// default: panic(v) -// } -type UserTransactionPurposeClass interface { - bin.Encoder - bin.Decoder - bin.BareEncoder - bin.BareDecoder - construct() UserTransactionPurposeClass - - // TypeID returns type id in TL schema. - // - // See https://core.telegram.org/mtproto/TL-tl#remarks. - TypeID() uint32 - // TypeName returns name of type in TL schema. - TypeName() string - // String implements fmt.Stringer. - String() string - // Zero returns true if current object has a zero value. - Zero() bool - - EncodeTDLibJSON(b tdjson.Encoder) error - DecodeTDLibJSON(b tdjson.Decoder) error -} - -// DecodeUserTransactionPurpose implements binary de-serialization for UserTransactionPurposeClass. -func DecodeUserTransactionPurpose(buf *bin.Buffer) (UserTransactionPurposeClass, error) { - id, err := buf.PeekID() - if err != nil { - return nil, err - } - switch id { - case UserTransactionPurposeGiftedStarsTypeID: - // Decoding userTransactionPurposeGiftedStars#1fb3401. - v := UserTransactionPurposeGiftedStars{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - case UserTransactionPurposeGiftSellTypeID: - // Decoding userTransactionPurposeGiftSell#195fcd8e. - v := UserTransactionPurposeGiftSell{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - case UserTransactionPurposeGiftSendTypeID: - // Decoding userTransactionPurposeGiftSend#b36e54df. - v := UserTransactionPurposeGiftSend{} - if err := v.Decode(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", bin.NewUnexpectedID(id)) - } -} - -// DecodeTDLibJSONUserTransactionPurpose implements binary de-serialization for UserTransactionPurposeClass. -func DecodeTDLibJSONUserTransactionPurpose(buf tdjson.Decoder) (UserTransactionPurposeClass, error) { - id, err := buf.FindTypeID() - if err != nil { - return nil, err - } - switch id { - case "userTransactionPurposeGiftedStars": - // Decoding userTransactionPurposeGiftedStars#1fb3401. - v := UserTransactionPurposeGiftedStars{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - case "userTransactionPurposeGiftSell": - // Decoding userTransactionPurposeGiftSell#195fcd8e. - v := UserTransactionPurposeGiftSell{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - case "userTransactionPurposeGiftSend": - // Decoding userTransactionPurposeGiftSend#b36e54df. - v := UserTransactionPurposeGiftSend{} - if err := v.DecodeTDLibJSON(buf); err != nil { - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", err) - } - return &v, nil - default: - return nil, fmt.Errorf("unable to decode UserTransactionPurposeClass: %w", tdjson.NewUnexpectedID(id)) - } -} - -// UserTransactionPurpose boxes the UserTransactionPurposeClass providing a helper. -type UserTransactionPurposeBox struct { - UserTransactionPurpose UserTransactionPurposeClass -} - -// Decode implements bin.Decoder for UserTransactionPurposeBox. -func (b *UserTransactionPurposeBox) Decode(buf *bin.Buffer) error { - if b == nil { - return fmt.Errorf("unable to decode UserTransactionPurposeBox to nil") - } - v, err := DecodeUserTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.UserTransactionPurpose = v - return nil -} - -// Encode implements bin.Encode for UserTransactionPurposeBox. -func (b *UserTransactionPurposeBox) Encode(buf *bin.Buffer) error { - if b == nil || b.UserTransactionPurpose == nil { - return fmt.Errorf("unable to encode UserTransactionPurposeClass as nil") - } - return b.UserTransactionPurpose.Encode(buf) -} - -// DecodeTDLibJSON implements bin.Decoder for UserTransactionPurposeBox. -func (b *UserTransactionPurposeBox) DecodeTDLibJSON(buf tdjson.Decoder) error { - if b == nil { - return fmt.Errorf("unable to decode UserTransactionPurposeBox to nil") - } - v, err := DecodeTDLibJSONUserTransactionPurpose(buf) - if err != nil { - return fmt.Errorf("unable to decode boxed value: %w", err) - } - b.UserTransactionPurpose = v - return nil -} - -// EncodeTDLibJSON implements bin.Encode for UserTransactionPurposeBox. -func (b *UserTransactionPurposeBox) EncodeTDLibJSON(buf tdjson.Encoder) error { - if b == nil || b.UserTransactionPurpose == nil { - return fmt.Errorf("unable to encode UserTransactionPurposeClass as nil") - } - return b.UserTransactionPurpose.EncodeTDLibJSON(buf) -}