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

// StatsStoryStats represents TL type `stats.storyStats#50cd067c`.
// Contains statistics¹ about a story².
//
// Links:
//  1. https://core.telegram.org/api/stats
//  2. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/constructor/stats.storyStats for reference.
type StatsStoryStats struct {
	// A graph containing the number of story views and shares
	ViewsGraph StatsGraphClass
	// A bar graph containing the number of story reactions categorized by "emotion" (i.e.
	// Positive, Negative, Other, etc...)
	ReactionsByEmotionGraph StatsGraphClass
}

// StatsStoryStatsTypeID is TL type id of StatsStoryStats.
const StatsStoryStatsTypeID = 0x50cd067c

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

func ( *StatsStoryStats) () bool {
	if  == nil {
		return true
	}
	if !(.ViewsGraph == nil) {
		return false
	}
	if !(.ReactionsByEmotionGraph == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StatsStoryStats from given interface.
func ( *StatsStoryStats) ( interface {
	() ( StatsGraphClass)
	() ( StatsGraphClass)
}) {
	.ViewsGraph = .()
	.ReactionsByEmotionGraph = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StatsStoryStats) () tdp.Type {
	 := tdp.Type{
		Name: "stats.storyStats",
		ID:   StatsStoryStatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ViewsGraph",
			SchemaName: "views_graph",
		},
		{
			Name:       "ReactionsByEmotionGraph",
			SchemaName: "reactions_by_emotion_graph",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsStoryStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.storyStats#50cd067c as nil")
	}
	.PutID(StatsStoryStatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsStoryStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.storyStats#50cd067c as nil")
	}
	if .ViewsGraph == nil {
		return fmt.Errorf("unable to encode stats.storyStats#50cd067c: field views_graph is nil")
	}
	if  := .ViewsGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.storyStats#50cd067c: field views_graph: %w", )
	}
	if .ReactionsByEmotionGraph == nil {
		return fmt.Errorf("unable to encode stats.storyStats#50cd067c: field reactions_by_emotion_graph is nil")
	}
	if  := .ReactionsByEmotionGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.storyStats#50cd067c: field reactions_by_emotion_graph: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsStoryStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.storyStats#50cd067c to nil")
	}
	if  := .ConsumeID(StatsStoryStatsTypeID);  != nil {
		return fmt.Errorf("unable to decode stats.storyStats#50cd067c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsStoryStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.storyStats#50cd067c to nil")
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.storyStats#50cd067c: field views_graph: %w", )
		}
		.ViewsGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.storyStats#50cd067c: field reactions_by_emotion_graph: %w", )
		}
		.ReactionsByEmotionGraph = 
	}
	return nil
}

// GetViewsGraph returns value of ViewsGraph field.
func ( *StatsStoryStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .ViewsGraph
}

// GetReactionsByEmotionGraph returns value of ReactionsByEmotionGraph field.
func ( *StatsStoryStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .ReactionsByEmotionGraph
}