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

// PaymentsStarGiftsNotModified represents TL type `payments.starGiftsNotModified#a388a368`.
// The list of available gifts »¹ hasn't changed.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/payments.starGiftsNotModified for reference.
type PaymentsStarGiftsNotModified struct {
}

// PaymentsStarGiftsNotModifiedTypeID is TL type id of PaymentsStarGiftsNotModified.
const PaymentsStarGiftsNotModifiedTypeID = 0xa388a368

// construct implements constructor of PaymentsStarGiftsClass.
func ( PaymentsStarGiftsNotModified) () PaymentsStarGiftsClass { return & }

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

	_ PaymentsStarGiftsClass = &PaymentsStarGiftsNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftsNotModified#a388a368 as nil")
	}
	.PutID(PaymentsStarGiftsNotModifiedTypeID)
	return .EncodeBare()
}

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

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

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

// PaymentsStarGifts represents TL type `payments.starGifts#2ed82995`.
// Available gifts »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/payments.starGifts for reference.
type PaymentsStarGifts struct {
	// Hash used for caching, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
	// List of available gifts.
	Gifts []StarGiftClass
	// Chats mentioned in the gifts field.
	Chats []ChatClass
	// Users mentioned in the gifts field.
	Users []UserClass
}

// PaymentsStarGiftsTypeID is TL type id of PaymentsStarGifts.
const PaymentsStarGiftsTypeID = 0x2ed82995

// construct implements constructor of PaymentsStarGiftsClass.
func ( PaymentsStarGifts) () PaymentsStarGiftsClass { return & }

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

	_ PaymentsStarGiftsClass = &PaymentsStarGifts{}
)

func ( *PaymentsStarGifts) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Gifts == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsStarGifts from given interface.
func ( *PaymentsStarGifts) ( interface {
	() ( int)
	() ( []StarGiftClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Hash = .()
	.Gifts = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsStarGifts) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGifts",
		ID:   PaymentsStarGiftsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Gifts",
			SchemaName: "gifts",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGifts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGifts#2ed82995 as nil")
	}
	.PutID(PaymentsStarGiftsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGifts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGifts#2ed82995 as nil")
	}
	.PutInt(.Hash)
	.PutVectorHeader(len(.Gifts))
	for ,  := range .Gifts {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field gifts element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field gifts element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGifts#2ed82995: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsStarGifts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGifts#2ed82995 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGifts#2ed82995: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGifts#2ed82995: field gifts: %w", )
		}

		if  > 0 {
			.Gifts = make([]StarGiftClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStarGift()
			if  != nil {
				return fmt.Errorf("unable to decode payments.starGifts#2ed82995: field gifts: %w", )
			}
			.Gifts = append(.Gifts, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGifts#2ed82995: field chats: %w", )
		}

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

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

// GetHash returns value of Hash field.
func ( *PaymentsStarGifts) () ( int) {
	if  == nil {
		return
	}
	return .Hash
}

// GetGifts returns value of Gifts field.
func ( *PaymentsStarGifts) () ( []StarGiftClass) {
	if  == nil {
		return
	}
	return .Gifts
}

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

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

// MapGifts returns field Gifts wrapped in StarGiftClassArray helper.
func ( *PaymentsStarGifts) () ( StarGiftClassArray) {
	return StarGiftClassArray(.Gifts)
}

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

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

// PaymentsStarGiftsClassName is schema name of PaymentsStarGiftsClass.
const PaymentsStarGiftsClassName = "payments.StarGifts"

// PaymentsStarGiftsClass represents payments.StarGifts generic type.
//
// See https://core.telegram.org/type/payments.StarGifts for reference.
//
// Constructors:
//   - [PaymentsStarGiftsNotModified]
//   - [PaymentsStarGifts]
//
// Example:
//
//	g, err := tg.DecodePaymentsStarGifts(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PaymentsStarGiftsNotModified: // payments.starGiftsNotModified#a388a368
//	case *tg.PaymentsStarGifts: // payments.starGifts#2ed82995
//	default: panic(v)
//	}
type PaymentsStarGiftsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PaymentsStarGiftsClass

	// 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 PaymentsStarGiftsClass to PaymentsStarGifts.
	AsModified() (*PaymentsStarGifts, bool)
}

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

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

// DecodePaymentsStarGifts implements binary de-serialization for PaymentsStarGiftsClass.
func ( *bin.Buffer) (PaymentsStarGiftsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PaymentsStarGiftsNotModifiedTypeID:
		// Decoding payments.starGiftsNotModified#a388a368.
		 := PaymentsStarGiftsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", )
		}
		return &, nil
	case PaymentsStarGiftsTypeID:
		// Decoding payments.starGifts#2ed82995.
		 := PaymentsStarGifts{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PaymentsStarGiftsClass: %w", bin.NewUnexpectedID())
	}
}

// PaymentsStarGifts boxes the PaymentsStarGiftsClass providing a helper.
type PaymentsStarGiftsBox struct {
	StarGifts PaymentsStarGiftsClass
}

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

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