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

// InputQuickReplyShortcut represents TL type `inputQuickReplyShortcut#24596d41`.
// Selects a quick reply shortcut¹ by name.
//
// Links:
//  1. https://core.telegram.org/api/business#quick-reply-shortcuts
//
// See https://core.telegram.org/constructor/inputQuickReplyShortcut for reference.
type InputQuickReplyShortcut struct {
	// Shortcut name.
	Shortcut string
}

// InputQuickReplyShortcutTypeID is TL type id of InputQuickReplyShortcut.
const InputQuickReplyShortcutTypeID = 0x24596d41

// construct implements constructor of InputQuickReplyShortcutClass.
func (i InputQuickReplyShortcut) construct() InputQuickReplyShortcutClass { return &i }

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

	_ InputQuickReplyShortcutClass = &InputQuickReplyShortcut{}
)

func (i *InputQuickReplyShortcut) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Shortcut == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputQuickReplyShortcut from given interface.
func (i *InputQuickReplyShortcut) FillFrom(from interface {
	GetShortcut() (value string)
}) {
	i.Shortcut = from.GetShortcut()
}

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

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

// TypeInfo returns info about TL type.
func (i *InputQuickReplyShortcut) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputQuickReplyShortcut",
		ID:   InputQuickReplyShortcutTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Shortcut",
			SchemaName: "shortcut",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputQuickReplyShortcut) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputQuickReplyShortcut#24596d41 as nil")
	}
	b.PutID(InputQuickReplyShortcutTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputQuickReplyShortcut) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputQuickReplyShortcut#24596d41 as nil")
	}
	b.PutString(i.Shortcut)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputQuickReplyShortcut) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputQuickReplyShortcut#24596d41 to nil")
	}
	if err := b.ConsumeID(InputQuickReplyShortcutTypeID); err != nil {
		return fmt.Errorf("unable to decode inputQuickReplyShortcut#24596d41: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputQuickReplyShortcut) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputQuickReplyShortcut#24596d41 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputQuickReplyShortcut#24596d41: field shortcut: %w", err)
		}
		i.Shortcut = value
	}
	return nil
}

// GetShortcut returns value of Shortcut field.
func (i *InputQuickReplyShortcut) GetShortcut() (value string) {
	if i == nil {
		return
	}
	return i.Shortcut
}

// InputQuickReplyShortcutID represents TL type `inputQuickReplyShortcutId#1190cf1`.
// Selects a quick reply shortcut¹ by its numeric ID.
//
// Links:
//  1. https://core.telegram.org/api/business#quick-reply-shortcuts
//
// See https://core.telegram.org/constructor/inputQuickReplyShortcutId for reference.
type InputQuickReplyShortcutID struct {
	// Shortcut ID.
	ShortcutID int
}

// InputQuickReplyShortcutIDTypeID is TL type id of InputQuickReplyShortcutID.
const InputQuickReplyShortcutIDTypeID = 0x1190cf1

// construct implements constructor of InputQuickReplyShortcutClass.
func (i InputQuickReplyShortcutID) construct() InputQuickReplyShortcutClass { return &i }

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

	_ InputQuickReplyShortcutClass = &InputQuickReplyShortcutID{}
)

func (i *InputQuickReplyShortcutID) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.ShortcutID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputQuickReplyShortcutID from given interface.
func (i *InputQuickReplyShortcutID) FillFrom(from interface {
	GetShortcutID() (value int)
}) {
	i.ShortcutID = from.GetShortcutID()
}

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

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

// TypeInfo returns info about TL type.
func (i *InputQuickReplyShortcutID) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputQuickReplyShortcutId",
		ID:   InputQuickReplyShortcutIDTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ShortcutID",
			SchemaName: "shortcut_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputQuickReplyShortcutID) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputQuickReplyShortcutId#1190cf1 as nil")
	}
	b.PutID(InputQuickReplyShortcutIDTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputQuickReplyShortcutID) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputQuickReplyShortcutId#1190cf1 as nil")
	}
	b.PutInt(i.ShortcutID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputQuickReplyShortcutID) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputQuickReplyShortcutId#1190cf1 to nil")
	}
	if err := b.ConsumeID(InputQuickReplyShortcutIDTypeID); err != nil {
		return fmt.Errorf("unable to decode inputQuickReplyShortcutId#1190cf1: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputQuickReplyShortcutID) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputQuickReplyShortcutId#1190cf1 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode inputQuickReplyShortcutId#1190cf1: field shortcut_id: %w", err)
		}
		i.ShortcutID = value
	}
	return nil
}

// GetShortcutID returns value of ShortcutID field.
func (i *InputQuickReplyShortcutID) GetShortcutID() (value int) {
	if i == nil {
		return
	}
	return i.ShortcutID
}

// InputQuickReplyShortcutClassName is schema name of InputQuickReplyShortcutClass.
const InputQuickReplyShortcutClassName = "InputQuickReplyShortcut"

// InputQuickReplyShortcutClass represents InputQuickReplyShortcut generic type.
//
// See https://core.telegram.org/type/InputQuickReplyShortcut for reference.
//
// Example:
//
//	g, err := tg.DecodeInputQuickReplyShortcut(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputQuickReplyShortcut: // inputQuickReplyShortcut#24596d41
//	case *tg.InputQuickReplyShortcutID: // inputQuickReplyShortcutId#1190cf1
//	default: panic(v)
//	}
type InputQuickReplyShortcutClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputQuickReplyShortcutClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeInputQuickReplyShortcut implements binary de-serialization for InputQuickReplyShortcutClass.
func DecodeInputQuickReplyShortcut(buf *bin.Buffer) (InputQuickReplyShortcutClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case InputQuickReplyShortcutTypeID:
		// Decoding inputQuickReplyShortcut#24596d41.
		v := InputQuickReplyShortcut{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputQuickReplyShortcutClass: %w", err)
		}
		return &v, nil
	case InputQuickReplyShortcutIDTypeID:
		// Decoding inputQuickReplyShortcutId#1190cf1.
		v := InputQuickReplyShortcutID{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputQuickReplyShortcutClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InputQuickReplyShortcutClass: %w", bin.NewUnexpectedID(id))
	}
}

// InputQuickReplyShortcut boxes the InputQuickReplyShortcutClass providing a helper.
type InputQuickReplyShortcutBox struct {
	InputQuickReplyShortcut InputQuickReplyShortcutClass
}

// Decode implements bin.Decoder for InputQuickReplyShortcutBox.
func (b *InputQuickReplyShortcutBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode InputQuickReplyShortcutBox to nil")
	}
	v, err := DecodeInputQuickReplyShortcut(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.InputQuickReplyShortcut = v
	return nil
}

// Encode implements bin.Encode for InputQuickReplyShortcutBox.
func (b *InputQuickReplyShortcutBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.InputQuickReplyShortcut == nil {
		return fmt.Errorf("unable to encode InputQuickReplyShortcutClass as nil")
	}
	return b.InputQuickReplyShortcut.Encode(buf)
}
