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

// GetThemedChatEmojiStatusesRequest represents TL type `getThemedChatEmojiStatuses#72b694fa`.
type GetThemedChatEmojiStatusesRequest struct {
}

// GetThemedChatEmojiStatusesRequestTypeID is TL type id of GetThemedChatEmojiStatusesRequest.
const GetThemedChatEmojiStatusesRequestTypeID = 0x72b694fa

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetThemedChatEmojiStatusesRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getThemedChatEmojiStatuses#72b694fa as nil")
	}
	b.PutID(GetThemedChatEmojiStatusesRequestTypeID)
	return g.EncodeBare(b)
}

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

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

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

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

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

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

// GetThemedChatEmojiStatuses invokes method getThemedChatEmojiStatuses#72b694fa returning error if any.
func (c *Client) GetThemedChatEmojiStatuses(ctx context.Context) (*EmojiStatusCustomEmojis, error) {
	var result EmojiStatusCustomEmojis

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