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

// StoriesGetStoryViewsListRequest represents TL type `stories.getStoryViewsList#7ed23c57`.
// Obtain the list of users that have viewed a specific story we posted¹
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/method/stories.getStoryViewsList for reference.
type StoriesGetStoryViewsListRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to only fetch view reaction/views made by our contacts¹
	//
	// Links:
	//  1) https://core.telegram.org/api/contacts
	JustContacts bool
	// Whether to return storyView¹ info about users that reacted to the story (i.e. if set,
	// the server will first sort results by view date as usual, and then also additionally
	// sort the list by putting storyView²s with an associated reaction first in the list).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/storyView
	//  2) https://core.telegram.org/constructor/storyView
	ReactionsFirst bool
	// ForwardsFirst field of StoriesGetStoryViewsListRequest.
	ForwardsFirst bool
	// Peer where the story was posted
	Peer InputPeerClass
	// Search for specific peers
	//
	// Use SetQ and GetQ helpers.
	Q string
	// Story ID
	ID int
	// Offset for pagination, obtained from stories.storyViewsList¹.next_offset
	//
	// Links:
	//  1) https://core.telegram.org/constructor/stories.storyViewsList
	Offset string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// StoriesGetStoryViewsListRequestTypeID is TL type id of StoriesGetStoryViewsListRequest.
const StoriesGetStoryViewsListRequestTypeID = 0x7ed23c57

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

func ( *StoriesGetStoryViewsListRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.JustContacts == false) {
		return false
	}
	if !(.ReactionsFirst == false) {
		return false
	}
	if !(.ForwardsFirst == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Q == "") {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesGetStoryViewsListRequest from given interface.
func ( *StoriesGetStoryViewsListRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( string,  bool)
	() ( int)
	() ( string)
	() ( int)
}) {
	.JustContacts = .()
	.ReactionsFirst = .()
	.ForwardsFirst = .()
	.Peer = .()
	if ,  := .();  {
		.Q = 
	}

	.ID = .()
	.Offset = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesGetStoryViewsListRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.getStoryViewsList",
		ID:   StoriesGetStoryViewsListRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "JustContacts",
			SchemaName: "just_contacts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ReactionsFirst",
			SchemaName: "reactions_first",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ForwardsFirst",
			SchemaName: "forwards_first",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Q",
			SchemaName: "q",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoriesGetStoryViewsListRequest) () {
	if !(.JustContacts == false) {
		.Flags.Set(0)
	}
	if !(.ReactionsFirst == false) {
		.Flags.Set(2)
	}
	if !(.ForwardsFirst == false) {
		.Flags.Set(3)
	}
	if !(.Q == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *StoriesGetStoryViewsListRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getStoryViewsList#7ed23c57 as nil")
	}
	.PutID(StoriesGetStoryViewsListRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesGetStoryViewsListRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.getStoryViewsList#7ed23c57 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.getStoryViewsList#7ed23c57: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stories.getStoryViewsList#7ed23c57: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.getStoryViewsList#7ed23c57: field peer: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.Q)
	}
	.PutInt(.ID)
	.PutString(.Offset)
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesGetStoryViewsListRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.getStoryViewsList#7ed23c57 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field flags: %w", )
		}
	}
	.JustContacts = .Flags.Has(0)
	.ReactionsFirst = .Flags.Has(2)
	.ForwardsFirst = .Flags.Has(3)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field q: %w", )
		}
		.Q = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.getStoryViewsList#7ed23c57: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetJustContacts sets value of JustContacts conditional field.
func ( *StoriesGetStoryViewsListRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.JustContacts = true
	} else {
		.Flags.Unset(0)
		.JustContacts = false
	}
}

// GetJustContacts returns value of JustContacts conditional field.
func ( *StoriesGetStoryViewsListRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetReactionsFirst sets value of ReactionsFirst conditional field.
func ( *StoriesGetStoryViewsListRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.ReactionsFirst = true
	} else {
		.Flags.Unset(2)
		.ReactionsFirst = false
	}
}

// GetReactionsFirst returns value of ReactionsFirst conditional field.
func ( *StoriesGetStoryViewsListRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetForwardsFirst sets value of ForwardsFirst conditional field.
func ( *StoriesGetStoryViewsListRequest) ( bool) {
	if  {
		.Flags.Set(3)
		.ForwardsFirst = true
	} else {
		.Flags.Unset(3)
		.ForwardsFirst = false
	}
}

// GetForwardsFirst returns value of ForwardsFirst conditional field.
func ( *StoriesGetStoryViewsListRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

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

// SetQ sets value of Q conditional field.
func ( *StoriesGetStoryViewsListRequest) ( string) {
	.Flags.Set(1)
	.Q = 
}

// GetQ returns value of Q conditional field and
// boolean which is true if field was set.
func ( *StoriesGetStoryViewsListRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Q, true
}

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

// GetOffset returns value of Offset field.
func ( *StoriesGetStoryViewsListRequest) () ( string) {
	if  == nil {
		return
	}
	return .Offset
}

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

// StoriesGetStoryViewsList invokes method stories.getStoryViewsList#7ed23c57 returning error if any.
// Obtain the list of users that have viewed a specific story we posted¹
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 STORY_ID_INVALID: The specified story ID is invalid.
//
// See https://core.telegram.org/method/stories.getStoryViewsList for reference.
func ( *Client) ( context.Context,  *StoriesGetStoryViewsListRequest) (*StoriesStoryViewsList, error) {
	var  StoriesStoryViewsList

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