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

// StatsGetStoryPublicForwardsRequest represents TL type `stats.getStoryPublicForwards#a6437ef6`.
// Obtain forwards of a story¹ as a message to public chats and reposts by public
// channels.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/method/stats.getStoryPublicForwards for reference.
type StatsGetStoryPublicForwardsRequest struct {
	// Peer where the story was originally posted
	Peer InputPeerClass
	// Story¹ ID
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	ID int
	// Offset for pagination, from stats.PublicForwards¹.next_offset.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/stats.publicForwards
	Offset string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// StatsGetStoryPublicForwardsRequestTypeID is TL type id of StatsGetStoryPublicForwardsRequest.
const StatsGetStoryPublicForwardsRequestTypeID = 0xa6437ef6

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

func ( *StatsGetStoryPublicForwardsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsGetStoryPublicForwardsRequest from given interface.
func ( *StatsGetStoryPublicForwardsRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( string)
	() ( int)
}) {
	.Peer = .()
	.ID = .()
	.Offset = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StatsGetStoryPublicForwardsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stats.getStoryPublicForwards",
		ID:   StatsGetStoryPublicForwardsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsGetStoryPublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getStoryPublicForwards#a6437ef6 as nil")
	}
	.PutID(StatsGetStoryPublicForwardsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsGetStoryPublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getStoryPublicForwards#a6437ef6 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stats.getStoryPublicForwards#a6437ef6: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getStoryPublicForwards#a6437ef6: field peer: %w", )
	}
	.PutInt(.ID)
	.PutString(.Offset)
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StatsGetStoryPublicForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getStoryPublicForwards#a6437ef6 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryPublicForwards#a6437ef6: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryPublicForwards#a6437ef6: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryPublicForwards#a6437ef6: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryPublicForwards#a6437ef6: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *StatsGetStoryPublicForwardsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

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

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

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

// StatsGetStoryPublicForwards invokes method stats.getStoryPublicForwards#a6437ef6 returning error if any.
// Obtain forwards of a story¹ as a message to public chats and reposts by public
// channels.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/stats.getStoryPublicForwards for reference.
func ( *Client) ( context.Context,  *StatsGetStoryPublicForwardsRequest) (*StatsPublicForwards, error) {
	var  StatsPublicForwards

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