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

// StatsGetStoryStatsRequest represents TL type `stats.getStoryStats#374fef40`.
// Get statistics¹ for a certain story².
//
// Links:
//  1. https://core.telegram.org/api/stats
//  2. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/method/stats.getStoryStats for reference.
type StatsGetStoryStatsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to enable the dark theme for graph colors
	Dark bool
	// The peer that posted the story
	Peer InputPeerClass
	// Story ID
	ID int
}

// StatsGetStoryStatsRequestTypeID is TL type id of StatsGetStoryStatsRequest.
const StatsGetStoryStatsRequestTypeID = 0x374fef40

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

func ( *StatsGetStoryStatsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Dark == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsGetStoryStatsRequest from given interface.
func ( *StatsGetStoryStatsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( int)
}) {
	.Dark = .()
	.Peer = .()
	.ID = .()
}

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

// TypeName returns name of type in TL schema.
func (*StatsGetStoryStatsRequest) () string {
	return "stats.getStoryStats"
}

// TypeInfo returns info about TL type.
func ( *StatsGetStoryStatsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stats.getStoryStats",
		ID:   StatsGetStoryStatsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Dark",
			SchemaName: "dark",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StatsGetStoryStatsRequest) () {
	if !(.Dark == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *StatsGetStoryStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getStoryStats#374fef40 as nil")
	}
	.PutID(StatsGetStoryStatsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsGetStoryStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getStoryStats#374fef40 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getStoryStats#374fef40: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stats.getStoryStats#374fef40: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getStoryStats#374fef40: field peer: %w", )
	}
	.PutInt(.ID)
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsGetStoryStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getStoryStats#374fef40 to nil")
	}
	if  := .ConsumeID(StatsGetStoryStatsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stats.getStoryStats#374fef40: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsGetStoryStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getStoryStats#374fef40 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.getStoryStats#374fef40: field flags: %w", )
		}
	}
	.Dark = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryStats#374fef40: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getStoryStats#374fef40: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// SetDark sets value of Dark conditional field.
func ( *StatsGetStoryStatsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Dark = true
	} else {
		.Flags.Unset(0)
		.Dark = false
	}
}

// GetDark returns value of Dark conditional field.
func ( *StatsGetStoryStatsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

// StatsGetStoryStats invokes method stats.getStoryStats#374fef40 returning error if any.
// Get statistics¹ for a certain story².
//
// Links:
//  1. https://core.telegram.org/api/stats
//  2. https://core.telegram.org/api/stories
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/stats.getStoryStats for reference.
func ( *Client) ( context.Context,  *StatsGetStoryStatsRequest) (*StatsStoryStats, error) {
	var  StatsStoryStats

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