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

// StoriesGetPinnedStoriesRequest represents TL type `stories.getPinnedStories#5821a5dc`.
// Fetch the stories¹ pinned on a peer's profile.
//
// Links:
//  1. https://core.telegram.org/api/stories#pinned-or-archived-stories
//
// See https://core.telegram.org/method/stories.getPinnedStories for reference.
type StoriesGetPinnedStoriesRequest struct {
	// Peer whose pinned stories should be fetched
	Peer InputPeerClass
	// Offsets for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetID int
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// StoriesGetPinnedStoriesRequestTypeID is TL type id of StoriesGetPinnedStoriesRequest.
const StoriesGetPinnedStoriesRequestTypeID = 0x5821a5dc

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

func ( *StoriesGetPinnedStoriesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.OffsetID == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesGetPinnedStoriesRequest from given interface.
func ( *StoriesGetPinnedStoriesRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int)
}) {
	.Peer = .()
	.OffsetID = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*StoriesGetPinnedStoriesRequest) () string {
	return "stories.getPinnedStories"
}

// TypeInfo returns info about TL type.
func ( *StoriesGetPinnedStoriesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.getPinnedStories",
		ID:   StoriesGetPinnedStoriesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "OffsetID",
			SchemaName: "offset_id",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesGetPinnedStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getPinnedStories#5821a5dc as nil")
	}
	.PutID(StoriesGetPinnedStoriesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesGetPinnedStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getPinnedStories#5821a5dc as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stories.getPinnedStories#5821a5dc: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.getPinnedStories#5821a5dc: field peer: %w", )
	}
	.PutInt(.OffsetID)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *StoriesGetPinnedStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getPinnedStories#5821a5dc to nil")
	}
	if  := .ConsumeID(StoriesGetPinnedStoriesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stories.getPinnedStories#5821a5dc: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StoriesGetPinnedStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getPinnedStories#5821a5dc to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getPinnedStories#5821a5dc: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getPinnedStories#5821a5dc: field offset_id: %w", )
		}
		.OffsetID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getPinnedStories#5821a5dc: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

// GetOffsetID returns value of OffsetID field.
func ( *StoriesGetPinnedStoriesRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetID
}

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

// StoriesGetPinnedStories invokes method stories.getPinnedStories#5821a5dc returning error if any.
// Fetch the stories¹ pinned on a peer's profile.
//
// Links:
//  1. https://core.telegram.org/api/stories#pinned-or-archived-stories
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/stories.getPinnedStories for reference.
func ( *Client) ( context.Context,  *StoriesGetPinnedStoriesRequest) (*StoriesStories, error) {
	var  StoriesStories

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