// 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#a3805f3f`.
// Used to gift Telegram PremiumĀ¹ subscriptions only to some specific subscribers of a
// channel 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 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 users, 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
}

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

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

	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)
}) {
	.Users = .()
	if ,  := .();  {
		.BoostPeer = 
	}

	.Currency = .()
	.Amount = .()
}

// 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",
		},
	}
	return 
}

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

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

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

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

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

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

// 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
	// WinnersAreVisible field of InputStorePaymentPremiumGiveaway.
	WinnersAreVisible bool
	// The channel 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
	// PrizeDescription field of InputStorePaymentPremiumGiveaway.
	//
	// 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
}

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

// InputStorePaymentPurposeClass represents InputStorePaymentPurpose generic type.
//
// See https://core.telegram.org/type/InputStorePaymentPurpose for reference.
//
// 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#a3805f3f
//	case *tg.InputStorePaymentPremiumGiveaway: // inputStorePaymentPremiumGiveaway#160544ca
//	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#a3805f3f.
		 := 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
	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()
}