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

// MessagesSendPaidReactionRequest represents TL type `messages.sendPaidReaction#58bbcb50`.
// Sends one or more paid Telegram Star reactions »¹, transferring Telegram Stars »²
// to a channel's balance.
//
// Links:
//  1. https://core.telegram.org/api/reactions#paid-reactions
//  2. https://core.telegram.org/api/stars
//
// See https://core.telegram.org/method/messages.sendPaidReaction for reference.
type MessagesSendPaidReactionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The channel
	Peer InputPeerClass
	// The message to react to
	MsgID int
	// The number of stars¹ to send (each will increment the reaction counter by one).
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	Count int
	// Unique client message ID required to prevent message resending. Note: this argument
	// must be composed of a 64-bit integer where the lower 32 bits are random, and the
	// higher 32 bits are equal to the current unixtime, i.e. `uint64_t random_id = (time()
	// << 32)
	RandomID int64
	// Each post with star reactions has a leaderboard with the top senders, but users can
	// opt out of appearing there if they prefer more privacy. Not populating this field will
	// use the default reaction privacy, stored on the server and synced to clients using
	// updatePaidReactionPrivacy¹ (see here² for more info).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/updatePaidReactionPrivacy
	//  2) https://core.telegram.org/api/reactions#paid-reaction-privacy
	//
	// Use SetPrivate and GetPrivate helpers.
	Private PaidReactionPrivacyClass
}

// MessagesSendPaidReactionRequestTypeID is TL type id of MessagesSendPaidReactionRequest.
const MessagesSendPaidReactionRequestTypeID = 0x58bbcb50

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

func ( *MessagesSendPaidReactionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.Private == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendPaidReactionRequest from given interface.
func ( *MessagesSendPaidReactionRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( int)
	() ( int64)
	() ( PaidReactionPrivacyClass,  bool)
}) {
	.Peer = .()
	.MsgID = .()
	.Count = .()
	.RandomID = .()
	if ,  := .();  {
		.Private = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*MessagesSendPaidReactionRequest) () string {
	return "messages.sendPaidReaction"
}

// TypeInfo returns info about TL type.
func ( *MessagesSendPaidReactionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendPaidReaction",
		ID:   MessagesSendPaidReactionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "Private",
			SchemaName: "private",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSendPaidReactionRequest) () {
	if !(.Private == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSendPaidReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendPaidReaction#58bbcb50 as nil")
	}
	.PutID(MessagesSendPaidReactionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendPaidReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendPaidReaction#58bbcb50 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendPaidReaction#58bbcb50: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.sendPaidReaction#58bbcb50: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendPaidReaction#58bbcb50: field peer: %w", )
	}
	.PutInt(.MsgID)
	.PutInt(.Count)
	.PutLong(.RandomID)
	if .Flags.Has(0) {
		if .Private == nil {
			return fmt.Errorf("unable to encode messages.sendPaidReaction#58bbcb50: field private is nil")
		}
		if  := .Private.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.sendPaidReaction#58bbcb50: field private: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSendPaidReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendPaidReaction#58bbcb50 to nil")
	}
	if  := .ConsumeID(MessagesSendPaidReactionRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendPaidReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendPaidReaction#58bbcb50 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field msg_id: %w", )
		}
		.MsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field random_id: %w", )
		}
		.RandomID = 
	}
	if .Flags.Has(0) {
		,  := DecodePaidReactionPrivacy()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendPaidReaction#58bbcb50: field private: %w", )
		}
		.Private = 
	}
	return nil
}

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

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

// GetCount returns value of Count field.
func ( *MessagesSendPaidReactionRequest) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// GetRandomID returns value of RandomID field.
func ( *MessagesSendPaidReactionRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// SetPrivate sets value of Private conditional field.
func ( *MessagesSendPaidReactionRequest) ( PaidReactionPrivacyClass) {
	.Flags.Set(0)
	.Private = 
}

// GetPrivate returns value of Private conditional field and
// boolean which is true if field was set.
func ( *MessagesSendPaidReactionRequest) () ( PaidReactionPrivacyClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Private, true
}

// MessagesSendPaidReaction invokes method messages.sendPaidReaction#58bbcb50 returning error if any.
// Sends one or more paid Telegram Star reactions »¹, transferring Telegram Stars »²
// to a channel's balance.
//
// Links:
//  1. https://core.telegram.org/api/reactions#paid-reactions
//  2. https://core.telegram.org/api/stars
//
// Possible errors:
//
//	400 BALANCE_TOO_LOW: The transaction cannot be completed because the current Telegram Stars balance is too low.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 RANDOM_ID_EMPTY: Random ID empty.
//	400 RANDOM_ID_EXPIRED: The specified random_id was expired (most likely it didn't follow the required `uint64_t random_id = (time() << 32)
//	400 REACTIONS_COUNT_INVALID: The specified number of reactions is invalid.
//	400 SEND_AS_PEER_INVALID: You can't send messages as the specified peer.
//
// See https://core.telegram.org/method/messages.sendPaidReaction for reference.
func ( *Client) ( context.Context,  *MessagesSendPaidReactionRequest) (UpdatesClass, error) {
	var  UpdatesBox

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