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

// HelpTermsOfServiceUpdateEmpty represents TL type `help.termsOfServiceUpdateEmpty#e3309f7f`.
// No changes were made to telegram's terms of service
//
// See https://core.telegram.org/constructor/help.termsOfServiceUpdateEmpty for reference.
type HelpTermsOfServiceUpdateEmpty struct {
	// New TOS updates will have to be queried using help.getTermsOfServiceUpdate¹ in
	// expires seconds
	//
	// Links:
	//  1) https://core.telegram.org/method/help.getTermsOfServiceUpdate
	Expires int
}

// HelpTermsOfServiceUpdateEmptyTypeID is TL type id of HelpTermsOfServiceUpdateEmpty.
const HelpTermsOfServiceUpdateEmptyTypeID = 0xe3309f7f

// construct implements constructor of HelpTermsOfServiceUpdateClass.
func ( HelpTermsOfServiceUpdateEmpty) () HelpTermsOfServiceUpdateClass { return & }

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

	_ HelpTermsOfServiceUpdateClass = &HelpTermsOfServiceUpdateEmpty{}
)

func ( *HelpTermsOfServiceUpdateEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.Expires == 0) {
		return false
	}

	return true
}

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

// FillFrom fills HelpTermsOfServiceUpdateEmpty from given interface.
func ( *HelpTermsOfServiceUpdateEmpty) ( interface {
	() ( int)
}) {
	.Expires = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpTermsOfServiceUpdateEmpty) () string {
	return "help.termsOfServiceUpdateEmpty"
}

// TypeInfo returns info about TL type.
func ( *HelpTermsOfServiceUpdateEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "help.termsOfServiceUpdateEmpty",
		ID:   HelpTermsOfServiceUpdateEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpTermsOfServiceUpdateEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.termsOfServiceUpdateEmpty#e3309f7f as nil")
	}
	.PutID(HelpTermsOfServiceUpdateEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpTermsOfServiceUpdateEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.termsOfServiceUpdateEmpty#e3309f7f as nil")
	}
	.PutInt(.Expires)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *HelpTermsOfServiceUpdateEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.termsOfServiceUpdateEmpty#e3309f7f to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.termsOfServiceUpdateEmpty#e3309f7f: field expires: %w", )
		}
		.Expires = 
	}
	return nil
}

// GetExpires returns value of Expires field.
func ( *HelpTermsOfServiceUpdateEmpty) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// HelpTermsOfServiceUpdate represents TL type `help.termsOfServiceUpdate#28ecf961`.
// Info about an update of telegram's terms of service. If the terms of service are
// declined, then the account.deleteAccount¹ method should be called with the reason
// "Decline ToS update"
//
// Links:
//  1. https://core.telegram.org/method/account.deleteAccount
//
// See https://core.telegram.org/constructor/help.termsOfServiceUpdate for reference.
type HelpTermsOfServiceUpdate struct {
	// New TOS updates will have to be queried using help.getTermsOfServiceUpdate¹ in
	// expires seconds
	//
	// Links:
	//  1) https://core.telegram.org/method/help.getTermsOfServiceUpdate
	Expires int
	// New terms of service
	TermsOfService HelpTermsOfService
}

// HelpTermsOfServiceUpdateTypeID is TL type id of HelpTermsOfServiceUpdate.
const HelpTermsOfServiceUpdateTypeID = 0x28ecf961

// construct implements constructor of HelpTermsOfServiceUpdateClass.
func ( HelpTermsOfServiceUpdate) () HelpTermsOfServiceUpdateClass { return & }

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

	_ HelpTermsOfServiceUpdateClass = &HelpTermsOfServiceUpdate{}
)

func ( *HelpTermsOfServiceUpdate) () bool {
	if  == nil {
		return true
	}
	if !(.Expires == 0) {
		return false
	}
	if !(.TermsOfService.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills HelpTermsOfServiceUpdate from given interface.
func ( *HelpTermsOfServiceUpdate) ( interface {
	() ( int)
	() ( HelpTermsOfService)
}) {
	.Expires = .()
	.TermsOfService = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpTermsOfServiceUpdate) () string {
	return "help.termsOfServiceUpdate"
}

// TypeInfo returns info about TL type.
func ( *HelpTermsOfServiceUpdate) () tdp.Type {
	 := tdp.Type{
		Name: "help.termsOfServiceUpdate",
		ID:   HelpTermsOfServiceUpdateTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
		{
			Name:       "TermsOfService",
			SchemaName: "terms_of_service",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpTermsOfServiceUpdate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.termsOfServiceUpdate#28ecf961 as nil")
	}
	.PutID(HelpTermsOfServiceUpdateTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpTermsOfServiceUpdate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.termsOfServiceUpdate#28ecf961 as nil")
	}
	.PutInt(.Expires)
	if  := .TermsOfService.Encode();  != nil {
		return fmt.Errorf("unable to encode help.termsOfServiceUpdate#28ecf961: field terms_of_service: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpTermsOfServiceUpdate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.termsOfServiceUpdate#28ecf961 to nil")
	}
	if  := .ConsumeID(HelpTermsOfServiceUpdateTypeID);  != nil {
		return fmt.Errorf("unable to decode help.termsOfServiceUpdate#28ecf961: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpTermsOfServiceUpdate) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.termsOfServiceUpdate#28ecf961 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.termsOfServiceUpdate#28ecf961: field expires: %w", )
		}
		.Expires = 
	}
	{
		if  := .TermsOfService.Decode();  != nil {
			return fmt.Errorf("unable to decode help.termsOfServiceUpdate#28ecf961: field terms_of_service: %w", )
		}
	}
	return nil
}

// GetExpires returns value of Expires field.
func ( *HelpTermsOfServiceUpdate) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// GetTermsOfService returns value of TermsOfService field.
func ( *HelpTermsOfServiceUpdate) () ( HelpTermsOfService) {
	if  == nil {
		return
	}
	return .TermsOfService
}

// HelpTermsOfServiceUpdateClassName is schema name of HelpTermsOfServiceUpdateClass.
const HelpTermsOfServiceUpdateClassName = "help.TermsOfServiceUpdate"

// HelpTermsOfServiceUpdateClass represents help.TermsOfServiceUpdate generic type.
//
// See https://core.telegram.org/type/help.TermsOfServiceUpdate for reference.
//
// Example:
//
//	g, err := tg.DecodeHelpTermsOfServiceUpdate(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.HelpTermsOfServiceUpdateEmpty: // help.termsOfServiceUpdateEmpty#e3309f7f
//	case *tg.HelpTermsOfServiceUpdate: // help.termsOfServiceUpdate#28ecf961
//	default: panic(v)
//	}
type HelpTermsOfServiceUpdateClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() HelpTermsOfServiceUpdateClass

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

	// New TOS updates will have to be queried using help.getTermsOfServiceUpdate¹ in
	// expires seconds
	//
	// Links:
	//  1) https://core.telegram.org/method/help.getTermsOfServiceUpdate
	GetExpires() (value int)

	// AsNotEmpty tries to map HelpTermsOfServiceUpdateClass to HelpTermsOfServiceUpdate.
	AsNotEmpty() (*HelpTermsOfServiceUpdate, bool)
}

// AsNotEmpty tries to map HelpTermsOfServiceUpdateEmpty to HelpTermsOfServiceUpdate.
func ( *HelpTermsOfServiceUpdateEmpty) () (*HelpTermsOfServiceUpdate, bool) {
	return nil, false
}

// AsNotEmpty tries to map HelpTermsOfServiceUpdate to HelpTermsOfServiceUpdate.
func ( *HelpTermsOfServiceUpdate) () (*HelpTermsOfServiceUpdate, bool) {
	return , true
}

// DecodeHelpTermsOfServiceUpdate implements binary de-serialization for HelpTermsOfServiceUpdateClass.
func ( *bin.Buffer) (HelpTermsOfServiceUpdateClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case HelpTermsOfServiceUpdateEmptyTypeID:
		// Decoding help.termsOfServiceUpdateEmpty#e3309f7f.
		 := HelpTermsOfServiceUpdateEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpTermsOfServiceUpdateClass: %w", )
		}
		return &, nil
	case HelpTermsOfServiceUpdateTypeID:
		// Decoding help.termsOfServiceUpdate#28ecf961.
		 := HelpTermsOfServiceUpdate{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpTermsOfServiceUpdateClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode HelpTermsOfServiceUpdateClass: %w", bin.NewUnexpectedID())
	}
}

// HelpTermsOfServiceUpdate boxes the HelpTermsOfServiceUpdateClass providing a helper.
type HelpTermsOfServiceUpdateBox struct {
	TermsOfServiceUpdate HelpTermsOfServiceUpdateClass
}

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

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