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

// ChannelsGetAdminLogRequest represents TL type `channels.getAdminLog#33ddf480`.
// Get the admin log of a channel/supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.getAdminLog for reference.
type ChannelsGetAdminLogRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Channel
	Channel InputChannelClass
	// Search query, can be empty
	Q string
	// Event filter
	//
	// Use SetEventsFilter and GetEventsFilter helpers.
	EventsFilter ChannelAdminLogEventsFilter
	// Only show events from these admins
	//
	// Use SetAdmins and GetAdmins helpers.
	Admins []InputUserClass
	// Maximum ID of message to return (see pagination¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	MaxID int64
	// Minimum ID of message to return (see pagination¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	MinID int64
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// ChannelsGetAdminLogRequestTypeID is TL type id of ChannelsGetAdminLogRequest.
const ChannelsGetAdminLogRequestTypeID = 0x33ddf480

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

func ( *ChannelsGetAdminLogRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Q == "") {
		return false
	}
	if !(.EventsFilter.Zero()) {
		return false
	}
	if !(.Admins == nil) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}
	if !(.MinID == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetAdminLogRequest from given interface.
func ( *ChannelsGetAdminLogRequest) ( interface {
	() ( InputChannelClass)
	() ( string)
	() ( ChannelAdminLogEventsFilter,  bool)
	() ( []InputUserClass,  bool)
	() ( int64)
	() ( int64)
	() ( int)
}) {
	.Channel = .()
	.Q = .()
	if ,  := .();  {
		.EventsFilter = 
	}

	if ,  := .();  {
		.Admins = 
	}

	.MaxID = .()
	.MinID = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsGetAdminLogRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getAdminLog",
		ID:   ChannelsGetAdminLogRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Q",
			SchemaName: "q",
		},
		{
			Name:       "EventsFilter",
			SchemaName: "events_filter",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Admins",
			SchemaName: "admins",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
		},
		{
			Name:       "MinID",
			SchemaName: "min_id",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsGetAdminLogRequest) () {
	if !(.EventsFilter.Zero()) {
		.Flags.Set(0)
	}
	if !(.Admins == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsGetAdminLogRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getAdminLog#33ddf480 as nil")
	}
	.PutID(ChannelsGetAdminLogRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetAdminLogRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getAdminLog#33ddf480 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field channel: %w", )
	}
	.PutString(.Q)
	if .Flags.Has(0) {
		if  := .EventsFilter.Encode();  != nil {
			return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field events_filter: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.Admins))
		for ,  := range .Admins {
			if  == nil {
				return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field admins element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode channels.getAdminLog#33ddf480: field admins element with index %d: %w", , )
			}
		}
	}
	.PutLong(.MaxID)
	.PutLong(.MinID)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsGetAdminLogRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getAdminLog#33ddf480 to nil")
	}
	if  := .ConsumeID(ChannelsGetAdminLogRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetAdminLogRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getAdminLog#33ddf480 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field flags: %w", )
		}
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field q: %w", )
		}
		.Q = 
	}
	if .Flags.Has(0) {
		if  := .EventsFilter.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field events_filter: %w", )
		}
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field admins: %w", )
		}

		if  > 0 {
			.Admins = make([]InputUserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputUser()
			if  != nil {
				return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field admins: %w", )
			}
			.Admins = append(.Admins, )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field max_id: %w", )
		}
		.MaxID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field min_id: %w", )
		}
		.MinID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getAdminLog#33ddf480: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

// GetQ returns value of Q field.
func ( *ChannelsGetAdminLogRequest) () ( string) {
	if  == nil {
		return
	}
	return .Q
}

// SetEventsFilter sets value of EventsFilter conditional field.
func ( *ChannelsGetAdminLogRequest) ( ChannelAdminLogEventsFilter) {
	.Flags.Set(0)
	.EventsFilter = 
}

// GetEventsFilter returns value of EventsFilter conditional field and
// boolean which is true if field was set.
func ( *ChannelsGetAdminLogRequest) () ( ChannelAdminLogEventsFilter,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .EventsFilter, true
}

// SetAdmins sets value of Admins conditional field.
func ( *ChannelsGetAdminLogRequest) ( []InputUserClass) {
	.Flags.Set(1)
	.Admins = 
}

// GetAdmins returns value of Admins conditional field and
// boolean which is true if field was set.
func ( *ChannelsGetAdminLogRequest) () ( []InputUserClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Admins, true
}

// GetMaxID returns value of MaxID field.
func ( *ChannelsGetAdminLogRequest) () ( int64) {
	if  == nil {
		return
	}
	return .MaxID
}

// GetMinID returns value of MinID field.
func ( *ChannelsGetAdminLogRequest) () ( int64) {
	if  == nil {
		return
	}
	return .MinID
}

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

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

// MapAdmins returns field Admins wrapped in InputUserClassArray helper.
func ( *ChannelsGetAdminLogRequest) () ( InputUserClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return InputUserClassArray(.Admins), true
}

// ChannelsGetAdminLog invokes method channels.getAdminLog#33ddf480 returning error if any.
// Get the admin log of a channel/supergroup¹
//
// 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.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/channels.getAdminLog for reference.
func ( *Client) ( context.Context,  *ChannelsGetAdminLogRequest) (*ChannelsAdminLogResults, error) {
	var  ChannelsAdminLogResults

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