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

// CommunitiesToggleAllPeerLinkRequestApprovalRequest represents TL type `communities.toggleAllPeerLinkRequestApproval#bfe3dd3d`.
//
// See https://core.telegram.org/method/communities.toggleAllPeerLinkRequestApproval for reference.
type CommunitiesToggleAllPeerLinkRequestApprovalRequest struct {
	// Flags field of CommunitiesToggleAllPeerLinkRequestApprovalRequest.
	Flags bin.Fields
	// Reject field of CommunitiesToggleAllPeerLinkRequestApprovalRequest.
	Reject bool
	// Community field of CommunitiesToggleAllPeerLinkRequestApprovalRequest.
	Community InputChannelClass
}

// CommunitiesToggleAllPeerLinkRequestApprovalRequestTypeID is TL type id of CommunitiesToggleAllPeerLinkRequestApprovalRequest.
const CommunitiesToggleAllPeerLinkRequestApprovalRequestTypeID = 0xbfe3dd3d

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

func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Reject == false) {
		return false
	}
	if !(.Community == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CommunitiesToggleAllPeerLinkRequestApprovalRequest from given interface.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
}) {
	.Reject = .()
	.Community = .()
}

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

// TypeName returns name of type in TL schema.
func (*CommunitiesToggleAllPeerLinkRequestApprovalRequest) () string {
	return "communities.toggleAllPeerLinkRequestApproval"
}

// TypeInfo returns info about TL type.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () tdp.Type {
	 := tdp.Type{
		Name: "communities.toggleAllPeerLinkRequestApproval",
		ID:   CommunitiesToggleAllPeerLinkRequestApprovalRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Reject",
			SchemaName: "reject",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Community",
			SchemaName: "community",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () {
	if !(.Reject == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d as nil")
	}
	.PutID(CommunitiesToggleAllPeerLinkRequestApprovalRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d: field flags: %w", )
	}
	if .Community == nil {
		return fmt.Errorf("unable to encode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d: field community is nil")
	}
	if  := .Community.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d: field community: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d: field flags: %w", )
		}
	}
	.Reject = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode communities.toggleAllPeerLinkRequestApproval#bfe3dd3d: field community: %w", )
		}
		.Community = 
	}
	return nil
}

// SetReject sets value of Reject conditional field.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Reject = true
	} else {
		.Flags.Unset(0)
		.Reject = false
	}
}

// GetReject returns value of Reject conditional field.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetCommunity returns value of Community field.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Community
}

// GetCommunityAsNotEmpty returns mapped value of Community field.
func ( *CommunitiesToggleAllPeerLinkRequestApprovalRequest) () (NotEmptyInputChannel, bool) {
	return .Community.AsNotEmpty()
}

// CommunitiesToggleAllPeerLinkRequestApproval invokes method communities.toggleAllPeerLinkRequestApproval#bfe3dd3d returning error if any.
//
// See https://core.telegram.org/method/communities.toggleAllPeerLinkRequestApproval for reference.
func ( *Client) ( context.Context,  *CommunitiesToggleAllPeerLinkRequestApprovalRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}