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

// StoriesGetPeerMaxIDsRequest represents TL type `stories.getPeerMaxIDs#535983c3`.
// Get the IDs of the maximum read stories for a set of peers.
//
// See https://core.telegram.org/method/stories.getPeerMaxIDs for reference.
type StoriesGetPeerMaxIDsRequest struct {
	// Peers
	ID []InputPeerClass
}

// StoriesGetPeerMaxIDsRequestTypeID is TL type id of StoriesGetPeerMaxIDsRequest.
const StoriesGetPeerMaxIDsRequestTypeID = 0x535983c3

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

func ( *StoriesGetPeerMaxIDsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesGetPeerMaxIDsRequest from given interface.
func ( *StoriesGetPeerMaxIDsRequest) ( interface {
	() ( []InputPeerClass)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesGetPeerMaxIDsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.getPeerMaxIDs",
		ID:   StoriesGetPeerMaxIDsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesGetPeerMaxIDsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getPeerMaxIDs#535983c3 as nil")
	}
	.PutID(StoriesGetPeerMaxIDsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesGetPeerMaxIDsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getPeerMaxIDs#535983c3 as nil")
	}
	.PutVectorHeader(len(.ID))
	for ,  := range .ID {
		if  == nil {
			return fmt.Errorf("unable to encode stories.getPeerMaxIDs#535983c3: field id element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.getPeerMaxIDs#535983c3: field id element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesGetPeerMaxIDsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getPeerMaxIDs#535983c3 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getPeerMaxIDs#535983c3: field id: %w", )
		}

		if  > 0 {
			.ID = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode stories.getPeerMaxIDs#535983c3: field id: %w", )
			}
			.ID = append(.ID, )
		}
	}
	return nil
}

// GetID returns value of ID field.
func ( *StoriesGetPeerMaxIDsRequest) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .ID
}

// MapID returns field ID wrapped in InputPeerClassArray helper.
func ( *StoriesGetPeerMaxIDsRequest) () ( InputPeerClassArray) {
	return InputPeerClassArray(.ID)
}

// StoriesGetPeerMaxIDs invokes method stories.getPeerMaxIDs#535983c3 returning error if any.
// Get the IDs of the maximum read stories for a set of peers.
//
// See https://core.telegram.org/method/stories.getPeerMaxIDs for reference.
func ( *Client) ( context.Context,  []InputPeerClass) ([]int, error) {
	var  IntVector

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