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

// ChannelsGetMessageAuthorRequest represents TL type `channels.getMessageAuthor#ece2a0e6`.
// Can only be invoked by non-bot admins of a monoforum »¹, obtains the original sender
// of a message sent by other monoforum admins to the monoforum, on behalf of the channel
// associated to the monoforum.
//
// Links:
//  1. https://core.telegram.org/api/monoforum
//
// See https://core.telegram.org/method/channels.getMessageAuthor for reference.
type ChannelsGetMessageAuthorRequest struct {
	// ID of the monoforum.
	Channel InputChannelClass
	// ID of the message sent by a monoforum admin.
	ID int
}

// ChannelsGetMessageAuthorRequestTypeID is TL type id of ChannelsGetMessageAuthorRequest.
const ChannelsGetMessageAuthorRequestTypeID = 0xece2a0e6

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

func ( *ChannelsGetMessageAuthorRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetMessageAuthorRequest from given interface.
func ( *ChannelsGetMessageAuthorRequest) ( interface {
	() ( InputChannelClass)
	() ( int)
}) {
	.Channel = .()
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsGetMessageAuthorRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getMessageAuthor",
		ID:   ChannelsGetMessageAuthorRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsGetMessageAuthorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getMessageAuthor#ece2a0e6 as nil")
	}
	.PutID(ChannelsGetMessageAuthorRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetMessageAuthorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getMessageAuthor#ece2a0e6 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.getMessageAuthor#ece2a0e6: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getMessageAuthor#ece2a0e6: field channel: %w", )
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetMessageAuthorRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getMessageAuthor#ece2a0e6 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getMessageAuthor#ece2a0e6: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getMessageAuthor#ece2a0e6: field id: %w", )
		}
		.ID = 
	}
	return nil
}

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

// GetID returns value of ID field.
func ( *ChannelsGetMessageAuthorRequest) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

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

// ChannelsGetMessageAuthor invokes method channels.getMessageAuthor#ece2a0e6 returning error if any.
// Can only be invoked by non-bot admins of a monoforum »¹, obtains the original sender
// of a message sent by other monoforum admins to the monoforum, on behalf of the channel
// associated to the monoforum.
//
// Links:
//  1. https://core.telegram.org/api/monoforum
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.getMessageAuthor for reference.
func ( *Client) ( context.Context,  *ChannelsGetMessageAuthorRequest) (UserClass, error) {
	var  UserBox

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