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

// StarGiftAuctionRound represents TL type `starGiftAuctionRound#3aae0528`.
// Describes one or more collectible gift auction rounds »¹.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/constructor/starGiftAuctionRound for reference.
type StarGiftAuctionRound struct {
	// This object describes all rounds starting from num up until next.num-1 inclusively
	// (next is the next StarGiftAuctionRound¹).
	//
	// Links:
	//  1) https://core.telegram.org/type/StarGiftAuctionRound
	Num int
	// Duration in seconds of the round(s).
	Duration int
}

// StarGiftAuctionRoundTypeID is TL type id of StarGiftAuctionRound.
const StarGiftAuctionRoundTypeID = 0x3aae0528

// construct implements constructor of StarGiftAuctionRoundClass.
func ( StarGiftAuctionRound) () StarGiftAuctionRoundClass { return & }

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

	_ StarGiftAuctionRoundClass = &StarGiftAuctionRound{}
)

func ( *StarGiftAuctionRound) () bool {
	if  == nil {
		return true
	}
	if !(.Num == 0) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAuctionRound from given interface.
func ( *StarGiftAuctionRound) ( interface {
	() ( int)
	() ( int)
}) {
	.Num = .()
	.Duration = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAuctionRound) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAuctionRound",
		ID:   StarGiftAuctionRoundTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Num",
			SchemaName: "num",
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAuctionRound) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionRound#3aae0528 as nil")
	}
	.PutID(StarGiftAuctionRoundTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAuctionRound) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionRound#3aae0528 as nil")
	}
	.PutInt(.Num)
	.PutInt(.Duration)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAuctionRound) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAuctionRound#3aae0528 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRound#3aae0528: field num: %w", )
		}
		.Num = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRound#3aae0528: field duration: %w", )
		}
		.Duration = 
	}
	return nil
}

// GetNum returns value of Num field.
func ( *StarGiftAuctionRound) () ( int) {
	if  == nil {
		return
	}
	return .Num
}

// GetDuration returns value of Duration field.
func ( *StarGiftAuctionRound) () ( int) {
	if  == nil {
		return
	}
	return .Duration
}

// StarGiftAuctionRoundExtendable represents TL type `starGiftAuctionRoundExtendable#aa021e5`.
// Describes one or more extendable collectible gift auction rounds »¹.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/constructor/starGiftAuctionRoundExtendable for reference.
type StarGiftAuctionRoundExtendable struct {
	// This object describes all rounds starting from num up until next.num-1 inclusively
	// (next is the next StarGiftAuctionRound¹).
	//
	// Links:
	//  1) https://core.telegram.org/type/StarGiftAuctionRound
	Num int
	// Duration in seconds of the round(s).
	Duration int
	// The round(s) will be extended by extend_window if a bid changes the composition/order
	// of the top extend_top bidders.
	ExtendTop int
	// The round(s) will be extended by this many seconds if a bid changes the
	// composition/order of the top extend_top bidders.
	ExtendWindow int
}

// StarGiftAuctionRoundExtendableTypeID is TL type id of StarGiftAuctionRoundExtendable.
const StarGiftAuctionRoundExtendableTypeID = 0xaa021e5

// construct implements constructor of StarGiftAuctionRoundClass.
func ( StarGiftAuctionRoundExtendable) () StarGiftAuctionRoundClass { return & }

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

	_ StarGiftAuctionRoundClass = &StarGiftAuctionRoundExtendable{}
)

func ( *StarGiftAuctionRoundExtendable) () bool {
	if  == nil {
		return true
	}
	if !(.Num == 0) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}
	if !(.ExtendTop == 0) {
		return false
	}
	if !(.ExtendWindow == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAuctionRoundExtendable from given interface.
func ( *StarGiftAuctionRoundExtendable) ( interface {
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Num = .()
	.Duration = .()
	.ExtendTop = .()
	.ExtendWindow = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAuctionRoundExtendable) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAuctionRoundExtendable",
		ID:   StarGiftAuctionRoundExtendableTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Num",
			SchemaName: "num",
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
		},
		{
			Name:       "ExtendTop",
			SchemaName: "extend_top",
		},
		{
			Name:       "ExtendWindow",
			SchemaName: "extend_window",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAuctionRoundExtendable) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionRoundExtendable#aa021e5 as nil")
	}
	.PutID(StarGiftAuctionRoundExtendableTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAuctionRoundExtendable) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionRoundExtendable#aa021e5 as nil")
	}
	.PutInt(.Num)
	.PutInt(.Duration)
	.PutInt(.ExtendTop)
	.PutInt(.ExtendWindow)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAuctionRoundExtendable) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAuctionRoundExtendable#aa021e5 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRoundExtendable#aa021e5: field num: %w", )
		}
		.Num = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRoundExtendable#aa021e5: field duration: %w", )
		}
		.Duration = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRoundExtendable#aa021e5: field extend_top: %w", )
		}
		.ExtendTop = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionRoundExtendable#aa021e5: field extend_window: %w", )
		}
		.ExtendWindow = 
	}
	return nil
}

// GetNum returns value of Num field.
func ( *StarGiftAuctionRoundExtendable) () ( int) {
	if  == nil {
		return
	}
	return .Num
}

// GetDuration returns value of Duration field.
func ( *StarGiftAuctionRoundExtendable) () ( int) {
	if  == nil {
		return
	}
	return .Duration
}

// GetExtendTop returns value of ExtendTop field.
func ( *StarGiftAuctionRoundExtendable) () ( int) {
	if  == nil {
		return
	}
	return .ExtendTop
}

// GetExtendWindow returns value of ExtendWindow field.
func ( *StarGiftAuctionRoundExtendable) () ( int) {
	if  == nil {
		return
	}
	return .ExtendWindow
}

// StarGiftAuctionRoundClassName is schema name of StarGiftAuctionRoundClass.
const StarGiftAuctionRoundClassName = "StarGiftAuctionRound"

// StarGiftAuctionRoundClass represents StarGiftAuctionRound generic type.
//
// See https://core.telegram.org/type/StarGiftAuctionRound for reference.
//
// Constructors:
//   - [StarGiftAuctionRound]
//   - [StarGiftAuctionRoundExtendable]
//
// Example:
//
//	g, err := tg.DecodeStarGiftAuctionRound(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StarGiftAuctionRound: // starGiftAuctionRound#3aae0528
//	case *tg.StarGiftAuctionRoundExtendable: // starGiftAuctionRoundExtendable#aa021e5
//	default: panic(v)
//	}
type StarGiftAuctionRoundClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarGiftAuctionRoundClass

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

	// This object describes all rounds starting from num up until next.num-1 inclusively
	// (next is the next StarGiftAuctionRound¹).
	//
	// Links:
	//  1) https://core.telegram.org/type/StarGiftAuctionRound
	GetNum() (value int)

	// Duration in seconds of the round(s).
	GetDuration() (value int)
}

// DecodeStarGiftAuctionRound implements binary de-serialization for StarGiftAuctionRoundClass.
func ( *bin.Buffer) (StarGiftAuctionRoundClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StarGiftAuctionRoundTypeID:
		// Decoding starGiftAuctionRound#3aae0528.
		 := StarGiftAuctionRound{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAuctionRoundClass: %w", )
		}
		return &, nil
	case StarGiftAuctionRoundExtendableTypeID:
		// Decoding starGiftAuctionRoundExtendable#aa021e5.
		 := StarGiftAuctionRoundExtendable{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAuctionRoundClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StarGiftAuctionRoundClass: %w", bin.NewUnexpectedID())
	}
}

// StarGiftAuctionRound boxes the StarGiftAuctionRoundClass providing a helper.
type StarGiftAuctionRoundBox struct {
	StarGiftAuctionRound StarGiftAuctionRoundClass
}

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

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