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

// StoriesSendReactionRequest represents TL type `stories.sendReaction#7fd736b2`.
// React to a story.
//
// See https://core.telegram.org/method/stories.sendReaction for reference.
type StoriesSendReactionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to add this reaction to the recent reactions list »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/reactions#recent-reactions
	AddToRecent bool
	// The peer that sent the story
	Peer InputPeerClass
	// ID of the story to react to
	StoryID int
	// Reaction
	Reaction ReactionClass
}

// StoriesSendReactionRequestTypeID is TL type id of StoriesSendReactionRequest.
const StoriesSendReactionRequestTypeID = 0x7fd736b2

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

func ( *StoriesSendReactionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AddToRecent == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.StoryID == 0) {
		return false
	}
	if !(.Reaction == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesSendReactionRequest from given interface.
func ( *StoriesSendReactionRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( ReactionClass)
}) {
	.AddToRecent = .()
	.Peer = .()
	.StoryID = .()
	.Reaction = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesSendReactionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stories.sendReaction",
		ID:   StoriesSendReactionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AddToRecent",
			SchemaName: "add_to_recent",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "StoryID",
			SchemaName: "story_id",
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *StoriesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.sendReaction#7fd736b2 as nil")
	}
	.PutID(StoriesSendReactionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.sendReaction#7fd736b2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.sendReaction#7fd736b2: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode stories.sendReaction#7fd736b2: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.sendReaction#7fd736b2: field peer: %w", )
	}
	.PutInt(.StoryID)
	if .Reaction == nil {
		return fmt.Errorf("unable to encode stories.sendReaction#7fd736b2: field reaction is nil")
	}
	if  := .Reaction.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.sendReaction#7fd736b2: field reaction: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.sendReaction#7fd736b2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.sendReaction#7fd736b2: field flags: %w", )
		}
	}
	.AddToRecent = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode stories.sendReaction#7fd736b2: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.sendReaction#7fd736b2: field story_id: %w", )
		}
		.StoryID = 
	}
	{
		,  := DecodeReaction()
		if  != nil {
			return fmt.Errorf("unable to decode stories.sendReaction#7fd736b2: field reaction: %w", )
		}
		.Reaction = 
	}
	return nil
}

// SetAddToRecent sets value of AddToRecent conditional field.
func ( *StoriesSendReactionRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.AddToRecent = true
	} else {
		.Flags.Unset(0)
		.AddToRecent = false
	}
}

// GetAddToRecent returns value of AddToRecent conditional field.
func ( *StoriesSendReactionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

// GetReaction returns value of Reaction field.
func ( *StoriesSendReactionRequest) () ( ReactionClass) {
	if  == nil {
		return
	}
	return .Reaction
}

// StoriesSendReaction invokes method stories.sendReaction#7fd736b2 returning error if any.
// React to a story.
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 REACTION_INVALID: The specified reaction is invalid.
//	400 STORY_ID_EMPTY: You specified no story IDs.
//
// See https://core.telegram.org/method/stories.sendReaction for reference.
func ( *Client) ( context.Context,  *StoriesSendReactionRequest) (UpdatesClass, error) {
	var  UpdatesBox

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