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

// StatsGetMessagePublicForwardsRequest represents TL type `stats.getMessagePublicForwards#5f150144`.
// Obtains a list of messages, indicating to which other public channels was a channel
// message forwarded.
// Will return a list of messages¹ with peer_id equal to the public channel to which
// this message was forwarded.
//
// Links:
//  1. https://core.telegram.org/constructor/message
//
// See https://core.telegram.org/method/stats.getMessagePublicForwards for reference.
type StatsGetMessagePublicForwardsRequest struct {
	// Source channel
	Channel InputChannelClass
	// Source message ID
	MsgID int
	// Offset field of StatsGetMessagePublicForwardsRequest.
	Offset string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// StatsGetMessagePublicForwardsRequestTypeID is TL type id of StatsGetMessagePublicForwardsRequest.
const StatsGetMessagePublicForwardsRequestTypeID = 0x5f150144

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

func ( *StatsGetMessagePublicForwardsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsGetMessagePublicForwardsRequest from given interface.
func ( *StatsGetMessagePublicForwardsRequest) ( interface {
	() ( InputChannelClass)
	() ( int)
	() ( string)
	() ( int)
}) {
	.Channel = .()
	.MsgID = .()
	.Offset = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*StatsGetMessagePublicForwardsRequest) () string {
	return "stats.getMessagePublicForwards"
}

// TypeInfo returns info about TL type.
func ( *StatsGetMessagePublicForwardsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stats.getMessagePublicForwards",
		ID:   StatsGetMessagePublicForwardsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsGetMessagePublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getMessagePublicForwards#5f150144 as nil")
	}
	.PutID(StatsGetMessagePublicForwardsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsGetMessagePublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getMessagePublicForwards#5f150144 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode stats.getMessagePublicForwards#5f150144: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getMessagePublicForwards#5f150144: field channel: %w", )
	}
	.PutInt(.MsgID)
	.PutString(.Offset)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsGetMessagePublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getMessagePublicForwards#5f150144 to nil")
	}
	if  := .ConsumeID(StatsGetMessagePublicForwardsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stats.getMessagePublicForwards#5f150144: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsGetMessagePublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getMessagePublicForwards#5f150144 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessagePublicForwards#5f150144: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessagePublicForwards#5f150144: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessagePublicForwards#5f150144: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessagePublicForwards#5f150144: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

// GetMsgID returns value of MsgID field.
func ( *StatsGetMessagePublicForwardsRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

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

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

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

// StatsGetMessagePublicForwards invokes method stats.getMessagePublicForwards#5f150144 returning error if any.
// Obtains a list of messages, indicating to which other public channels was a channel
// message forwarded.
// Will return a list of messages¹ with peer_id equal to the public channel to which
// this message was forwarded.
//
// Links:
//  1. https://core.telegram.org/constructor/message
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/stats.getMessagePublicForwards for reference.
func ( *Client) ( context.Context,  *StatsGetMessagePublicForwardsRequest) (*StatsPublicForwards, error) {
	var  StatsPublicForwards

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