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

// GetRecentEmojiStatusesRequest represents TL type `getRecentEmojiStatuses#ae3a3d29`.
type GetRecentEmojiStatusesRequest struct {
}

// GetRecentEmojiStatusesRequestTypeID is TL type id of GetRecentEmojiStatusesRequest.
const GetRecentEmojiStatusesRequestTypeID = 0xae3a3d29

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

func (g *GetRecentEmojiStatusesRequest) Zero() bool {
	if g == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetRecentEmojiStatusesRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getRecentEmojiStatuses#ae3a3d29 as nil")
	}
	b.PutID(GetRecentEmojiStatusesRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetRecentEmojiStatusesRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getRecentEmojiStatuses#ae3a3d29 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *GetRecentEmojiStatusesRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getRecentEmojiStatuses#ae3a3d29 to nil")
	}
	if err := b.ConsumeID(GetRecentEmojiStatusesRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode getRecentEmojiStatuses#ae3a3d29: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *GetRecentEmojiStatusesRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getRecentEmojiStatuses#ae3a3d29 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetRecentEmojiStatusesRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if g == nil {
		return fmt.Errorf("can't decode getRecentEmojiStatuses#ae3a3d29 to nil")
	}

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

// GetRecentEmojiStatuses invokes method getRecentEmojiStatuses#ae3a3d29 returning error if any.
func (c *Client) GetRecentEmojiStatuses(ctx context.Context) (*EmojiStatuses, error) {
	var result EmojiStatuses

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