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

// GetStickerOutlineRequest represents TL type `getStickerOutline#a3952da5`.
type GetStickerOutlineRequest struct {
	// File identifier of the sticker
	StickerFileID int32
	// Pass true to get the outline scaled for animated emoji
	ForAnimatedEmoji bool
	// Pass true to get the outline scaled for clicked animated emoji message
	ForClickedAnimatedEmojiMessage bool
}

// GetStickerOutlineRequestTypeID is TL type id of GetStickerOutlineRequest.
const GetStickerOutlineRequestTypeID = 0xa3952da5

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

func (g *GetStickerOutlineRequest) Zero() bool {
	if g == nil {
		return true
	}
	if !(g.StickerFileID == 0) {
		return false
	}
	if !(g.ForAnimatedEmoji == false) {
		return false
	}
	if !(g.ForClickedAnimatedEmojiMessage == false) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (g *GetStickerOutlineRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "getStickerOutline",
		ID:   GetStickerOutlineRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "StickerFileID",
			SchemaName: "sticker_file_id",
		},
		{
			Name:       "ForAnimatedEmoji",
			SchemaName: "for_animated_emoji",
		},
		{
			Name:       "ForClickedAnimatedEmojiMessage",
			SchemaName: "for_clicked_animated_emoji_message",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (g *GetStickerOutlineRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getStickerOutline#a3952da5 as nil")
	}
	b.PutID(GetStickerOutlineRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetStickerOutlineRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getStickerOutline#a3952da5 as nil")
	}
	b.PutInt32(g.StickerFileID)
	b.PutBool(g.ForAnimatedEmoji)
	b.PutBool(g.ForClickedAnimatedEmojiMessage)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (g *GetStickerOutlineRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getStickerOutline#a3952da5 to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field sticker_file_id: %w", err)
		}
		g.StickerFileID = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field for_animated_emoji: %w", err)
		}
		g.ForAnimatedEmoji = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field for_clicked_animated_emoji_message: %w", err)
		}
		g.ForClickedAnimatedEmojiMessage = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetStickerOutlineRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if g == nil {
		return fmt.Errorf("can't encode getStickerOutline#a3952da5 as nil")
	}
	b.ObjStart()
	b.PutID("getStickerOutline")
	b.Comma()
	b.FieldStart("sticker_file_id")
	b.PutInt32(g.StickerFileID)
	b.Comma()
	b.FieldStart("for_animated_emoji")
	b.PutBool(g.ForAnimatedEmoji)
	b.Comma()
	b.FieldStart("for_clicked_animated_emoji_message")
	b.PutBool(g.ForClickedAnimatedEmojiMessage)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

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

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("getStickerOutline"); err != nil {
				return fmt.Errorf("unable to decode getStickerOutline#a3952da5: %w", err)
			}
		case "sticker_file_id":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field sticker_file_id: %w", err)
			}
			g.StickerFileID = value
		case "for_animated_emoji":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field for_animated_emoji: %w", err)
			}
			g.ForAnimatedEmoji = value
		case "for_clicked_animated_emoji_message":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode getStickerOutline#a3952da5: field for_clicked_animated_emoji_message: %w", err)
			}
			g.ForClickedAnimatedEmojiMessage = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetStickerFileID returns value of StickerFileID field.
func (g *GetStickerOutlineRequest) GetStickerFileID() (value int32) {
	if g == nil {
		return
	}
	return g.StickerFileID
}

// GetForAnimatedEmoji returns value of ForAnimatedEmoji field.
func (g *GetStickerOutlineRequest) GetForAnimatedEmoji() (value bool) {
	if g == nil {
		return
	}
	return g.ForAnimatedEmoji
}

// GetForClickedAnimatedEmojiMessage returns value of ForClickedAnimatedEmojiMessage field.
func (g *GetStickerOutlineRequest) GetForClickedAnimatedEmojiMessage() (value bool) {
	if g == nil {
		return
	}
	return g.ForClickedAnimatedEmojiMessage
}

// GetStickerOutline invokes method getStickerOutline#a3952da5 returning error if any.
func (c *Client) GetStickerOutline(ctx context.Context, request *GetStickerOutlineRequest) (*Outline, error) {
	var result Outline

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