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

// GetGreetingStickersRequest represents TL type `getGreetingStickers#16581d1c`.
type GetGreetingStickersRequest struct {
}

// GetGreetingStickersRequestTypeID is TL type id of GetGreetingStickersRequest.
const GetGreetingStickersRequestTypeID = 0x16581d1c

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetGreetingStickersRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getGreetingStickers#16581d1c as nil")
	}
	b.PutID(GetGreetingStickersRequestTypeID)
	return g.EncodeBare(b)
}

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

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

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

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

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

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

// GetGreetingStickers invokes method getGreetingStickers#16581d1c returning error if any.
func (c *Client) GetGreetingStickers(ctx context.Context) (*Stickers, error) {
	var result Stickers

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