// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// MessagesDeleteParticipantReactionsRequest represents TL type `messages.deleteParticipantReactions#a0b80cf8`.
//
// See https://core.telegram.org/method/messages.deleteParticipantReactions for reference.
type MessagesDeleteParticipantReactionsRequest struct {
	// Peer field of MessagesDeleteParticipantReactionsRequest.
	Peer InputPeerClass
	// Participant field of MessagesDeleteParticipantReactionsRequest.
	Participant InputPeerClass
}

// MessagesDeleteParticipantReactionsRequestTypeID is TL type id of MessagesDeleteParticipantReactionsRequest.
const MessagesDeleteParticipantReactionsRequestTypeID = 0xa0b80cf8

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

func (d *MessagesDeleteParticipantReactionsRequest) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.Peer == nil) {
		return false
	}
	if !(d.Participant == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesDeleteParticipantReactionsRequest from given interface.
func (d *MessagesDeleteParticipantReactionsRequest) FillFrom(from interface {
	GetPeer() (value InputPeerClass)
	GetParticipant() (value InputPeerClass)
}) {
	d.Peer = from.GetPeer()
	d.Participant = from.GetParticipant()
}

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

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

// TypeInfo returns info about TL type.
func (d *MessagesDeleteParticipantReactionsRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messages.deleteParticipantReactions",
		ID:   MessagesDeleteParticipantReactionsRequestTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Participant",
			SchemaName: "participant",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *MessagesDeleteParticipantReactionsRequest) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode messages.deleteParticipantReactions#a0b80cf8 as nil")
	}
	b.PutID(MessagesDeleteParticipantReactionsRequestTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *MessagesDeleteParticipantReactionsRequest) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode messages.deleteParticipantReactions#a0b80cf8 as nil")
	}
	if d.Peer == nil {
		return fmt.Errorf("unable to encode messages.deleteParticipantReactions#a0b80cf8: field peer is nil")
	}
	if err := d.Peer.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messages.deleteParticipantReactions#a0b80cf8: field peer: %w", err)
	}
	if d.Participant == nil {
		return fmt.Errorf("unable to encode messages.deleteParticipantReactions#a0b80cf8: field participant is nil")
	}
	if err := d.Participant.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messages.deleteParticipantReactions#a0b80cf8: field participant: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *MessagesDeleteParticipantReactionsRequest) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode messages.deleteParticipantReactions#a0b80cf8 to nil")
	}
	if err := b.ConsumeID(MessagesDeleteParticipantReactionsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode messages.deleteParticipantReactions#a0b80cf8: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *MessagesDeleteParticipantReactionsRequest) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode messages.deleteParticipantReactions#a0b80cf8 to nil")
	}
	{
		value, err := DecodeInputPeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messages.deleteParticipantReactions#a0b80cf8: field peer: %w", err)
		}
		d.Peer = value
	}
	{
		value, err := DecodeInputPeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messages.deleteParticipantReactions#a0b80cf8: field participant: %w", err)
		}
		d.Participant = value
	}
	return nil
}

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

// GetParticipant returns value of Participant field.
func (d *MessagesDeleteParticipantReactionsRequest) GetParticipant() (value InputPeerClass) {
	if d == nil {
		return
	}
	return d.Participant
}

// MessagesDeleteParticipantReactions invokes method messages.deleteParticipantReactions#a0b80cf8 returning error if any.
//
// See https://core.telegram.org/method/messages.deleteParticipantReactions for reference.
func (c *Client) MessagesDeleteParticipantReactions(ctx context.Context, request *MessagesDeleteParticipantReactionsRequest) (bool, error) {
	var result BoolBox

	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return false, err
	}
	_, ok := result.Bool.(*BoolTrue)
	return ok, nil
}
