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

// ChannelsGetParticipantsRequest represents TL type `channels.getParticipants#77ced9d0`.
// Get the participants of a supergroup/channel¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.getParticipants for reference.
type ChannelsGetParticipantsRequest struct {
	// Channel
	Channel InputChannelClass
	// Which participant types to fetch
	Filter ChannelParticipantsFilterClass
	// Offset¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Offset int
	// Limit¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
	// Hash¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Hash int64
}

// ChannelsGetParticipantsRequestTypeID is TL type id of ChannelsGetParticipantsRequest.
const ChannelsGetParticipantsRequestTypeID = 0x77ced9d0

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

func ( *ChannelsGetParticipantsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Filter == nil) {
		return false
	}
	if !(.Offset == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetParticipantsRequest from given interface.
func ( *ChannelsGetParticipantsRequest) ( interface {
	() ( InputChannelClass)
	() ( ChannelParticipantsFilterClass)
	() ( int)
	() ( int)
	() ( int64)
}) {
	.Channel = .()
	.Filter = .()
	.Offset = .()
	.Limit = .()
	.Hash = .()
}

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

// TypeName returns name of type in TL schema.
func (*ChannelsGetParticipantsRequest) () string {
	return "channels.getParticipants"
}

// TypeInfo returns info about TL type.
func ( *ChannelsGetParticipantsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getParticipants",
		ID:   ChannelsGetParticipantsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Filter",
			SchemaName: "filter",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsGetParticipantsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getParticipants#77ced9d0 as nil")
	}
	.PutID(ChannelsGetParticipantsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetParticipantsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getParticipants#77ced9d0 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.getParticipants#77ced9d0: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getParticipants#77ced9d0: field channel: %w", )
	}
	if .Filter == nil {
		return fmt.Errorf("unable to encode channels.getParticipants#77ced9d0: field filter is nil")
	}
	if  := .Filter.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getParticipants#77ced9d0: field filter: %w", )
	}
	.PutInt(.Offset)
	.PutInt(.Limit)
	.PutLong(.Hash)
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsGetParticipantsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getParticipants#77ced9d0 to nil")
	}
	if  := .ConsumeID(ChannelsGetParticipantsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetParticipantsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getParticipants#77ced9d0 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := DecodeChannelParticipantsFilter()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: field filter: %w", )
		}
		.Filter = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: field limit: %w", )
		}
		.Limit = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getParticipants#77ced9d0: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// GetChannel returns value of Channel field.
func ( *ChannelsGetParticipantsRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

// GetFilter returns value of Filter field.
func ( *ChannelsGetParticipantsRequest) () ( ChannelParticipantsFilterClass) {
	if  == nil {
		return
	}
	return .Filter
}

// GetOffset returns value of Offset field.
func ( *ChannelsGetParticipantsRequest) () ( int) {
	if  == nil {
		return
	}
	return .Offset
}

// GetLimit returns value of Limit field.
func ( *ChannelsGetParticipantsRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// GetHash returns value of Hash field.
func ( *ChannelsGetParticipantsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *ChannelsGetParticipantsRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// ChannelsGetParticipants invokes method channels.getParticipants#77ced9d0 returning error if any.
// Get the participants of a supergroup/channel¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/channels.getParticipants for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsGetParticipantsRequest) (ChannelsChannelParticipantsClass, error) {
	var  ChannelsChannelParticipantsBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .ChannelParticipants, nil
}