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

// CommunitiesTogglePeerLinkRequestApprovalRequest represents TL type `communities.togglePeerLinkRequestApproval#8c8219a8`.
//
// See https://core.telegram.org/method/communities.togglePeerLinkRequestApproval for reference.
type CommunitiesTogglePeerLinkRequestApprovalRequest struct {
	// Flags field of CommunitiesTogglePeerLinkRequestApprovalRequest.
	Flags bin.Fields
	// Reject field of CommunitiesTogglePeerLinkRequestApprovalRequest.
	Reject bool
	// Community field of CommunitiesTogglePeerLinkRequestApprovalRequest.
	Community InputChannelClass
	// Peer field of CommunitiesTogglePeerLinkRequestApprovalRequest.
	Peer InputPeerClass
}

// CommunitiesTogglePeerLinkRequestApprovalRequestTypeID is TL type id of CommunitiesTogglePeerLinkRequestApprovalRequest.
const CommunitiesTogglePeerLinkRequestApprovalRequestTypeID = 0x8c8219a8

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

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

	return true
}

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

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *CommunitiesTogglePeerLinkRequestApprovalRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.togglePeerLinkRequestApproval#8c8219a8 as nil")
	}
	.PutID(CommunitiesTogglePeerLinkRequestApprovalRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// GetPeer returns value of Peer field.
func ( *CommunitiesTogglePeerLinkRequestApprovalRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

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

// CommunitiesTogglePeerLinkRequestApproval invokes method communities.togglePeerLinkRequestApproval#8c8219a8 returning error if any.
//
// See https://core.telegram.org/method/communities.togglePeerLinkRequestApproval for reference.
func ( *Client) ( context.Context,  *CommunitiesTogglePeerLinkRequestApprovalRequest) (bool, error) {
	var  BoolBox

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