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

// StoriesGetStoriesViewsRequest represents TL type `stories.getStoriesViews#28e16cc8`.
// Obtain info about the view count, forward count, reactions and recent viewers of one
// or more storiesĀ¹.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/method/stories.getStoriesViews for reference.
type StoriesGetStoriesViewsRequest struct {
	// Peer whose stories should be fetched
	Peer InputPeerClass
	// Story IDs
	ID []int
}

// StoriesGetStoriesViewsRequestTypeID is TL type id of StoriesGetStoriesViewsRequest.
const StoriesGetStoriesViewsRequestTypeID = 0x28e16cc8

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *StoriesGetStoriesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getStoriesViews#28e16cc8 as nil")
	}
	.PutID(StoriesGetStoriesViewsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesGetStoriesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getStoriesViews#28e16cc8 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stories.getStoriesViews#28e16cc8: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.getStoriesViews#28e16cc8: field peer: %w", )
	}
	.PutVectorHeader(len(.ID))
	for ,  := range .ID {
		.PutInt()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesGetStoriesViewsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getStoriesViews#28e16cc8 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoriesViews#28e16cc8: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoriesViews#28e16cc8: field id: %w", )
		}

		if  > 0 {
			.ID = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode stories.getStoriesViews#28e16cc8: field id: %w", )
			}
			.ID = append(.ID, )
		}
	}
	return nil
}

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

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

// StoriesGetStoriesViews invokes method stories.getStoriesViews#28e16cc8 returning error if any.
// Obtain info about the view count, forward count, reactions and recent viewers of one
// or more storiesĀ¹.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 STORY_ID_EMPTY: You specified no story IDs.
//
// See https://core.telegram.org/method/stories.getStoriesViews for reference.
func ( *Client) ( context.Context,  *StoriesGetStoriesViewsRequest) (*StoriesStoryViews, error) {
	var  StoriesStoryViews

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