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

// PaymentsStarGiftCollectionsNotModified represents TL type `payments.starGiftCollectionsNotModified#a0ba4f17`.
// The list of star gift collections »¹ hasn't changed.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// See https://core.telegram.org/constructor/payments.starGiftCollectionsNotModified for reference.
type PaymentsStarGiftCollectionsNotModified struct {
}

// PaymentsStarGiftCollectionsNotModifiedTypeID is TL type id of PaymentsStarGiftCollectionsNotModified.
const PaymentsStarGiftCollectionsNotModifiedTypeID = 0xa0ba4f17

// construct implements constructor of PaymentsStarGiftCollectionsClass.
func ( PaymentsStarGiftCollectionsNotModified) () PaymentsStarGiftCollectionsClass {
	return &
}

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

	_ PaymentsStarGiftCollectionsClass = &PaymentsStarGiftCollectionsNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftCollectionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftCollectionsNotModified#a0ba4f17 as nil")
	}
	.PutID(PaymentsStarGiftCollectionsNotModifiedTypeID)
	return .EncodeBare()
}

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

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

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

// PaymentsStarGiftCollections represents TL type `payments.starGiftCollections#8a2932f3`.
// Represents a list of star gift collections »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// See https://core.telegram.org/constructor/payments.starGiftCollections for reference.
type PaymentsStarGiftCollections struct {
	// Star gift collections.
	Collections []StarGiftCollection
}

// PaymentsStarGiftCollectionsTypeID is TL type id of PaymentsStarGiftCollections.
const PaymentsStarGiftCollectionsTypeID = 0x8a2932f3

// construct implements constructor of PaymentsStarGiftCollectionsClass.
func ( PaymentsStarGiftCollections) () PaymentsStarGiftCollectionsClass { return & }

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

	_ PaymentsStarGiftCollectionsClass = &PaymentsStarGiftCollections{}
)

func ( *PaymentsStarGiftCollections) () bool {
	if  == nil {
		return true
	}
	if !(.Collections == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsStarGiftCollections from given interface.
func ( *PaymentsStarGiftCollections) ( interface {
	() ( []StarGiftCollection)
}) {
	.Collections = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsStarGiftCollections) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGiftCollections",
		ID:   PaymentsStarGiftCollectionsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Collections",
			SchemaName: "collections",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftCollections) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftCollections#8a2932f3 as nil")
	}
	.PutID(PaymentsStarGiftCollectionsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGiftCollections) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftCollections#8a2932f3 as nil")
	}
	.PutVectorHeader(len(.Collections))
	for ,  := range .Collections {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftCollections#8a2932f3: field collections element with index %d: %w", , )
		}
	}
	return nil
}

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

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

		if  > 0 {
			.Collections = make([]StarGiftCollection, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StarGiftCollection
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.starGiftCollections#8a2932f3: field collections: %w", )
			}
			.Collections = append(.Collections, )
		}
	}
	return nil
}

// GetCollections returns value of Collections field.
func ( *PaymentsStarGiftCollections) () ( []StarGiftCollection) {
	if  == nil {
		return
	}
	return .Collections
}

// PaymentsStarGiftCollectionsClassName is schema name of PaymentsStarGiftCollectionsClass.
const PaymentsStarGiftCollectionsClassName = "payments.StarGiftCollections"

// PaymentsStarGiftCollectionsClass represents payments.StarGiftCollections generic type.
//
// See https://core.telegram.org/type/payments.StarGiftCollections for reference.
//
// Constructors:
//   - [PaymentsStarGiftCollectionsNotModified]
//   - [PaymentsStarGiftCollections]
//
// Example:
//
//	g, err := tg.DecodePaymentsStarGiftCollections(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PaymentsStarGiftCollectionsNotModified: // payments.starGiftCollectionsNotModified#a0ba4f17
//	case *tg.PaymentsStarGiftCollections: // payments.starGiftCollections#8a2932f3
//	default: panic(v)
//	}
type PaymentsStarGiftCollectionsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PaymentsStarGiftCollectionsClass

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

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

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

// DecodePaymentsStarGiftCollections implements binary de-serialization for PaymentsStarGiftCollectionsClass.
func ( *bin.Buffer) (PaymentsStarGiftCollectionsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PaymentsStarGiftCollectionsNotModifiedTypeID:
		// Decoding payments.starGiftCollectionsNotModified#a0ba4f17.
		 := PaymentsStarGiftCollectionsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", )
		}
		return &, nil
	case PaymentsStarGiftCollectionsTypeID:
		// Decoding payments.starGiftCollections#8a2932f3.
		 := PaymentsStarGiftCollections{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PaymentsStarGiftCollectionsClass: %w", bin.NewUnexpectedID())
	}
}

// PaymentsStarGiftCollections boxes the PaymentsStarGiftCollectionsClass providing a helper.
type PaymentsStarGiftCollectionsBox struct {
	StarGiftCollections PaymentsStarGiftCollectionsClass
}

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

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