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

// MessagesGetEmojiGameInfoRequest represents TL type `messages.getEmojiGameInfo#fb7e8ca7`.
//
// See https://core.telegram.org/method/messages.getEmojiGameInfo for reference.
type MessagesGetEmojiGameInfoRequest struct {
}

// MessagesGetEmojiGameInfoRequestTypeID is TL type id of MessagesGetEmojiGameInfoRequest.
const MessagesGetEmojiGameInfoRequestTypeID = 0xfb7e8ca7

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *MessagesGetEmojiGameInfoRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode messages.getEmojiGameInfo#fb7e8ca7 as nil")
	}
	b.PutID(MessagesGetEmojiGameInfoRequestTypeID)
	return g.EncodeBare(b)
}

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

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

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

// MessagesGetEmojiGameInfo invokes method messages.getEmojiGameInfo#fb7e8ca7 returning error if any.
//
// See https://core.telegram.org/method/messages.getEmojiGameInfo for reference.
func (c *Client) MessagesGetEmojiGameInfo(ctx context.Context) (MessagesEmojiGameInfoClass, error) {
	var result MessagesEmojiGameInfoBox

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