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

// PostInteractionCountersMessage represents TL type `postInteractionCountersMessage#e7058e7f`.
// Interaction counters for a message.
//
// See https://core.telegram.org/constructor/postInteractionCountersMessage for reference.
type PostInteractionCountersMessage struct {
	// Message ID
	MsgID int
	// Number of views
	Views int
	// Number of forwards to public channels
	Forwards int
	// Number of reactions
	Reactions int
}

// PostInteractionCountersMessageTypeID is TL type id of PostInteractionCountersMessage.
const PostInteractionCountersMessageTypeID = 0xe7058e7f

// construct implements constructor of PostInteractionCountersClass.
func ( PostInteractionCountersMessage) () PostInteractionCountersClass { return & }

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

	_ PostInteractionCountersClass = &PostInteractionCountersMessage{}
)

func ( *PostInteractionCountersMessage) () bool {
	if  == nil {
		return true
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Views == 0) {
		return false
	}
	if !(.Forwards == 0) {
		return false
	}
	if !(.Reactions == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PostInteractionCountersMessage from given interface.
func ( *PostInteractionCountersMessage) ( interface {
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.MsgID = .()
	.Views = .()
	.Forwards = .()
	.Reactions = .()
}

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

// TypeName returns name of type in TL schema.
func (*PostInteractionCountersMessage) () string {
	return "postInteractionCountersMessage"
}

// TypeInfo returns info about TL type.
func ( *PostInteractionCountersMessage) () tdp.Type {
	 := tdp.Type{
		Name: "postInteractionCountersMessage",
		ID:   PostInteractionCountersMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Views",
			SchemaName: "views",
		},
		{
			Name:       "Forwards",
			SchemaName: "forwards",
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PostInteractionCountersMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postInteractionCountersMessage#e7058e7f as nil")
	}
	.PutID(PostInteractionCountersMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PostInteractionCountersMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postInteractionCountersMessage#e7058e7f as nil")
	}
	.PutInt(.MsgID)
	.PutInt(.Views)
	.PutInt(.Forwards)
	.PutInt(.Reactions)
	return nil
}

// Decode implements bin.Decoder.
func ( *PostInteractionCountersMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode postInteractionCountersMessage#e7058e7f to nil")
	}
	if  := .ConsumeID(PostInteractionCountersMessageTypeID);  != nil {
		return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PostInteractionCountersMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode postInteractionCountersMessage#e7058e7f to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field views: %w", )
		}
		.Views = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field forwards: %w", )
		}
		.Forwards = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersMessage#e7058e7f: field reactions: %w", )
		}
		.Reactions = 
	}
	return nil
}

// GetMsgID returns value of MsgID field.
func ( *PostInteractionCountersMessage) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetViews returns value of Views field.
func ( *PostInteractionCountersMessage) () ( int) {
	if  == nil {
		return
	}
	return .Views
}

// GetForwards returns value of Forwards field.
func ( *PostInteractionCountersMessage) () ( int) {
	if  == nil {
		return
	}
	return .Forwards
}

// GetReactions returns value of Reactions field.
func ( *PostInteractionCountersMessage) () ( int) {
	if  == nil {
		return
	}
	return .Reactions
}

// PostInteractionCountersStory represents TL type `postInteractionCountersStory#8a480e27`.
// Interaction counters for a story.
//
// See https://core.telegram.org/constructor/postInteractionCountersStory for reference.
type PostInteractionCountersStory struct {
	// Story ID
	StoryID int
	// Number of views
	Views int
	// Number of forwards and reposts to public chats and channels
	Forwards int
	// Number of reactions
	Reactions int
}

// PostInteractionCountersStoryTypeID is TL type id of PostInteractionCountersStory.
const PostInteractionCountersStoryTypeID = 0x8a480e27

// construct implements constructor of PostInteractionCountersClass.
func ( PostInteractionCountersStory) () PostInteractionCountersClass { return & }

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

	_ PostInteractionCountersClass = &PostInteractionCountersStory{}
)

func ( *PostInteractionCountersStory) () bool {
	if  == nil {
		return true
	}
	if !(.StoryID == 0) {
		return false
	}
	if !(.Views == 0) {
		return false
	}
	if !(.Forwards == 0) {
		return false
	}
	if !(.Reactions == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PostInteractionCountersStory from given interface.
func ( *PostInteractionCountersStory) ( interface {
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.StoryID = .()
	.Views = .()
	.Forwards = .()
	.Reactions = .()
}

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

// TypeName returns name of type in TL schema.
func (*PostInteractionCountersStory) () string {
	return "postInteractionCountersStory"
}

// TypeInfo returns info about TL type.
func ( *PostInteractionCountersStory) () tdp.Type {
	 := tdp.Type{
		Name: "postInteractionCountersStory",
		ID:   PostInteractionCountersStoryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "StoryID",
			SchemaName: "story_id",
		},
		{
			Name:       "Views",
			SchemaName: "views",
		},
		{
			Name:       "Forwards",
			SchemaName: "forwards",
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PostInteractionCountersStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postInteractionCountersStory#8a480e27 as nil")
	}
	.PutID(PostInteractionCountersStoryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PostInteractionCountersStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode postInteractionCountersStory#8a480e27 as nil")
	}
	.PutInt(.StoryID)
	.PutInt(.Views)
	.PutInt(.Forwards)
	.PutInt(.Reactions)
	return nil
}

// Decode implements bin.Decoder.
func ( *PostInteractionCountersStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode postInteractionCountersStory#8a480e27 to nil")
	}
	if  := .ConsumeID(PostInteractionCountersStoryTypeID);  != nil {
		return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PostInteractionCountersStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode postInteractionCountersStory#8a480e27 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field story_id: %w", )
		}
		.StoryID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field views: %w", )
		}
		.Views = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field forwards: %w", )
		}
		.Forwards = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode postInteractionCountersStory#8a480e27: field reactions: %w", )
		}
		.Reactions = 
	}
	return nil
}

// GetStoryID returns value of StoryID field.
func ( *PostInteractionCountersStory) () ( int) {
	if  == nil {
		return
	}
	return .StoryID
}

// GetViews returns value of Views field.
func ( *PostInteractionCountersStory) () ( int) {
	if  == nil {
		return
	}
	return .Views
}

// GetForwards returns value of Forwards field.
func ( *PostInteractionCountersStory) () ( int) {
	if  == nil {
		return
	}
	return .Forwards
}

// GetReactions returns value of Reactions field.
func ( *PostInteractionCountersStory) () ( int) {
	if  == nil {
		return
	}
	return .Reactions
}

// PostInteractionCountersClassName is schema name of PostInteractionCountersClass.
const PostInteractionCountersClassName = "PostInteractionCounters"

// PostInteractionCountersClass represents PostInteractionCounters generic type.
//
// See https://core.telegram.org/type/PostInteractionCounters for reference.
//
// Example:
//
//	g, err := tg.DecodePostInteractionCounters(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PostInteractionCountersMessage: // postInteractionCountersMessage#e7058e7f
//	case *tg.PostInteractionCountersStory: // postInteractionCountersStory#8a480e27
//	default: panic(v)
//	}
type PostInteractionCountersClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PostInteractionCountersClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// Number of views
	GetViews() (value int)

	// Number of forwards to public channels
	GetForwards() (value int)

	// Number of reactions
	GetReactions() (value int)
}

// DecodePostInteractionCounters implements binary de-serialization for PostInteractionCountersClass.
func ( *bin.Buffer) (PostInteractionCountersClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PostInteractionCountersMessageTypeID:
		// Decoding postInteractionCountersMessage#e7058e7f.
		 := PostInteractionCountersMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", )
		}
		return &, nil
	case PostInteractionCountersStoryTypeID:
		// Decoding postInteractionCountersStory#8a480e27.
		 := PostInteractionCountersStory{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PostInteractionCountersClass: %w", bin.NewUnexpectedID())
	}
}

// PostInteractionCounters boxes the PostInteractionCountersClass providing a helper.
type PostInteractionCountersBox struct {
	PostInteractionCounters PostInteractionCountersClass
}

// Decode implements bin.Decoder for PostInteractionCountersBox.
func ( *PostInteractionCountersBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode PostInteractionCountersBox to nil")
	}
	,  := DecodePostInteractionCounters()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.PostInteractionCounters = 
	return nil
}

// Encode implements bin.Encode for PostInteractionCountersBox.
func ( *PostInteractionCountersBox) ( *bin.Buffer) error {
	if  == nil || .PostInteractionCounters == nil {
		return fmt.Errorf("unable to encode PostInteractionCountersClass as nil")
	}
	return .PostInteractionCounters.Encode()
}