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

// GroupCallDonor represents TL type `groupCallDonor#ee430c85`.
//
// See https://core.telegram.org/constructor/groupCallDonor for reference.
type GroupCallDonor struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Top field of GroupCallDonor.
	Top bool
	// My field of GroupCallDonor.
	My bool
	// PeerID field of GroupCallDonor.
	//
	// Use SetPeerID and GetPeerID helpers.
	PeerID PeerClass
	// Stars field of GroupCallDonor.
	Stars int64
}

// GroupCallDonorTypeID is TL type id of GroupCallDonor.
const GroupCallDonorTypeID = 0xee430c85

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

func ( *GroupCallDonor) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Top == false) {
		return false
	}
	if !(.My == false) {
		return false
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills GroupCallDonor from given interface.
func ( *GroupCallDonor) ( interface {
	() ( bool)
	() ( bool)
	() ( PeerClass,  bool)
	() ( int64)
}) {
	.Top = .()
	.My = .()
	if ,  := .();  {
		.PeerID = 
	}

	.Stars = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *GroupCallDonor) () tdp.Type {
	 := tdp.Type{
		Name: "groupCallDonor",
		ID:   GroupCallDonorTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Top",
			SchemaName: "top",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "My",
			SchemaName: "my",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *GroupCallDonor) () {
	if !(.Top == false) {
		.Flags.Set(0)
	}
	if !(.My == false) {
		.Flags.Set(1)
	}
	if !(.PeerID == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *GroupCallDonor) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode groupCallDonor#ee430c85 as nil")
	}
	.PutID(GroupCallDonorTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *GroupCallDonor) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode groupCallDonor#ee430c85 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode groupCallDonor#ee430c85: field flags: %w", )
	}
	if .Flags.Has(3) {
		if .PeerID == nil {
			return fmt.Errorf("unable to encode groupCallDonor#ee430c85: field peer_id is nil")
		}
		if  := .PeerID.Encode();  != nil {
			return fmt.Errorf("unable to encode groupCallDonor#ee430c85: field peer_id: %w", )
		}
	}
	.PutLong(.Stars)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *GroupCallDonor) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode groupCallDonor#ee430c85 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode groupCallDonor#ee430c85: field flags: %w", )
		}
	}
	.Top = .Flags.Has(0)
	.My = .Flags.Has(1)
	if .Flags.Has(3) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode groupCallDonor#ee430c85: field peer_id: %w", )
		}
		.PeerID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode groupCallDonor#ee430c85: field stars: %w", )
		}
		.Stars = 
	}
	return nil
}

// SetTop sets value of Top conditional field.
func ( *GroupCallDonor) ( bool) {
	if  {
		.Flags.Set(0)
		.Top = true
	} else {
		.Flags.Unset(0)
		.Top = false
	}
}

// GetTop returns value of Top conditional field.
func ( *GroupCallDonor) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetMy sets value of My conditional field.
func ( *GroupCallDonor) ( bool) {
	if  {
		.Flags.Set(1)
		.My = true
	} else {
		.Flags.Unset(1)
		.My = false
	}
}

// GetMy returns value of My conditional field.
func ( *GroupCallDonor) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetPeerID sets value of PeerID conditional field.
func ( *GroupCallDonor) ( PeerClass) {
	.Flags.Set(3)
	.PeerID = 
}

// GetPeerID returns value of PeerID conditional field and
// boolean which is true if field was set.
func ( *GroupCallDonor) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .PeerID, true
}

// GetStars returns value of Stars field.
func ( *GroupCallDonor) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}