// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// 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{}
)

// StarsTransaction represents TL type `starsTransaction#13659eb0`.
// Represents a Telegram Stars or TON transaction »¹.
//
// Links:
//  1. https://core.telegram.org/api/stars
//
// See https://core.telegram.org/constructor/starsTransaction for reference.
type StarsTransaction struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this transaction is a refund.
	Refund bool
	// The transaction is currently pending.
	Pending bool
	// This transaction has failed.
	Failed bool
	// This transaction was a gift from the user in peer.peer.
	Gift bool
	// This transaction is a paid reaction »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/reactions#paid-reactions
	Reaction bool
	// This transaction pays for the upgrade of a gift to a collectible gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	StargiftUpgrade bool
	// This transaction transfers stars from the balance of a user account connected to a
	// business bot¹, to the balance of the business bot, see here »² for more info.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/connected-business-bots
	//  2) https://core.telegram.org/api/stars#transferring-stars-from-a-business-account-to-the-business-bot
	BusinessTransfer bool
	// This transaction is related to the resale of a collectible gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#reselling-collectible-gifts
	StargiftResale bool
	// Represents payment for a paid global post search »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/search#posts-tab
	PostsSearch bool
	// Represents payment for a separate prepaid upgrade of a gift¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#prepaying-for-someone-elses-upgrade
	StargiftPrepaidUpgrade bool
	// Represents payment for the removal of the starGiftAttributeOriginalDetails¹ attribute
	// from a gift, see here »² for the full flow.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGiftAttributeOriginalDetails
	//  2) https://core.telegram.org/api/gifts#dropping-the-original-details-of-an-upgraded-gift
	StargiftDropOriginalDetails bool
	// PhonegroupMessage field of StarsTransaction.
	PhonegroupMessage bool
	// Represents payment for placing a collectible gift auction bid »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/auctions
	StargiftAuctionBid bool
	// Represents payment for a collectible gift purchase offer »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
	Offer bool
	// Transaction ID.
	ID string
	// Amount of Telegram Stars or TON.
	Amount StarsAmountClass
	// Date of the transaction (unixtime).
	Date int
	// Source of the incoming transaction, or its recipient for outgoing transactions.
	Peer StarsTransactionPeerClass
	// For transactions with bots, title of the bought product.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// For transactions with bots, description of the bought product.
	//
	// Use SetDescription and GetDescription helpers.
	Description string
	// For transactions with bots, photo of the bought product.
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo WebDocumentClass
	// If neither pending nor failed are set, the transaction was completed successfully, and
	// this field will contain the point in time (Unix timestamp) when the withdrawal was
	// completed successfully.
	//
	// Use SetTransactionDate and GetTransactionDate helpers.
	TransactionDate int
	// If neither pending nor failed are set, the transaction was completed successfully, and
	// this field will contain a URL where the withdrawal transaction can be viewed.
	//
	// Use SetTransactionURL and GetTransactionURL helpers.
	TransactionURL string
	// Bot specified invoice payload (i.e. the payload passed to inputMediaInvoice¹ when
	// creating the invoice²).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputMediaInvoice
	//  2) https://core.telegram.org/api/payments
	//
	// Use SetBotPayload and GetBotPayload helpers.
	BotPayload []byte
	// For paid media transactions »¹, message ID of the paid media posted to peer.peer
	// (can point to a deleted message; either way, extended_media will always contain the
	// bought media).
	//
	// Links:
	//  1) https://core.telegram.org/api/paid-media
	//
	// Use SetMsgID and GetMsgID helpers.
	MsgID int
	// The purchased paid media »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/paid-media
	//
	// Use SetExtendedMedia and GetExtendedMedia helpers.
	ExtendedMedia []MessageMediaClass
	// The number of seconds between consecutive Telegram Star debiting for Telegram Star
	// subscriptions »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-subscriptions
	//
	// Use SetSubscriptionPeriod and GetSubscriptionPeriod helpers.
	SubscriptionPeriod int
	// ID of the message containing the messageMediaGiveaway¹, for incoming star giveaway
	// prizes².
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageMediaGiveaway
	//  2) https://core.telegram.org/api/giveaways#star-giveaways
	//
	// Use SetGiveawayPostID and GetGiveawayPostID helpers.
	GiveawayPostID int
	// This transaction indicates a purchase or a sale (conversion back to Stars) of a gift
	// »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	//
	// Use SetStargift and GetStargift helpers.
	Stargift StarGiftClass
	// This transaction is payment for paid bot broadcasts¹.  Paid broadcasts are only
	// allowed if the allow_paid_floodskip parameter of messages.sendMessage² and other
	// message sending methods is set while trying to broadcast more than 30 messages per
	// second to bot users. The integer value returned by this flag indicates the number of
	// billed API calls.
	//
	// Links:
	//  1) https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once
	//  2) https://core.telegram.org/method/messages.sendMessage
	//
	// Use SetFloodskipNumber and GetFloodskipNumber helpers.
	FloodskipNumber int
	// This transaction is the receival (or refund) of an affiliate commission¹ (i.e. this
	// is the transaction received by the peer that created the referral link², flag 17 is
	// for transactions made by users that imported the referral link).
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/referrals
	//  2) https://core.telegram.org/api/links#referral-links
	//
	// Use SetStarrefCommissionPermille and GetStarrefCommissionPermille helpers.
	StarrefCommissionPermille int
	// For transactions made by referred users¹, the peer that received the affiliate
	// commission.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/referrals
	//
	// Use SetStarrefPeer and GetStarrefPeer helpers.
	StarrefPeer PeerClass
	// For transactions made by referred users¹, the amount of Telegram Stars received by
	// the affiliate, can be negative for refunds.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/referrals
	//
	// Use SetStarrefAmount and GetStarrefAmount helpers.
	StarrefAmount StarsAmountClass
	// This transaction is related to the reception or transmission of a paid message »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/paid-messages
	//
	// Use SetPaidMessages and GetPaidMessages helpers.
	PaidMessages int
	// This transaction indicates the payment for a gifted Telegram Premium subscription »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium#gifting-telegram-premium
	//
	// Use SetPremiumGiftMonths and GetPremiumGiftMonths helpers.
	PremiumGiftMonths int
	// Indicates that this is payment for ad revenue from the specified unixtime (always set
	// together with ads_proceeds_to_date).
	//
	// Use SetAdsProceedsFromDate and GetAdsProceedsFromDate helpers.
	AdsProceedsFromDate int
	// Indicates that this is payment for ad revenue to the specified unixtime.
	//
	// Use SetAdsProceedsToDate and GetAdsProceedsToDate helpers.
	AdsProceedsToDate int
}

// StarsTransactionTypeID is TL type id of StarsTransaction.
const StarsTransactionTypeID = 0x13659eb0

// Ensuring interfaces in compile-time for StarsTransaction.
var (
	_ bin.Encoder     = &StarsTransaction{}
	_ bin.Decoder     = &StarsTransaction{}
	_ bin.BareEncoder = &StarsTransaction{}
	_ bin.BareDecoder = &StarsTransaction{}
)

func ( *StarsTransaction) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Refund == false) {
		return false
	}
	if !(.Pending == false) {
		return false
	}
	if !(.Failed == false) {
		return false
	}
	if !(.Gift == false) {
		return false
	}
	if !(.Reaction == false) {
		return false
	}
	if !(.StargiftUpgrade == false) {
		return false
	}
	if !(.BusinessTransfer == false) {
		return false
	}
	if !(.StargiftResale == false) {
		return false
	}
	if !(.PostsSearch == false) {
		return false
	}
	if !(.StargiftPrepaidUpgrade == false) {
		return false
	}
	if !(.StargiftDropOriginalDetails == false) {
		return false
	}
	if !(.PhonegroupMessage == false) {
		return false
	}
	if !(.StargiftAuctionBid == false) {
		return false
	}
	if !(.Offer == false) {
		return false
	}
	if !(.ID == "") {
		return false
	}
	if !(.Amount == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.TransactionDate == 0) {
		return false
	}
	if !(.TransactionURL == "") {
		return false
	}
	if !(.BotPayload == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.ExtendedMedia == nil) {
		return false
	}
	if !(.SubscriptionPeriod == 0) {
		return false
	}
	if !(.GiveawayPostID == 0) {
		return false
	}
	if !(.Stargift == nil) {
		return false
	}
	if !(.FloodskipNumber == 0) {
		return false
	}
	if !(.StarrefCommissionPermille == 0) {
		return false
	}
	if !(.StarrefPeer == nil) {
		return false
	}
	if !(.StarrefAmount == nil) {
		return false
	}
	if !(.PaidMessages == 0) {
		return false
	}
	if !(.PremiumGiftMonths == 0) {
		return false
	}
	if !(.AdsProceedsFromDate == 0) {
		return false
	}
	if !(.AdsProceedsToDate == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *StarsTransaction) () string {
	if  == nil {
		return "StarsTransaction(nil)"
	}
	type  StarsTransaction
	return fmt.Sprintf("StarsTransaction%+v", (*))
}

// FillFrom fills StarsTransaction from given interface.
func ( *StarsTransaction) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string)
	() ( StarsAmountClass)
	() ( int)
	() ( StarsTransactionPeerClass)
	() ( string,  bool)
	() ( string,  bool)
	() ( WebDocumentClass,  bool)
	() ( int,  bool)
	() ( string,  bool)
	() ( []byte,  bool)
	() ( int,  bool)
	() ( []MessageMediaClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( StarGiftClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( PeerClass,  bool)
	() ( StarsAmountClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.Refund = .()
	.Pending = .()
	.Failed = .()
	.Gift = .()
	.Reaction = .()
	.StargiftUpgrade = .()
	.BusinessTransfer = .()
	.StargiftResale = .()
	.PostsSearch = .()
	.StargiftPrepaidUpgrade = .()
	.StargiftDropOriginalDetails = .()
	.PhonegroupMessage = .()
	.StargiftAuctionBid = .()
	.Offer = .()
	.ID = .()
	.Amount = .()
	.Date = .()
	.Peer = .()
	if ,  := .();  {
		.Title = 
	}

	if ,  := .();  {
		.Description = 
	}

	if ,  := .();  {
		.Photo = 
	}

	if ,  := .();  {
		.TransactionDate = 
	}

	if ,  := .();  {
		.TransactionURL = 
	}

	if ,  := .();  {
		.BotPayload = 
	}

	if ,  := .();  {
		.MsgID = 
	}

	if ,  := .();  {
		.ExtendedMedia = 
	}

	if ,  := .();  {
		.SubscriptionPeriod = 
	}

	if ,  := .();  {
		.GiveawayPostID = 
	}

	if ,  := .();  {
		.Stargift = 
	}

	if ,  := .();  {
		.FloodskipNumber = 
	}

	if ,  := .();  {
		.StarrefCommissionPermille = 
	}

	if ,  := .();  {
		.StarrefPeer = 
	}

	if ,  := .();  {
		.StarrefAmount = 
	}

	if ,  := .();  {
		.PaidMessages = 
	}

	if ,  := .();  {
		.PremiumGiftMonths = 
	}

	if ,  := .();  {
		.AdsProceedsFromDate = 
	}

	if ,  := .();  {
		.AdsProceedsToDate = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StarsTransaction) () uint32 {
	return StarsTransactionTypeID
}

// TypeName returns name of type in TL schema.
func (*StarsTransaction) () string {
	return "starsTransaction"
}

// TypeInfo returns info about TL type.
func ( *StarsTransaction) () tdp.Type {
	 := tdp.Type{
		Name: "starsTransaction",
		ID:   StarsTransactionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Refund",
			SchemaName: "refund",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Pending",
			SchemaName: "pending",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Failed",
			SchemaName: "failed",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "StargiftUpgrade",
			SchemaName: "stargift_upgrade",
			Null:       !.Flags.Has(18),
		},
		{
			Name:       "BusinessTransfer",
			SchemaName: "business_transfer",
			Null:       !.Flags.Has(21),
		},
		{
			Name:       "StargiftResale",
			SchemaName: "stargift_resale",
			Null:       !.Flags.Has(22),
		},
		{
			Name:       "PostsSearch",
			SchemaName: "posts_search",
			Null:       !.Flags.Has(24),
		},
		{
			Name:       "StargiftPrepaidUpgrade",
			SchemaName: "stargift_prepaid_upgrade",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "StargiftDropOriginalDetails",
			SchemaName: "stargift_drop_original_details",
			Null:       !.Flags.Has(26),
		},
		{
			Name:       "PhonegroupMessage",
			SchemaName: "phonegroup_message",
			Null:       !.Flags.Has(27),
		},
		{
			Name:       "StargiftAuctionBid",
			SchemaName: "stargift_auction_bid",
			Null:       !.Flags.Has(28),
		},
		{
			Name:       "Offer",
			SchemaName: "offer",
			Null:       !.Flags.Has(29),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Description",
			SchemaName: "description",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "TransactionDate",
			SchemaName: "transaction_date",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "TransactionURL",
			SchemaName: "transaction_url",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "BotPayload",
			SchemaName: "bot_payload",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ExtendedMedia",
			SchemaName: "extended_media",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "SubscriptionPeriod",
			SchemaName: "subscription_period",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "GiveawayPostID",
			SchemaName: "giveaway_post_id",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "Stargift",
			SchemaName: "stargift",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "FloodskipNumber",
			SchemaName: "floodskip_number",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "StarrefCommissionPermille",
			SchemaName: "starref_commission_permille",
			Null:       !.Flags.Has(16),
		},
		{
			Name:       "StarrefPeer",
			SchemaName: "starref_peer",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "StarrefAmount",
			SchemaName: "starref_amount",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "PaidMessages",
			SchemaName: "paid_messages",
			Null:       !.Flags.Has(19),
		},
		{
			Name:       "PremiumGiftMonths",
			SchemaName: "premium_gift_months",
			Null:       !.Flags.Has(20),
		},
		{
			Name:       "AdsProceedsFromDate",
			SchemaName: "ads_proceeds_from_date",
			Null:       !.Flags.Has(23),
		},
		{
			Name:       "AdsProceedsToDate",
			SchemaName: "ads_proceeds_to_date",
			Null:       !.Flags.Has(23),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarsTransaction) () {
	if !(.Refund == false) {
		.Flags.Set(3)
	}
	if !(.Pending == false) {
		.Flags.Set(4)
	}
	if !(.Failed == false) {
		.Flags.Set(6)
	}
	if !(.Gift == false) {
		.Flags.Set(10)
	}
	if !(.Reaction == false) {
		.Flags.Set(11)
	}
	if !(.StargiftUpgrade == false) {
		.Flags.Set(18)
	}
	if !(.BusinessTransfer == false) {
		.Flags.Set(21)
	}
	if !(.StargiftResale == false) {
		.Flags.Set(22)
	}
	if !(.PostsSearch == false) {
		.Flags.Set(24)
	}
	if !(.StargiftPrepaidUpgrade == false) {
		.Flags.Set(25)
	}
	if !(.StargiftDropOriginalDetails == false) {
		.Flags.Set(26)
	}
	if !(.PhonegroupMessage == false) {
		.Flags.Set(27)
	}
	if !(.StargiftAuctionBid == false) {
		.Flags.Set(28)
	}
	if !(.Offer == false) {
		.Flags.Set(29)
	}
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.Description == "") {
		.Flags.Set(1)
	}
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
	if !(.TransactionDate == 0) {
		.Flags.Set(5)
	}
	if !(.TransactionURL == "") {
		.Flags.Set(5)
	}
	if !(.BotPayload == nil) {
		.Flags.Set(7)
	}
	if !(.MsgID == 0) {
		.Flags.Set(8)
	}
	if !(.ExtendedMedia == nil) {
		.Flags.Set(9)
	}
	if !(.SubscriptionPeriod == 0) {
		.Flags.Set(12)
	}
	if !(.GiveawayPostID == 0) {
		.Flags.Set(13)
	}
	if !(.Stargift == nil) {
		.Flags.Set(14)
	}
	if !(.FloodskipNumber == 0) {
		.Flags.Set(15)
	}
	if !(.StarrefCommissionPermille == 0) {
		.Flags.Set(16)
	}
	if !(.StarrefPeer == nil) {
		.Flags.Set(17)
	}
	if !(.StarrefAmount == nil) {
		.Flags.Set(17)
	}
	if !(.PaidMessages == 0) {
		.Flags.Set(19)
	}
	if !(.PremiumGiftMonths == 0) {
		.Flags.Set(20)
	}
	if !(.AdsProceedsFromDate == 0) {
		.Flags.Set(23)
	}
	if !(.AdsProceedsToDate == 0) {
		.Flags.Set(23)
	}
}

// Encode implements bin.Encoder.
func ( *StarsTransaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starsTransaction#13659eb0 as nil")
	}
	.PutID(StarsTransactionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarsTransaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starsTransaction#13659eb0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starsTransaction#13659eb0: field flags: %w", )
	}
	.PutString(.ID)
	if .Amount == nil {
		return fmt.Errorf("unable to encode starsTransaction#13659eb0: field amount is nil")
	}
	if  := .Amount.Encode();  != nil {
		return fmt.Errorf("unable to encode starsTransaction#13659eb0: field amount: %w", )
	}
	.PutInt(.Date)
	if .Peer == nil {
		return fmt.Errorf("unable to encode starsTransaction#13659eb0: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode starsTransaction#13659eb0: field peer: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(1) {
		.PutString(.Description)
	}
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field photo: %w", )
		}
	}
	if .Flags.Has(5) {
		.PutInt(.TransactionDate)
	}
	if .Flags.Has(5) {
		.PutString(.TransactionURL)
	}
	if .Flags.Has(7) {
		.PutBytes(.BotPayload)
	}
	if .Flags.Has(8) {
		.PutInt(.MsgID)
	}
	if .Flags.Has(9) {
		.PutVectorHeader(len(.ExtendedMedia))
		for ,  := range .ExtendedMedia {
			if  == nil {
				return fmt.Errorf("unable to encode starsTransaction#13659eb0: field extended_media element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode starsTransaction#13659eb0: field extended_media element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(12) {
		.PutInt(.SubscriptionPeriod)
	}
	if .Flags.Has(13) {
		.PutInt(.GiveawayPostID)
	}
	if .Flags.Has(14) {
		if .Stargift == nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field stargift is nil")
		}
		if  := .Stargift.Encode();  != nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field stargift: %w", )
		}
	}
	if .Flags.Has(15) {
		.PutInt(.FloodskipNumber)
	}
	if .Flags.Has(16) {
		.PutInt(.StarrefCommissionPermille)
	}
	if .Flags.Has(17) {
		if .StarrefPeer == nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field starref_peer is nil")
		}
		if  := .StarrefPeer.Encode();  != nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field starref_peer: %w", )
		}
	}
	if .Flags.Has(17) {
		if .StarrefAmount == nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field starref_amount is nil")
		}
		if  := .StarrefAmount.Encode();  != nil {
			return fmt.Errorf("unable to encode starsTransaction#13659eb0: field starref_amount: %w", )
		}
	}
	if .Flags.Has(19) {
		.PutInt(.PaidMessages)
	}
	if .Flags.Has(20) {
		.PutInt(.PremiumGiftMonths)
	}
	if .Flags.Has(23) {
		.PutInt(.AdsProceedsFromDate)
	}
	if .Flags.Has(23) {
		.PutInt(.AdsProceedsToDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StarsTransaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starsTransaction#13659eb0 to nil")
	}
	if  := .ConsumeID(StarsTransactionTypeID);  != nil {
		return fmt.Errorf("unable to decode starsTransaction#13659eb0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarsTransaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starsTransaction#13659eb0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field flags: %w", )
		}
	}
	.Refund = .Flags.Has(3)
	.Pending = .Flags.Has(4)
	.Failed = .Flags.Has(6)
	.Gift = .Flags.Has(10)
	.Reaction = .Flags.Has(11)
	.StargiftUpgrade = .Flags.Has(18)
	.BusinessTransfer = .Flags.Has(21)
	.StargiftResale = .Flags.Has(22)
	.PostsSearch = .Flags.Has(24)
	.StargiftPrepaidUpgrade = .Flags.Has(25)
	.StargiftDropOriginalDetails = .Flags.Has(26)
	.PhonegroupMessage = .Flags.Has(27)
	.StargiftAuctionBid = .Flags.Has(28)
	.Offer = .Flags.Has(29)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field id: %w", )
		}
		.ID = 
	}
	{
		,  := DecodeStarsAmount()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field amount: %w", )
		}
		.Amount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeStarsTransactionPeer()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(2) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field photo: %w", )
		}
		.Photo = 
	}
	if .Flags.Has(5) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field transaction_date: %w", )
		}
		.TransactionDate = 
	}
	if .Flags.Has(5) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field transaction_url: %w", )
		}
		.TransactionURL = 
	}
	if .Flags.Has(7) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field bot_payload: %w", )
		}
		.BotPayload = 
	}
	if .Flags.Has(8) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field msg_id: %w", )
		}
		.MsgID = 
	}
	if .Flags.Has(9) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field extended_media: %w", )
		}

		if  > 0 {
			.ExtendedMedia = make([]MessageMediaClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageMedia()
			if  != nil {
				return fmt.Errorf("unable to decode starsTransaction#13659eb0: field extended_media: %w", )
			}
			.ExtendedMedia = append(.ExtendedMedia, )
		}
	}
	if .Flags.Has(12) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field subscription_period: %w", )
		}
		.SubscriptionPeriod = 
	}
	if .Flags.Has(13) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field giveaway_post_id: %w", )
		}
		.GiveawayPostID = 
	}
	if .Flags.Has(14) {
		,  := DecodeStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field stargift: %w", )
		}
		.Stargift = 
	}
	if .Flags.Has(15) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field floodskip_number: %w", )
		}
		.FloodskipNumber = 
	}
	if .Flags.Has(16) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field starref_commission_permille: %w", )
		}
		.StarrefCommissionPermille = 
	}
	if .Flags.Has(17) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field starref_peer: %w", )
		}
		.StarrefPeer = 
	}
	if .Flags.Has(17) {
		,  := DecodeStarsAmount()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field starref_amount: %w", )
		}
		.StarrefAmount = 
	}
	if .Flags.Has(19) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field paid_messages: %w", )
		}
		.PaidMessages = 
	}
	if .Flags.Has(20) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field premium_gift_months: %w", )
		}
		.PremiumGiftMonths = 
	}
	if .Flags.Has(23) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field ads_proceeds_from_date: %w", )
		}
		.AdsProceedsFromDate = 
	}
	if .Flags.Has(23) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsTransaction#13659eb0: field ads_proceeds_to_date: %w", )
		}
		.AdsProceedsToDate = 
	}
	return nil
}

// SetRefund sets value of Refund conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(3)
		.Refund = true
	} else {
		.Flags.Unset(3)
		.Refund = false
	}
}

// GetRefund returns value of Refund conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetPending sets value of Pending conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(4)
		.Pending = true
	} else {
		.Flags.Unset(4)
		.Pending = false
	}
}

// GetPending returns value of Pending conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetFailed sets value of Failed conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(6)
		.Failed = true
	} else {
		.Flags.Unset(6)
		.Failed = false
	}
}

// GetFailed returns value of Failed conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// SetGift sets value of Gift conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(10)
		.Gift = true
	} else {
		.Flags.Unset(10)
		.Gift = false
	}
}

// GetGift returns value of Gift conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

// SetReaction sets value of Reaction conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(11)
		.Reaction = true
	} else {
		.Flags.Unset(11)
		.Reaction = false
	}
}

// GetReaction returns value of Reaction conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

// SetStargiftUpgrade sets value of StargiftUpgrade conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(18)
		.StargiftUpgrade = true
	} else {
		.Flags.Unset(18)
		.StargiftUpgrade = false
	}
}

// GetStargiftUpgrade returns value of StargiftUpgrade conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(18)
}

// SetBusinessTransfer sets value of BusinessTransfer conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(21)
		.BusinessTransfer = true
	} else {
		.Flags.Unset(21)
		.BusinessTransfer = false
	}
}

// GetBusinessTransfer returns value of BusinessTransfer conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(21)
}

// SetStargiftResale sets value of StargiftResale conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(22)
		.StargiftResale = true
	} else {
		.Flags.Unset(22)
		.StargiftResale = false
	}
}

// GetStargiftResale returns value of StargiftResale conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(22)
}

// SetPostsSearch sets value of PostsSearch conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(24)
		.PostsSearch = true
	} else {
		.Flags.Unset(24)
		.PostsSearch = false
	}
}

// GetPostsSearch returns value of PostsSearch conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(24)
}

// SetStargiftPrepaidUpgrade sets value of StargiftPrepaidUpgrade conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(25)
		.StargiftPrepaidUpgrade = true
	} else {
		.Flags.Unset(25)
		.StargiftPrepaidUpgrade = false
	}
}

// GetStargiftPrepaidUpgrade returns value of StargiftPrepaidUpgrade conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(25)
}

// SetStargiftDropOriginalDetails sets value of StargiftDropOriginalDetails conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(26)
		.StargiftDropOriginalDetails = true
	} else {
		.Flags.Unset(26)
		.StargiftDropOriginalDetails = false
	}
}

// GetStargiftDropOriginalDetails returns value of StargiftDropOriginalDetails conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(26)
}

// SetPhonegroupMessage sets value of PhonegroupMessage conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(27)
		.PhonegroupMessage = true
	} else {
		.Flags.Unset(27)
		.PhonegroupMessage = false
	}
}

// GetPhonegroupMessage returns value of PhonegroupMessage conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(27)
}

// SetStargiftAuctionBid sets value of StargiftAuctionBid conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(28)
		.StargiftAuctionBid = true
	} else {
		.Flags.Unset(28)
		.StargiftAuctionBid = false
	}
}

// GetStargiftAuctionBid returns value of StargiftAuctionBid conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(28)
}

// SetOffer sets value of Offer conditional field.
func ( *StarsTransaction) ( bool) {
	if  {
		.Flags.Set(29)
		.Offer = true
	} else {
		.Flags.Unset(29)
		.Offer = false
	}
}

// GetOffer returns value of Offer conditional field.
func ( *StarsTransaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(29)
}

// GetID returns value of ID field.
func ( *StarsTransaction) () ( string) {
	if  == nil {
		return
	}
	return .ID
}

// GetAmount returns value of Amount field.
func ( *StarsTransaction) () ( StarsAmountClass) {
	if  == nil {
		return
	}
	return .Amount
}

// GetDate returns value of Date field.
func ( *StarsTransaction) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetPeer returns value of Peer field.
func ( *StarsTransaction) () ( StarsTransactionPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// SetTitle sets value of Title conditional field.
func ( *StarsTransaction) ( string) {
	.Flags.Set(0)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Title, true
}

// SetDescription sets value of Description conditional field.
func ( *StarsTransaction) ( string) {
	.Flags.Set(1)
	.Description = 
}

// GetDescription returns value of Description conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Description, true
}

// SetPhoto sets value of Photo conditional field.
func ( *StarsTransaction) ( WebDocumentClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// SetTransactionDate sets value of TransactionDate conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(5)
	.TransactionDate = 
}

// GetTransactionDate returns value of TransactionDate conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .TransactionDate, true
}

// SetTransactionURL sets value of TransactionURL conditional field.
func ( *StarsTransaction) ( string) {
	.Flags.Set(5)
	.TransactionURL = 
}

// GetTransactionURL returns value of TransactionURL conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .TransactionURL, true
}

// SetBotPayload sets value of BotPayload conditional field.
func ( *StarsTransaction) ( []byte) {
	.Flags.Set(7)
	.BotPayload = 
}

// GetBotPayload returns value of BotPayload conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .BotPayload, true
}

// SetMsgID sets value of MsgID conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(8)
	.MsgID = 
}

// GetMsgID returns value of MsgID conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .MsgID, true
}

// SetExtendedMedia sets value of ExtendedMedia conditional field.
func ( *StarsTransaction) ( []MessageMediaClass) {
	.Flags.Set(9)
	.ExtendedMedia = 
}

// GetExtendedMedia returns value of ExtendedMedia conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( []MessageMediaClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .ExtendedMedia, true
}

// SetSubscriptionPeriod sets value of SubscriptionPeriod conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(12)
	.SubscriptionPeriod = 
}

// GetSubscriptionPeriod returns value of SubscriptionPeriod conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(12) {
		return , false
	}
	return .SubscriptionPeriod, true
}

// SetGiveawayPostID sets value of GiveawayPostID conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(13)
	.GiveawayPostID = 
}

// GetGiveawayPostID returns value of GiveawayPostID conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .GiveawayPostID, true
}

// SetStargift sets value of Stargift conditional field.
func ( *StarsTransaction) ( StarGiftClass) {
	.Flags.Set(14)
	.Stargift = 
}

// GetStargift returns value of Stargift conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( StarGiftClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(14) {
		return , false
	}
	return .Stargift, true
}

// SetFloodskipNumber sets value of FloodskipNumber conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(15)
	.FloodskipNumber = 
}

// GetFloodskipNumber returns value of FloodskipNumber conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(15) {
		return , false
	}
	return .FloodskipNumber, true
}

// SetStarrefCommissionPermille sets value of StarrefCommissionPermille conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(16)
	.StarrefCommissionPermille = 
}

// GetStarrefCommissionPermille returns value of StarrefCommissionPermille conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(16) {
		return , false
	}
	return .StarrefCommissionPermille, true
}

// SetStarrefPeer sets value of StarrefPeer conditional field.
func ( *StarsTransaction) ( PeerClass) {
	.Flags.Set(17)
	.StarrefPeer = 
}

// GetStarrefPeer returns value of StarrefPeer conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(17) {
		return , false
	}
	return .StarrefPeer, true
}

// SetStarrefAmount sets value of StarrefAmount conditional field.
func ( *StarsTransaction) ( StarsAmountClass) {
	.Flags.Set(17)
	.StarrefAmount = 
}

// GetStarrefAmount returns value of StarrefAmount conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( StarsAmountClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(17) {
		return , false
	}
	return .StarrefAmount, true
}

// SetPaidMessages sets value of PaidMessages conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(19)
	.PaidMessages = 
}

// GetPaidMessages returns value of PaidMessages conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(19) {
		return , false
	}
	return .PaidMessages, true
}

// SetPremiumGiftMonths sets value of PremiumGiftMonths conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(20)
	.PremiumGiftMonths = 
}

// GetPremiumGiftMonths returns value of PremiumGiftMonths conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(20) {
		return , false
	}
	return .PremiumGiftMonths, true
}

// SetAdsProceedsFromDate sets value of AdsProceedsFromDate conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(23)
	.AdsProceedsFromDate = 
}

// GetAdsProceedsFromDate returns value of AdsProceedsFromDate conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(23) {
		return , false
	}
	return .AdsProceedsFromDate, true
}

// SetAdsProceedsToDate sets value of AdsProceedsToDate conditional field.
func ( *StarsTransaction) ( int) {
	.Flags.Set(23)
	.AdsProceedsToDate = 
}

// GetAdsProceedsToDate returns value of AdsProceedsToDate conditional field and
// boolean which is true if field was set.
func ( *StarsTransaction) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(23) {
		return , false
	}
	return .AdsProceedsToDate, true
}

// MapExtendedMedia returns field ExtendedMedia wrapped in MessageMediaClassArray helper.
func ( *StarsTransaction) () ( MessageMediaClassArray,  bool) {
	if !.Flags.Has(9) {
		return , false
	}
	return MessageMediaClassArray(.ExtendedMedia), true
}