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

// GetRecentInlineBotsRequest represents TL type `getRecentInlineBots#55b3723c`.
type GetRecentInlineBotsRequest struct {
}

// GetRecentInlineBotsRequestTypeID is TL type id of GetRecentInlineBotsRequest.
const GetRecentInlineBotsRequestTypeID = 0x55b3723c

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetRecentInlineBotsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getRecentInlineBots#55b3723c as nil")
	}
	b.PutID(GetRecentInlineBotsRequestTypeID)
	return g.EncodeBare(b)
}

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

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

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

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

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

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

// GetRecentInlineBots invokes method getRecentInlineBots#55b3723c returning error if any.
func (c *Client) GetRecentInlineBots(ctx context.Context) (*Users, error) {
	var result Users

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