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

// StoriesReadStoriesRequest represents TL type `stories.readStories#a556dac8`.
// Mark all stories up to a certain ID as read, for a given peer; will emit an
// updateReadStories¹ update to all logged-in sessions.
//
// Links:
//  1. https://core.telegram.org/constructor/updateReadStories
//
// See https://core.telegram.org/method/stories.readStories for reference.
type StoriesReadStoriesRequest struct {
	// The peer whose stories should be marked as read.
	Peer InputPeerClass
	// Mark all stories up to and including this ID as read
	MaxID int
}

// StoriesReadStoriesRequestTypeID is TL type id of StoriesReadStoriesRequest.
const StoriesReadStoriesRequestTypeID = 0xa556dac8

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

func ( *StoriesReadStoriesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesReadStoriesRequest from given interface.
func ( *StoriesReadStoriesRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
}) {
	.Peer = .()
	.MaxID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesReadStoriesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.readStories",
		ID:   StoriesReadStoriesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesReadStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.readStories#a556dac8 as nil")
	}
	.PutID(StoriesReadStoriesRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesReadStoriesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.readStories#a556dac8 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.readStories#a556dac8: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.readStories#a556dac8: field max_id: %w", )
		}
		.MaxID = 
	}
	return nil
}

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

// GetMaxID returns value of MaxID field.
func ( *StoriesReadStoriesRequest) () ( int) {
	if  == nil {
		return
	}
	return .MaxID
}

// StoriesReadStories invokes method stories.readStories#a556dac8 returning error if any.
// Mark all stories up to a certain ID as read, for a given peer; will emit an
// updateReadStories¹ update to all logged-in sessions.
//
// Links:
//  1. https://core.telegram.org/constructor/updateReadStories
//
// Possible errors:
//
//	400 MAX_ID_INVALID: The provided max ID is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 STORIES_NEVER_CREATED:
//
// See https://core.telegram.org/method/stories.readStories for reference.
func ( *Client) ( context.Context,  *StoriesReadStoriesRequest) ([]int, error) {
	var  IntVector

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