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

// StoriesGetStoriesArchiveRequest represents TL type `stories.getStoriesArchive#b4352016`.
// Fetch the story archive »¹ of a peer we control.
//
// Links:
//  1. https://core.telegram.org/api/stories#pinned-or-archived-stories
//
// See https://core.telegram.org/method/stories.getStoriesArchive for reference.
type StoriesGetStoriesArchiveRequest struct {
	// Peer whose archived 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
}

// StoriesGetStoriesArchiveRequestTypeID is TL type id of StoriesGetStoriesArchiveRequest.
const StoriesGetStoriesArchiveRequestTypeID = 0xb4352016

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

func ( *StoriesGetStoriesArchiveRequest) () 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 ( *StoriesGetStoriesArchiveRequest) () string {
	if  == nil {
		return "StoriesGetStoriesArchiveRequest(nil)"
	}
	type  StoriesGetStoriesArchiveRequest
	return fmt.Sprintf("StoriesGetStoriesArchiveRequest%+v", (*))
}

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

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

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

// TypeInfo returns info about TL type.
func ( *StoriesGetStoriesArchiveRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.getStoriesArchive",
		ID:   StoriesGetStoriesArchiveRequestTypeID,
	}
	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 ( *StoriesGetStoriesArchiveRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getStoriesArchive#b4352016 as nil")
	}
	.PutID(StoriesGetStoriesArchiveRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// StoriesGetStoriesArchive invokes method stories.getStoriesArchive#b4352016 returning error if any.
// Fetch the story archive »¹ of a peer we control.
//
// Links:
//  1. https://core.telegram.org/api/stories#pinned-or-archived-stories
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/stories.getStoriesArchive for reference.
func ( *Client) ( context.Context,  *StoriesGetStoriesArchiveRequest) (*StoriesStories, error) {
	var  StoriesStories

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