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

// PaymentsStarGiftActiveAuctionsNotModified represents TL type `payments.starGiftActiveAuctionsNotModified#db33dad0`.
// The list of currently active gift auctions¹ where the user has placed a bid hasn't
// changed.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/constructor/payments.starGiftActiveAuctionsNotModified for reference.
type PaymentsStarGiftActiveAuctionsNotModified struct {
}

// PaymentsStarGiftActiveAuctionsNotModifiedTypeID is TL type id of PaymentsStarGiftActiveAuctionsNotModified.
const PaymentsStarGiftActiveAuctionsNotModifiedTypeID = 0xdb33dad0

// construct implements constructor of PaymentsStarGiftActiveAuctionsClass.
func ( PaymentsStarGiftActiveAuctionsNotModified) () PaymentsStarGiftActiveAuctionsClass {
	return &
}

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

	_ PaymentsStarGiftActiveAuctionsClass = &PaymentsStarGiftActiveAuctionsNotModified{}
)

func ( *PaymentsStarGiftActiveAuctionsNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*PaymentsStarGiftActiveAuctionsNotModified) () string {
	return "payments.starGiftActiveAuctionsNotModified"
}

// TypeInfo returns info about TL type.
func ( *PaymentsStarGiftActiveAuctionsNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGiftActiveAuctionsNotModified",
		ID:   PaymentsStarGiftActiveAuctionsNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftActiveAuctionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftActiveAuctionsNotModified#db33dad0 as nil")
	}
	.PutID(PaymentsStarGiftActiveAuctionsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGiftActiveAuctionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftActiveAuctionsNotModified#db33dad0 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsStarGiftActiveAuctionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftActiveAuctionsNotModified#db33dad0 to nil")
	}
	return nil
}

// PaymentsStarGiftActiveAuctions represents TL type `payments.starGiftActiveAuctions#aef6abbc`.
// Describes all currently active gift auctions¹ where the user has placed a bid.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/constructor/payments.starGiftActiveAuctions for reference.
type PaymentsStarGiftActiveAuctions struct {
	// Auctions where the user has placed a bid
	Auctions []StarGiftActiveAuctionState
	// Mentioned users
	Users []UserClass
	// Mentioned chats
	Chats []ChatClass
}

// PaymentsStarGiftActiveAuctionsTypeID is TL type id of PaymentsStarGiftActiveAuctions.
const PaymentsStarGiftActiveAuctionsTypeID = 0xaef6abbc

// construct implements constructor of PaymentsStarGiftActiveAuctionsClass.
func ( PaymentsStarGiftActiveAuctions) () PaymentsStarGiftActiveAuctionsClass { return & }

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

	_ PaymentsStarGiftActiveAuctionsClass = &PaymentsStarGiftActiveAuctions{}
)

func ( *PaymentsStarGiftActiveAuctions) () bool {
	if  == nil {
		return true
	}
	if !(.Auctions == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsStarGiftActiveAuctions from given interface.
func ( *PaymentsStarGiftActiveAuctions) ( interface {
	() ( []StarGiftActiveAuctionState)
	() ( []UserClass)
	() ( []ChatClass)
}) {
	.Auctions = .()
	.Users = .()
	.Chats = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsStarGiftActiveAuctions) () string {
	return "payments.starGiftActiveAuctions"
}

// TypeInfo returns info about TL type.
func ( *PaymentsStarGiftActiveAuctions) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGiftActiveAuctions",
		ID:   PaymentsStarGiftActiveAuctionsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Auctions",
			SchemaName: "auctions",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftActiveAuctions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftActiveAuctions#aef6abbc as nil")
	}
	.PutID(PaymentsStarGiftActiveAuctionsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGiftActiveAuctions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftActiveAuctions#aef6abbc as nil")
	}
	.PutVectorHeader(len(.Auctions))
	for ,  := range .Auctions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftActiveAuctions#aef6abbc: field auctions element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGiftActiveAuctions#aef6abbc: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftActiveAuctions#aef6abbc: field users element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGiftActiveAuctions#aef6abbc: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftActiveAuctions#aef6abbc: field chats element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsStarGiftActiveAuctions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftActiveAuctions#aef6abbc to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field auctions: %w", )
		}

		if  > 0 {
			.Auctions = make([]StarGiftActiveAuctionState, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StarGiftActiveAuctionState
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field auctions: %w", )
			}
			.Auctions = append(.Auctions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode payments.starGiftActiveAuctions#aef6abbc: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	return nil
}

// GetAuctions returns value of Auctions field.
func ( *PaymentsStarGiftActiveAuctions) () ( []StarGiftActiveAuctionState) {
	if  == nil {
		return
	}
	return .Auctions
}

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

// GetChats returns value of Chats field.
func ( *PaymentsStarGiftActiveAuctions) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

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

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *PaymentsStarGiftActiveAuctions) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// PaymentsStarGiftActiveAuctionsClassName is schema name of PaymentsStarGiftActiveAuctionsClass.
const PaymentsStarGiftActiveAuctionsClassName = "payments.StarGiftActiveAuctions"

// PaymentsStarGiftActiveAuctionsClass represents payments.StarGiftActiveAuctions generic type.
//
// See https://core.telegram.org/type/payments.StarGiftActiveAuctions for reference.
//
// Constructors:
//   - [PaymentsStarGiftActiveAuctionsNotModified]
//   - [PaymentsStarGiftActiveAuctions]
//
// Example:
//
//	g, err := tg.DecodePaymentsStarGiftActiveAuctions(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PaymentsStarGiftActiveAuctionsNotModified: // payments.starGiftActiveAuctionsNotModified#db33dad0
//	case *tg.PaymentsStarGiftActiveAuctions: // payments.starGiftActiveAuctions#aef6abbc
//	default: panic(v)
//	}
type PaymentsStarGiftActiveAuctionsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PaymentsStarGiftActiveAuctionsClass

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

	// AsModified tries to map PaymentsStarGiftActiveAuctionsClass to PaymentsStarGiftActiveAuctions.
	AsModified() (*PaymentsStarGiftActiveAuctions, bool)
}

// AsModified tries to map PaymentsStarGiftActiveAuctionsNotModified to PaymentsStarGiftActiveAuctions.
func ( *PaymentsStarGiftActiveAuctionsNotModified) () (*PaymentsStarGiftActiveAuctions, bool) {
	return nil, false
}

// AsModified tries to map PaymentsStarGiftActiveAuctions to PaymentsStarGiftActiveAuctions.
func ( *PaymentsStarGiftActiveAuctions) () (*PaymentsStarGiftActiveAuctions, bool) {
	return , true
}

// DecodePaymentsStarGiftActiveAuctions implements binary de-serialization for PaymentsStarGiftActiveAuctionsClass.
func ( *bin.Buffer) (PaymentsStarGiftActiveAuctionsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PaymentsStarGiftActiveAuctionsNotModifiedTypeID:
		// Decoding payments.starGiftActiveAuctionsNotModified#db33dad0.
		 := PaymentsStarGiftActiveAuctionsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftActiveAuctionsClass: %w", )
		}
		return &, nil
	case PaymentsStarGiftActiveAuctionsTypeID:
		// Decoding payments.starGiftActiveAuctions#aef6abbc.
		 := PaymentsStarGiftActiveAuctions{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftActiveAuctionsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PaymentsStarGiftActiveAuctionsClass: %w", bin.NewUnexpectedID())
	}
}

// PaymentsStarGiftActiveAuctions boxes the PaymentsStarGiftActiveAuctionsClass providing a helper.
type PaymentsStarGiftActiveAuctionsBox struct {
	StarGiftActiveAuctions PaymentsStarGiftActiveAuctionsClass
}

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

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