// Code generated by gotdgen, DO NOT EDIT.

package tdapi

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

// ClearRecentlyFoundChatsRequest represents TL type `clearRecentlyFoundChats#eefa5b32`.
type ClearRecentlyFoundChatsRequest struct {
}

// ClearRecentlyFoundChatsRequestTypeID is TL type id of ClearRecentlyFoundChatsRequest.
const ClearRecentlyFoundChatsRequestTypeID = 0xeefa5b32

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

func (c *ClearRecentlyFoundChatsRequest) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ClearRecentlyFoundChatsRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "clearRecentlyFoundChats",
		ID:   ClearRecentlyFoundChatsRequestTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (c *ClearRecentlyFoundChatsRequest) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode clearRecentlyFoundChats#eefa5b32 as nil")
	}
	b.PutID(ClearRecentlyFoundChatsRequestTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ClearRecentlyFoundChatsRequest) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode clearRecentlyFoundChats#eefa5b32 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ClearRecentlyFoundChatsRequest) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode clearRecentlyFoundChats#eefa5b32 to nil")
	}
	if err := b.ConsumeID(ClearRecentlyFoundChatsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode clearRecentlyFoundChats#eefa5b32: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ClearRecentlyFoundChatsRequest) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode clearRecentlyFoundChats#eefa5b32 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ClearRecentlyFoundChatsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode clearRecentlyFoundChats#eefa5b32 as nil")
	}
	b.ObjStart()
	b.PutID("clearRecentlyFoundChats")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ClearRecentlyFoundChatsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode clearRecentlyFoundChats#eefa5b32 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("clearRecentlyFoundChats"); err != nil {
				return fmt.Errorf("unable to decode clearRecentlyFoundChats#eefa5b32: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ClearRecentlyFoundChats invokes method clearRecentlyFoundChats#eefa5b32 returning error if any.
func (c *Client) ClearRecentlyFoundChats(ctx context.Context) error {
	var ok Ok

	request := &ClearRecentlyFoundChatsRequest{}
	if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
		return err
	}
	return nil
}
