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

// InputStorePaymentPremiumSubscription represents TL type `inputStorePaymentPremiumSubscription#a6751e66`.
// Info about a Telegram Premium purchase
//
// See https://core.telegram.org/constructor/inputStorePaymentPremiumSubscription for reference.
type InputStorePaymentPremiumSubscription struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Pass true if this is a restore of a Telegram Premium purchase; only for the App Store
	Restore bool
	// Pass true if this is an upgrade from a monthly subscription to a yearly subscription;
	// only for App Store
	Upgrade bool
}

// InputStorePaymentPremiumSubscriptionTypeID is TL type id of InputStorePaymentPremiumSubscription.
const InputStorePaymentPremiumSubscriptionTypeID = 0xa6751e66

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentPremiumSubscription) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumSubscription{}
)

func ( *InputStorePaymentPremiumSubscription) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Restore == false) {
		return false
	}
	if !(.Upgrade == false) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentPremiumSubscription from given interface.
func ( *InputStorePaymentPremiumSubscription) ( interface {
	() ( bool)
	() ( bool)
}) {
	.Restore = .()
	.Upgrade = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentPremiumSubscription) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentPremiumSubscription",
		ID:   InputStorePaymentPremiumSubscriptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Restore",
			SchemaName: "restore",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Upgrade",
			SchemaName: "upgrade",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentPremiumSubscription) () {
	if !(.Restore == false) {
		.Flags.Set(0)
	}
	if !(.Upgrade == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentPremiumSubscription) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumSubscription#a6751e66 as nil")
	}
	.PutID(InputStorePaymentPremiumSubscriptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentPremiumSubscription) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumSubscription#a6751e66 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentPremiumSubscription#a6751e66: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentPremiumSubscription) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentPremiumSubscription#a6751e66 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumSubscription#a6751e66: field flags: %w", )
		}
	}
	.Restore = .Flags.Has(0)
	.Upgrade = .Flags.Has(1)
	return nil
}

// SetRestore sets value of Restore conditional field.
func ( *InputStorePaymentPremiumSubscription) ( bool) {
	if  {
		.Flags.Set(0)
		.Restore = true
	} else {
		.Flags.Unset(0)
		.Restore = false
	}
}

// GetRestore returns value of Restore conditional field.
func ( *InputStorePaymentPremiumSubscription) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetUpgrade sets value of Upgrade conditional field.
func ( *InputStorePaymentPremiumSubscription) ( bool) {
	if  {
		.Flags.Set(1)
		.Upgrade = true
	} else {
		.Flags.Unset(1)
		.Upgrade = false
	}
}

// GetUpgrade returns value of Upgrade conditional field.
func ( *InputStorePaymentPremiumSubscription) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// InputStorePaymentGiftPremium represents TL type `inputStorePaymentGiftPremium#616f7fe8`.
// Info about a gifted Telegram Premium purchase
//
// See https://core.telegram.org/constructor/inputStorePaymentGiftPremium for reference.
type InputStorePaymentGiftPremium struct {
	// The user to which the Telegram Premium subscription was gifted
	UserID InputUserClass
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Price of the product in the smallest units of the currency (integer, not float/double)
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
}

// InputStorePaymentGiftPremiumTypeID is TL type id of InputStorePaymentGiftPremium.
const InputStorePaymentGiftPremiumTypeID = 0x616f7fe8

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentGiftPremium) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentGiftPremium{}
)

func ( *InputStorePaymentGiftPremium) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentGiftPremium from given interface.
func ( *InputStorePaymentGiftPremium) ( interface {
	() ( InputUserClass)
	() ( string)
	() ( int64)
}) {
	.UserID = .()
	.Currency = .()
	.Amount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentGiftPremium) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentGiftPremium",
		ID:   InputStorePaymentGiftPremiumTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentGiftPremium) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentGiftPremium#616f7fe8 as nil")
	}
	.PutID(InputStorePaymentGiftPremiumTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentGiftPremium) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentGiftPremium#616f7fe8 as nil")
	}
	if .UserID == nil {
		return fmt.Errorf("unable to encode inputStorePaymentGiftPremium#616f7fe8: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentGiftPremium#616f7fe8: field user_id: %w", )
	}
	.PutString(.Currency)
	.PutLong(.Amount)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputStorePaymentGiftPremium) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentGiftPremium#616f7fe8 to nil")
	}
	if  := .ConsumeID(InputStorePaymentGiftPremiumTypeID);  != nil {
		return fmt.Errorf("unable to decode inputStorePaymentGiftPremium#616f7fe8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentGiftPremium) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentGiftPremium#616f7fe8 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentGiftPremium#616f7fe8: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentGiftPremium#616f7fe8: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentGiftPremium#616f7fe8: field amount: %w", )
		}
		.Amount = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *InputStorePaymentGiftPremium) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentGiftPremium) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// InputStorePaymentPremiumGiftCode represents TL type `inputStorePaymentPremiumGiftCode#fb790393`.
// Used to gift Telegram Premium¹ subscriptions only to some specific subscribers of a
// channel/supergroup or to some of our contacts, see here »² for more info on
// giveaways and gifts.
//
// Links:
//  1. https://core.telegram.org/api/premium
//  2. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/constructor/inputStorePaymentPremiumGiftCode for reference.
type InputStorePaymentPremiumGiftCode struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The users that will receive the Telegram Premium¹ subscriptions.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	Users []InputUserClass
	// If set, the gifts will be sent on behalf of a channel/supergroup we are an admin of,
	// which will also assign some boosts¹ to it. Otherwise, the gift will be sent directly
	// from the currently logged in user, and we will gain some extra boost slots². See here
	// »³ for more info on giveaways and gifts.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//  2) https://core.telegram.org/api/boost
	//  3) https://core.telegram.org/api/giveaways
	//
	// Use SetBoostPeer and GetBoostPeer helpers.
	BoostPeer InputPeerClass
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// Message attached with the gift
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
}

// InputStorePaymentPremiumGiftCodeTypeID is TL type id of InputStorePaymentPremiumGiftCode.
const InputStorePaymentPremiumGiftCodeTypeID = 0xfb790393

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentPremiumGiftCode) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiftCode{}
)

func ( *InputStorePaymentPremiumGiftCode) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.BoostPeer == nil) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}
	if !(.Message.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentPremiumGiftCode from given interface.
func ( *InputStorePaymentPremiumGiftCode) ( interface {
	() ( []InputUserClass)
	() ( InputPeerClass,  bool)
	() ( string)
	() ( int64)
	() ( TextWithEntities,  bool)
}) {
	.Users = .()
	if ,  := .();  {
		.BoostPeer = 
	}

	.Currency = .()
	.Amount = .()
	if ,  := .();  {
		.Message = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentPremiumGiftCode) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentPremiumGiftCode",
		ID:   InputStorePaymentPremiumGiftCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "BoostPeer",
			SchemaName: "boost_peer",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentPremiumGiftCode) () {
	if !(.BoostPeer == nil) {
		.Flags.Set(0)
	}
	if !(.Message.Zero()) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentPremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumGiftCode#fb790393 as nil")
	}
	.PutID(InputStorePaymentPremiumGiftCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentPremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumGiftCode#fb790393 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field flags: %w", )
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field users element with index %d: %w", , )
		}
	}
	if .Flags.Has(0) {
		if .BoostPeer == nil {
			return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field boost_peer is nil")
		}
		if  := .BoostPeer.Encode();  != nil {
			return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field boost_peer: %w", )
		}
	}
	.PutString(.Currency)
	.PutLong(.Amount)
	if .Flags.Has(1) {
		if  := .Message.Encode();  != nil {
			return fmt.Errorf("unable to encode inputStorePaymentPremiumGiftCode#fb790393: field message: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentPremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentPremiumGiftCode#fb790393 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field flags: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field users: %w", )
		}

		if  > 0 {
			.Users = make([]InputUserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputUser()
			if  != nil {
				return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field boost_peer: %w", )
		}
		.BoostPeer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field amount: %w", )
		}
		.Amount = 
	}
	if .Flags.Has(1) {
		if  := .Message.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiftCode#fb790393: field message: %w", )
		}
	}
	return nil
}

// GetUsers returns value of Users field.
func ( *InputStorePaymentPremiumGiftCode) () ( []InputUserClass) {
	if  == nil {
		return
	}
	return .Users
}

// SetBoostPeer sets value of BoostPeer conditional field.
func ( *InputStorePaymentPremiumGiftCode) ( InputPeerClass) {
	.Flags.Set(0)
	.BoostPeer = 
}

// GetBoostPeer returns value of BoostPeer conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentPremiumGiftCode) () ( InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .BoostPeer, true
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentPremiumGiftCode) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// SetMessage sets value of Message conditional field.
func ( *InputStorePaymentPremiumGiftCode) ( TextWithEntities) {
	.Flags.Set(1)
	.Message = 
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentPremiumGiftCode) () ( TextWithEntities,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Message, true
}

// MapUsers returns field Users wrapped in InputUserClassArray helper.
func ( *InputStorePaymentPremiumGiftCode) () ( InputUserClassArray) {
	return InputUserClassArray(.Users)
}

// InputStorePaymentPremiumGiveaway represents TL type `inputStorePaymentPremiumGiveaway#160544ca`.
// Used to pay for a giveaway, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/constructor/inputStorePaymentPremiumGiveaway for reference.
type InputStorePaymentPremiumGiveaway struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, only new subscribers starting from the giveaway creation date will be able to
	// participate to the giveaway.
	OnlyNewSubscribers bool
	// If set, giveaway winners are public and will be listed in a
	// messageMediaGiveawayResults¹ message that will be automatically sent to the channel
	// once the giveaway ends.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageMediaGiveawayResults
	WinnersAreVisible bool
	// The channel/supergroup starting the giveaway, that the user must join to participate,
	// that will receive the giveaway boosts¹; see here »² for more info on giveaways.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//  2) https://core.telegram.org/api/giveaways
	BoostPeer InputPeerClass
	// Additional channels that the user must join to participate to the giveaway can be
	// specified here.
	//
	// Use SetAdditionalPeers and GetAdditionalPeers helpers.
	AdditionalPeers []InputPeerClass
	// The set of users that can participate to the giveaway can be restricted by passing
	// here an explicit whitelist of up to giveaway_countries_max¹ countries, specified as
	// two-letter ISO 3166-1 alpha-2 country codes.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#giveaway-countries-max
	//
	// Use SetCountriesISO2 and GetCountriesISO2 helpers.
	CountriesISO2 []string
	// Can contain a textual description of additional giveaway prizes.
	//
	// Use SetPrizeDescription and GetPrizeDescription helpers.
	PrizeDescription string
	// Random ID to avoid resending the giveaway
	RandomID int64
	// The end date of the giveaway, must be at most giveaway_period_max¹ seconds in the
	// future; see here »² for more info on giveaways.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#giveaway-period-max
	//  2) https://core.telegram.org/api/giveaways
	UntilDate int
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
}

// InputStorePaymentPremiumGiveawayTypeID is TL type id of InputStorePaymentPremiumGiveaway.
const InputStorePaymentPremiumGiveawayTypeID = 0x160544ca

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentPremiumGiveaway) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiveaway{}
)

func ( *InputStorePaymentPremiumGiveaway) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.OnlyNewSubscribers == false) {
		return false
	}
	if !(.WinnersAreVisible == false) {
		return false
	}
	if !(.BoostPeer == nil) {
		return false
	}
	if !(.AdditionalPeers == nil) {
		return false
	}
	if !(.CountriesISO2 == nil) {
		return false
	}
	if !(.PrizeDescription == "") {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.UntilDate == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentPremiumGiveaway from given interface.
func ( *InputStorePaymentPremiumGiveaway) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( []InputPeerClass,  bool)
	() ( []string,  bool)
	() ( string,  bool)
	() ( int64)
	() ( int)
	() ( string)
	() ( int64)
}) {
	.OnlyNewSubscribers = .()
	.WinnersAreVisible = .()
	.BoostPeer = .()
	if ,  := .();  {
		.AdditionalPeers = 
	}

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

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

	.RandomID = .()
	.UntilDate = .()
	.Currency = .()
	.Amount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentPremiumGiveaway) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentPremiumGiveaway",
		ID:   InputStorePaymentPremiumGiveawayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "OnlyNewSubscribers",
			SchemaName: "only_new_subscribers",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "WinnersAreVisible",
			SchemaName: "winners_are_visible",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "BoostPeer",
			SchemaName: "boost_peer",
		},
		{
			Name:       "AdditionalPeers",
			SchemaName: "additional_peers",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "CountriesISO2",
			SchemaName: "countries_iso2",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "PrizeDescription",
			SchemaName: "prize_description",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "UntilDate",
			SchemaName: "until_date",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentPremiumGiveaway) () {
	if !(.OnlyNewSubscribers == false) {
		.Flags.Set(0)
	}
	if !(.WinnersAreVisible == false) {
		.Flags.Set(3)
	}
	if !(.AdditionalPeers == nil) {
		.Flags.Set(1)
	}
	if !(.CountriesISO2 == nil) {
		.Flags.Set(2)
	}
	if !(.PrizeDescription == "") {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentPremiumGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumGiveaway#160544ca as nil")
	}
	.PutID(InputStorePaymentPremiumGiveawayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentPremiumGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentPremiumGiveaway#160544ca as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field flags: %w", )
	}
	if .BoostPeer == nil {
		return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer is nil")
	}
	if  := .BoostPeer.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer: %w", )
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.AdditionalPeers))
		for ,  := range .AdditionalPeers {
			if  == nil {
				return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.CountriesISO2))
		for ,  := range .CountriesISO2 {
			.PutString()
		}
	}
	if .Flags.Has(4) {
		.PutString(.PrizeDescription)
	}
	.PutLong(.RandomID)
	.PutInt(.UntilDate)
	.PutString(.Currency)
	.PutLong(.Amount)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputStorePaymentPremiumGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentPremiumGiveaway#160544ca to nil")
	}
	if  := .ConsumeID(InputStorePaymentPremiumGiveawayTypeID);  != nil {
		return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentPremiumGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentPremiumGiveaway#160544ca to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field flags: %w", )
		}
	}
	.OnlyNewSubscribers = .Flags.Has(0)
	.WinnersAreVisible = .Flags.Has(3)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer: %w", )
		}
		.BoostPeer = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers: %w", )
		}

		if  > 0 {
			.AdditionalPeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers: %w", )
			}
			.AdditionalPeers = append(.AdditionalPeers, )
		}
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field countries_iso2: %w", )
		}

		if  > 0 {
			.CountriesISO2 = make([]string, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .String()
			if  != nil {
				return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field countries_iso2: %w", )
			}
			.CountriesISO2 = append(.CountriesISO2, )
		}
	}
	if .Flags.Has(4) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field prize_description: %w", )
		}
		.PrizeDescription = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field random_id: %w", )
		}
		.RandomID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field until_date: %w", )
		}
		.UntilDate = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field amount: %w", )
		}
		.Amount = 
	}
	return nil
}

// SetOnlyNewSubscribers sets value of OnlyNewSubscribers conditional field.
func ( *InputStorePaymentPremiumGiveaway) ( bool) {
	if  {
		.Flags.Set(0)
		.OnlyNewSubscribers = true
	} else {
		.Flags.Unset(0)
		.OnlyNewSubscribers = false
	}
}

// GetOnlyNewSubscribers returns value of OnlyNewSubscribers conditional field.
func ( *InputStorePaymentPremiumGiveaway) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetWinnersAreVisible sets value of WinnersAreVisible conditional field.
func ( *InputStorePaymentPremiumGiveaway) ( bool) {
	if  {
		.Flags.Set(3)
		.WinnersAreVisible = true
	} else {
		.Flags.Unset(3)
		.WinnersAreVisible = false
	}
}

// GetWinnersAreVisible returns value of WinnersAreVisible conditional field.
func ( *InputStorePaymentPremiumGiveaway) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// GetBoostPeer returns value of BoostPeer field.
func ( *InputStorePaymentPremiumGiveaway) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .BoostPeer
}

// SetAdditionalPeers sets value of AdditionalPeers conditional field.
func ( *InputStorePaymentPremiumGiveaway) ( []InputPeerClass) {
	.Flags.Set(1)
	.AdditionalPeers = 
}

// GetAdditionalPeers returns value of AdditionalPeers conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentPremiumGiveaway) () ( []InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .AdditionalPeers, true
}

// SetCountriesISO2 sets value of CountriesISO2 conditional field.
func ( *InputStorePaymentPremiumGiveaway) ( []string) {
	.Flags.Set(2)
	.CountriesISO2 = 
}

// GetCountriesISO2 returns value of CountriesISO2 conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentPremiumGiveaway) () ( []string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .CountriesISO2, true
}

// SetPrizeDescription sets value of PrizeDescription conditional field.
func ( *InputStorePaymentPremiumGiveaway) ( string) {
	.Flags.Set(4)
	.PrizeDescription = 
}

// GetPrizeDescription returns value of PrizeDescription conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentPremiumGiveaway) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .PrizeDescription, true
}

// GetRandomID returns value of RandomID field.
func ( *InputStorePaymentPremiumGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// GetUntilDate returns value of UntilDate field.
func ( *InputStorePaymentPremiumGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .UntilDate
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentPremiumGiveaway) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// MapAdditionalPeers returns field AdditionalPeers wrapped in InputPeerClassArray helper.
func ( *InputStorePaymentPremiumGiveaway) () ( InputPeerClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return InputPeerClassArray(.AdditionalPeers), true
}

// InputStorePaymentStarsTopup represents TL type `inputStorePaymentStarsTopup#f9a2a6cb`.
// Used to top up the Telegram Stars balance¹ of the current account.
//
// Links:
//  1. https://core.telegram.org/api/stars
//
// See https://core.telegram.org/constructor/inputStorePaymentStarsTopup for reference.
type InputStorePaymentStarsTopup struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Amount of stars to topup
	Stars int64
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// Should be populated with the peer where the topup process was initiated due to low
	// funds (i.e. a bot for bot payments, a channel for paid media/reactions, etc); leave
	// this flag unpopulated if the topup flow was not initated when attempting to spend more
	// Stars than currently available on the account's balance.
	//
	// Use SetSpendPurposePeer and GetSpendPurposePeer helpers.
	SpendPurposePeer InputPeerClass
}

// InputStorePaymentStarsTopupTypeID is TL type id of InputStorePaymentStarsTopup.
const InputStorePaymentStarsTopupTypeID = 0xf9a2a6cb

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentStarsTopup) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentStarsTopup{}
)

func ( *InputStorePaymentStarsTopup) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}
	if !(.SpendPurposePeer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentStarsTopup from given interface.
func ( *InputStorePaymentStarsTopup) ( interface {
	() ( int64)
	() ( string)
	() ( int64)
	() ( InputPeerClass,  bool)
}) {
	.Stars = .()
	.Currency = .()
	.Amount = .()
	if ,  := .();  {
		.SpendPurposePeer = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentStarsTopup) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentStarsTopup",
		ID:   InputStorePaymentStarsTopupTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "SpendPurposePeer",
			SchemaName: "spend_purpose_peer",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentStarsTopup) () {
	if !(.SpendPurposePeer == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentStarsTopup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsTopup#f9a2a6cb as nil")
	}
	.PutID(InputStorePaymentStarsTopupTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentStarsTopup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsTopup#f9a2a6cb as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsTopup#f9a2a6cb: field flags: %w", )
	}
	.PutLong(.Stars)
	.PutString(.Currency)
	.PutLong(.Amount)
	if .Flags.Has(0) {
		if .SpendPurposePeer == nil {
			return fmt.Errorf("unable to encode inputStorePaymentStarsTopup#f9a2a6cb: field spend_purpose_peer is nil")
		}
		if  := .SpendPurposePeer.Encode();  != nil {
			return fmt.Errorf("unable to encode inputStorePaymentStarsTopup#f9a2a6cb: field spend_purpose_peer: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentStarsTopup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentStarsTopup#f9a2a6cb to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#f9a2a6cb: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#f9a2a6cb: field stars: %w", )
		}
		.Stars = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#f9a2a6cb: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#f9a2a6cb: field amount: %w", )
		}
		.Amount = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsTopup#f9a2a6cb: field spend_purpose_peer: %w", )
		}
		.SpendPurposePeer = 
	}
	return nil
}

// GetStars returns value of Stars field.
func ( *InputStorePaymentStarsTopup) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentStarsTopup) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// SetSpendPurposePeer sets value of SpendPurposePeer conditional field.
func ( *InputStorePaymentStarsTopup) ( InputPeerClass) {
	.Flags.Set(0)
	.SpendPurposePeer = 
}

// GetSpendPurposePeer returns value of SpendPurposePeer conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentStarsTopup) () ( InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .SpendPurposePeer, true
}

// InputStorePaymentStarsGift represents TL type `inputStorePaymentStarsGift#1d741ef7`.
// Used to gift Telegram Stars¹ to a friend.
//
// Links:
//  1. https://core.telegram.org/api/stars
//
// See https://core.telegram.org/constructor/inputStorePaymentStarsGift for reference.
type InputStorePaymentStarsGift struct {
	// The user to which the stars should be gifted.
	UserID InputUserClass
	// Amount of stars to gift
	Stars int64
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
}

// InputStorePaymentStarsGiftTypeID is TL type id of InputStorePaymentStarsGift.
const InputStorePaymentStarsGiftTypeID = 0x1d741ef7

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentStarsGift) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentStarsGift{}
)

func ( *InputStorePaymentStarsGift) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentStarsGift from given interface.
func ( *InputStorePaymentStarsGift) ( interface {
	() ( InputUserClass)
	() ( int64)
	() ( string)
	() ( int64)
}) {
	.UserID = .()
	.Stars = .()
	.Currency = .()
	.Amount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentStarsGift) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentStarsGift",
		ID:   InputStorePaymentStarsGiftTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentStarsGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsGift#1d741ef7 as nil")
	}
	.PutID(InputStorePaymentStarsGiftTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentStarsGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsGift#1d741ef7 as nil")
	}
	if .UserID == nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsGift#1d741ef7: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsGift#1d741ef7: field user_id: %w", )
	}
	.PutLong(.Stars)
	.PutString(.Currency)
	.PutLong(.Amount)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputStorePaymentStarsGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentStarsGift#1d741ef7 to nil")
	}
	if  := .ConsumeID(InputStorePaymentStarsGiftTypeID);  != nil {
		return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentStarsGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentStarsGift#1d741ef7 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field stars: %w", )
		}
		.Stars = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGift#1d741ef7: field amount: %w", )
		}
		.Amount = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *InputStorePaymentStarsGift) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetStars returns value of Stars field.
func ( *InputStorePaymentStarsGift) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentStarsGift) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// InputStorePaymentStarsGiveaway represents TL type `inputStorePaymentStarsGiveaway#751f08fa`.
// Used to pay for a star giveaway, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/giveaways#star-giveaways
//
// See https://core.telegram.org/constructor/inputStorePaymentStarsGiveaway for reference.
type InputStorePaymentStarsGiveaway struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, only new subscribers starting from the giveaway creation date will be able to
	// participate to the giveaway.
	OnlyNewSubscribers bool
	// If set, giveaway winners are public and will be listed in a
	// messageMediaGiveawayResults¹ message that will be automatically sent to the channel
	// once the giveaway ends.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageMediaGiveawayResults
	WinnersAreVisible bool
	// Total number of Telegram Stars being given away (each user will receive stars/users
	// stars).
	Stars int64
	// The channel/supergroup starting the giveaway, that the user must join to participate,
	// that will receive the giveaway boosts¹; see here »² for more info on giveaways.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//  2) https://core.telegram.org/api/giveaways
	BoostPeer InputPeerClass
	// Additional channels that the user must join to participate to the giveaway can be
	// specified here.
	//
	// Use SetAdditionalPeers and GetAdditionalPeers helpers.
	AdditionalPeers []InputPeerClass
	// The set of users that can participate to the giveaway can be restricted by passing
	// here an explicit whitelist of up to giveaway_countries_max¹ countries, specified as
	// two-letter ISO 3166-1 alpha-2 country codes.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#giveaway-countries-max
	//
	// Use SetCountriesISO2 and GetCountriesISO2 helpers.
	CountriesISO2 []string
	// Can contain a textual description of additional giveaway prizes.
	//
	// Use SetPrizeDescription and GetPrizeDescription helpers.
	PrizeDescription string
	// Random ID to avoid resending the giveaway
	RandomID int64
	// The end date of the giveaway, must be at most giveaway_period_max¹ seconds in the
	// future; see here »² for more info on giveaways.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#giveaway-period-max
	//  2) https://core.telegram.org/api/giveaways
	UntilDate int
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// Number of winners.
	Users int
}

// InputStorePaymentStarsGiveawayTypeID is TL type id of InputStorePaymentStarsGiveaway.
const InputStorePaymentStarsGiveawayTypeID = 0x751f08fa

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentStarsGiveaway) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentStarsGiveaway{}
)

func ( *InputStorePaymentStarsGiveaway) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.OnlyNewSubscribers == false) {
		return false
	}
	if !(.WinnersAreVisible == false) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}
	if !(.BoostPeer == nil) {
		return false
	}
	if !(.AdditionalPeers == nil) {
		return false
	}
	if !(.CountriesISO2 == nil) {
		return false
	}
	if !(.PrizeDescription == "") {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.UntilDate == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}
	if !(.Users == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentStarsGiveaway from given interface.
func ( *InputStorePaymentStarsGiveaway) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( InputPeerClass)
	() ( []InputPeerClass,  bool)
	() ( []string,  bool)
	() ( string,  bool)
	() ( int64)
	() ( int)
	() ( string)
	() ( int64)
	() ( int)
}) {
	.OnlyNewSubscribers = .()
	.WinnersAreVisible = .()
	.Stars = .()
	.BoostPeer = .()
	if ,  := .();  {
		.AdditionalPeers = 
	}

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

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

	.RandomID = .()
	.UntilDate = .()
	.Currency = .()
	.Amount = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentStarsGiveaway) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentStarsGiveaway",
		ID:   InputStorePaymentStarsGiveawayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "OnlyNewSubscribers",
			SchemaName: "only_new_subscribers",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "WinnersAreVisible",
			SchemaName: "winners_are_visible",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "BoostPeer",
			SchemaName: "boost_peer",
		},
		{
			Name:       "AdditionalPeers",
			SchemaName: "additional_peers",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "CountriesISO2",
			SchemaName: "countries_iso2",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "PrizeDescription",
			SchemaName: "prize_description",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "UntilDate",
			SchemaName: "until_date",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentStarsGiveaway) () {
	if !(.OnlyNewSubscribers == false) {
		.Flags.Set(0)
	}
	if !(.WinnersAreVisible == false) {
		.Flags.Set(3)
	}
	if !(.AdditionalPeers == nil) {
		.Flags.Set(1)
	}
	if !(.CountriesISO2 == nil) {
		.Flags.Set(2)
	}
	if !(.PrizeDescription == "") {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsGiveaway#751f08fa as nil")
	}
	.PutID(InputStorePaymentStarsGiveawayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentStarsGiveaway#751f08fa as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field flags: %w", )
	}
	.PutLong(.Stars)
	if .BoostPeer == nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer is nil")
	}
	if  := .BoostPeer.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer: %w", )
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.AdditionalPeers))
		for ,  := range .AdditionalPeers {
			if  == nil {
				return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.CountriesISO2))
		for ,  := range .CountriesISO2 {
			.PutString()
		}
	}
	if .Flags.Has(4) {
		.PutString(.PrizeDescription)
	}
	.PutLong(.RandomID)
	.PutInt(.UntilDate)
	.PutString(.Currency)
	.PutLong(.Amount)
	.PutInt(.Users)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputStorePaymentStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentStarsGiveaway#751f08fa to nil")
	}
	if  := .ConsumeID(InputStorePaymentStarsGiveawayTypeID);  != nil {
		return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentStarsGiveaway#751f08fa to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field flags: %w", )
		}
	}
	.OnlyNewSubscribers = .Flags.Has(0)
	.WinnersAreVisible = .Flags.Has(3)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field stars: %w", )
		}
		.Stars = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field boost_peer: %w", )
		}
		.BoostPeer = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers: %w", )
		}

		if  > 0 {
			.AdditionalPeers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field additional_peers: %w", )
			}
			.AdditionalPeers = append(.AdditionalPeers, )
		}
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field countries_iso2: %w", )
		}

		if  > 0 {
			.CountriesISO2 = make([]string, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .String()
			if  != nil {
				return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field countries_iso2: %w", )
			}
			.CountriesISO2 = append(.CountriesISO2, )
		}
	}
	if .Flags.Has(4) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field prize_description: %w", )
		}
		.PrizeDescription = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field random_id: %w", )
		}
		.RandomID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field until_date: %w", )
		}
		.UntilDate = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field amount: %w", )
		}
		.Amount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentStarsGiveaway#751f08fa: field users: %w", )
		}
		.Users = 
	}
	return nil
}

// SetOnlyNewSubscribers sets value of OnlyNewSubscribers conditional field.
func ( *InputStorePaymentStarsGiveaway) ( bool) {
	if  {
		.Flags.Set(0)
		.OnlyNewSubscribers = true
	} else {
		.Flags.Unset(0)
		.OnlyNewSubscribers = false
	}
}

// GetOnlyNewSubscribers returns value of OnlyNewSubscribers conditional field.
func ( *InputStorePaymentStarsGiveaway) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetWinnersAreVisible sets value of WinnersAreVisible conditional field.
func ( *InputStorePaymentStarsGiveaway) ( bool) {
	if  {
		.Flags.Set(3)
		.WinnersAreVisible = true
	} else {
		.Flags.Unset(3)
		.WinnersAreVisible = false
	}
}

// GetWinnersAreVisible returns value of WinnersAreVisible conditional field.
func ( *InputStorePaymentStarsGiveaway) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// GetStars returns value of Stars field.
func ( *InputStorePaymentStarsGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}

// GetBoostPeer returns value of BoostPeer field.
func ( *InputStorePaymentStarsGiveaway) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .BoostPeer
}

// SetAdditionalPeers sets value of AdditionalPeers conditional field.
func ( *InputStorePaymentStarsGiveaway) ( []InputPeerClass) {
	.Flags.Set(1)
	.AdditionalPeers = 
}

// GetAdditionalPeers returns value of AdditionalPeers conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentStarsGiveaway) () ( []InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .AdditionalPeers, true
}

// SetCountriesISO2 sets value of CountriesISO2 conditional field.
func ( *InputStorePaymentStarsGiveaway) ( []string) {
	.Flags.Set(2)
	.CountriesISO2 = 
}

// GetCountriesISO2 returns value of CountriesISO2 conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentStarsGiveaway) () ( []string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .CountriesISO2, true
}

// SetPrizeDescription sets value of PrizeDescription conditional field.
func ( *InputStorePaymentStarsGiveaway) ( string) {
	.Flags.Set(4)
	.PrizeDescription = 
}

// GetPrizeDescription returns value of PrizeDescription conditional field and
// boolean which is true if field was set.
func ( *InputStorePaymentStarsGiveaway) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .PrizeDescription, true
}

// GetRandomID returns value of RandomID field.
func ( *InputStorePaymentStarsGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// GetUntilDate returns value of UntilDate field.
func ( *InputStorePaymentStarsGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .UntilDate
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentStarsGiveaway) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// GetUsers returns value of Users field.
func ( *InputStorePaymentStarsGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Users
}

// MapAdditionalPeers returns field AdditionalPeers wrapped in InputPeerClassArray helper.
func ( *InputStorePaymentStarsGiveaway) () ( InputPeerClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return InputPeerClassArray(.AdditionalPeers), true
}

// InputStorePaymentAuthCode represents TL type `inputStorePaymentAuthCode#3fc18057`.
// Indicates payment for a login code.
//
// See https://core.telegram.org/constructor/inputStorePaymentAuthCode for reference.
type InputStorePaymentAuthCode struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag to restore a previously made purchase.
	Restore bool
	// Phone number.
	PhoneNumber string
	// phone_code_hash returned by auth.sendCode¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.sendCode
	PhoneCodeHash string
	// PremiumDays field of InputStorePaymentAuthCode.
	PremiumDays int
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Price of the product in the smallest units of the currency (integer, not float/double)
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
}

// InputStorePaymentAuthCodeTypeID is TL type id of InputStorePaymentAuthCode.
const InputStorePaymentAuthCodeTypeID = 0x3fc18057

// construct implements constructor of InputStorePaymentPurposeClass.
func ( InputStorePaymentAuthCode) () InputStorePaymentPurposeClass { return & }

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

	_ InputStorePaymentPurposeClass = &InputStorePaymentAuthCode{}
)

func ( *InputStorePaymentAuthCode) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Restore == false) {
		return false
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.PhoneCodeHash == "") {
		return false
	}
	if !(.PremiumDays == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputStorePaymentAuthCode from given interface.
func ( *InputStorePaymentAuthCode) ( interface {
	() ( bool)
	() ( string)
	() ( string)
	() ( int)
	() ( string)
	() ( int64)
}) {
	.Restore = .()
	.PhoneNumber = .()
	.PhoneCodeHash = .()
	.PremiumDays = .()
	.Currency = .()
	.Amount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputStorePaymentAuthCode) () tdp.Type {
	 := tdp.Type{
		Name: "inputStorePaymentAuthCode",
		ID:   InputStorePaymentAuthCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Restore",
			SchemaName: "restore",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "PhoneCodeHash",
			SchemaName: "phone_code_hash",
		},
		{
			Name:       "PremiumDays",
			SchemaName: "premium_days",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStorePaymentAuthCode) () {
	if !(.Restore == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *InputStorePaymentAuthCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentAuthCode#3fc18057 as nil")
	}
	.PutID(InputStorePaymentAuthCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStorePaymentAuthCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStorePaymentAuthCode#3fc18057 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStorePaymentAuthCode#3fc18057: field flags: %w", )
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	.PutInt(.PremiumDays)
	.PutString(.Currency)
	.PutLong(.Amount)
	return nil
}

// Decode implements bin.Decoder.
func ( *InputStorePaymentAuthCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentAuthCode#3fc18057 to nil")
	}
	if  := .ConsumeID(InputStorePaymentAuthCodeTypeID);  != nil {
		return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputStorePaymentAuthCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStorePaymentAuthCode#3fc18057 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field flags: %w", )
		}
	}
	.Restore = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field premium_days: %w", )
		}
		.PremiumDays = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputStorePaymentAuthCode#3fc18057: field amount: %w", )
		}
		.Amount = 
	}
	return nil
}

// SetRestore sets value of Restore conditional field.
func ( *InputStorePaymentAuthCode) ( bool) {
	if  {
		.Flags.Set(0)
		.Restore = true
	} else {
		.Flags.Unset(0)
		.Restore = false
	}
}

// GetRestore returns value of Restore conditional field.
func ( *InputStorePaymentAuthCode) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetPhoneNumber returns value of PhoneNumber field.
func ( *InputStorePaymentAuthCode) () ( string) {
	if  == nil {
		return
	}
	return .PhoneNumber
}

// GetPhoneCodeHash returns value of PhoneCodeHash field.
func ( *InputStorePaymentAuthCode) () ( string) {
	if  == nil {
		return
	}
	return .PhoneCodeHash
}

// GetPremiumDays returns value of PremiumDays field.
func ( *InputStorePaymentAuthCode) () ( int) {
	if  == nil {
		return
	}
	return .PremiumDays
}

// GetCurrency returns value of Currency field.
func ( *InputStorePaymentAuthCode) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// InputStorePaymentPurposeClassName is schema name of InputStorePaymentPurposeClass.
const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose"

// InputStorePaymentPurposeClass represents InputStorePaymentPurpose generic type.
//
// See https://core.telegram.org/type/InputStorePaymentPurpose for reference.
//
// Constructors:
//   - [InputStorePaymentPremiumSubscription]
//   - [InputStorePaymentGiftPremium]
//   - [InputStorePaymentPremiumGiftCode]
//   - [InputStorePaymentPremiumGiveaway]
//   - [InputStorePaymentStarsTopup]
//   - [InputStorePaymentStarsGift]
//   - [InputStorePaymentStarsGiveaway]
//   - [InputStorePaymentAuthCode]
//
// Example:
//
//	g, err := tg.DecodeInputStorePaymentPurpose(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputStorePaymentPremiumSubscription: // inputStorePaymentPremiumSubscription#a6751e66
//	case *tg.InputStorePaymentGiftPremium: // inputStorePaymentGiftPremium#616f7fe8
//	case *tg.InputStorePaymentPremiumGiftCode: // inputStorePaymentPremiumGiftCode#fb790393
//	case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#160544ca
//	case *tg.InputStorePaymentStarsTopup: // inputStorePaymentStarsTopup#f9a2a6cb
//	case *tg.InputStorePaymentStarsGift: // inputStorePaymentStarsGift#1d741ef7
//	case *tg.InputStorePaymentStarsGiveaway: // inputStorePaymentStarsGiveaway#751f08fa
//	case *tg.InputStorePaymentAuthCode: // inputStorePaymentAuthCode#3fc18057
//	default: panic(v)
//	}
type InputStorePaymentPurposeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputStorePaymentPurposeClass

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

// DecodeInputStorePaymentPurpose implements binary de-serialization for InputStorePaymentPurposeClass.
func ( *bin.Buffer) (InputStorePaymentPurposeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputStorePaymentPremiumSubscriptionTypeID:
		// Decoding inputStorePaymentPremiumSubscription#a6751e66.
		 := InputStorePaymentPremiumSubscription{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentGiftPremiumTypeID:
		// Decoding inputStorePaymentGiftPremium#616f7fe8.
		 := InputStorePaymentGiftPremium{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentPremiumGiftCodeTypeID:
		// Decoding inputStorePaymentPremiumGiftCode#fb790393.
		 := InputStorePaymentPremiumGiftCode{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentPremiumGiveawayTypeID:
		// Decoding inputStorePaymentPremiumGiveaway#160544ca.
		 := InputStorePaymentPremiumGiveaway{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentStarsTopupTypeID:
		// Decoding inputStorePaymentStarsTopup#f9a2a6cb.
		 := InputStorePaymentStarsTopup{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentStarsGiftTypeID:
		// Decoding inputStorePaymentStarsGift#1d741ef7.
		 := InputStorePaymentStarsGift{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentStarsGiveawayTypeID:
		// Decoding inputStorePaymentStarsGiveaway#751f08fa.
		 := InputStorePaymentStarsGiveaway{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	case InputStorePaymentAuthCodeTypeID:
		// Decoding inputStorePaymentAuthCode#3fc18057.
		 := InputStorePaymentAuthCode{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputStorePaymentPurposeClass: %w", bin.NewUnexpectedID())
	}
}

// InputStorePaymentPurpose boxes the InputStorePaymentPurposeClass providing a helper.
type InputStorePaymentPurposeBox struct {
	InputStorePaymentPurpose InputStorePaymentPurposeClass
}

// Decode implements bin.Decoder for InputStorePaymentPurposeBox.
func ( *InputStorePaymentPurposeBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode InputStorePaymentPurposeBox to nil")
	}
	,  := DecodeInputStorePaymentPurpose()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.InputStorePaymentPurpose = 
	return nil
}

// Encode implements bin.Encode for InputStorePaymentPurposeBox.
func ( *InputStorePaymentPurposeBox) ( *bin.Buffer) error {
	if  == nil || .InputStorePaymentPurpose == nil {
		return fmt.Errorf("unable to encode InputStorePaymentPurposeClass as nil")
	}
	return .InputStorePaymentPurpose.Encode()
}