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

// CommunitiesToggleParticipantBannedRequest represents TL type `communities.toggleParticipantBanned#9967ad0f`.
//
// See https://core.telegram.org/method/communities.toggleParticipantBanned for reference.
type CommunitiesToggleParticipantBannedRequest struct {
	// Flags field of CommunitiesToggleParticipantBannedRequest.
	Flags bin.Fields
	// Unban field of CommunitiesToggleParticipantBannedRequest.
	Unban bool
	// Community field of CommunitiesToggleParticipantBannedRequest.
	Community InputChannelClass
	// Participant field of CommunitiesToggleParticipantBannedRequest.
	Participant InputPeerClass
}

// CommunitiesToggleParticipantBannedRequestTypeID is TL type id of CommunitiesToggleParticipantBannedRequest.
const CommunitiesToggleParticipantBannedRequestTypeID = 0x9967ad0f

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

func ( *CommunitiesToggleParticipantBannedRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Unban == false) {
		return false
	}
	if !(.Community == nil) {
		return false
	}
	if !(.Participant == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CommunitiesToggleParticipantBannedRequest from given interface.
func ( *CommunitiesToggleParticipantBannedRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( InputPeerClass)
}) {
	.Unban = .()
	.Community = .()
	.Participant = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *CommunitiesToggleParticipantBannedRequest) () tdp.Type {
	 := tdp.Type{
		Name: "communities.toggleParticipantBanned",
		ID:   CommunitiesToggleParticipantBannedRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Unban",
			SchemaName: "unban",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Community",
			SchemaName: "community",
		},
		{
			Name:       "Participant",
			SchemaName: "participant",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *CommunitiesToggleParticipantBannedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.toggleParticipantBanned#9967ad0f as nil")
	}
	.PutID(CommunitiesToggleParticipantBannedRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *CommunitiesToggleParticipantBannedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.toggleParticipantBanned#9967ad0f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode communities.toggleParticipantBanned#9967ad0f: field flags: %w", )
		}
	}
	.Unban = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode communities.toggleParticipantBanned#9967ad0f: field community: %w", )
		}
		.Community = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode communities.toggleParticipantBanned#9967ad0f: field participant: %w", )
		}
		.Participant = 
	}
	return nil
}

// SetUnban sets value of Unban conditional field.
func ( *CommunitiesToggleParticipantBannedRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Unban = true
	} else {
		.Flags.Unset(0)
		.Unban = false
	}
}

// GetUnban returns value of Unban conditional field.
func ( *CommunitiesToggleParticipantBannedRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetParticipant returns value of Participant field.
func ( *CommunitiesToggleParticipantBannedRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Participant
}

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

// CommunitiesToggleParticipantBanned invokes method communities.toggleParticipantBanned#9967ad0f returning error if any.
//
// See https://core.telegram.org/method/communities.toggleParticipantBanned for reference.
func ( *Client) ( context.Context,  *CommunitiesToggleParticipantBannedRequest) (bool, error) {
	var  BoolBox

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