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

// LoadQuickReplyShortcutMessagesRequest represents TL type `loadQuickReplyShortcutMessages#fd40aed4`.
type LoadQuickReplyShortcutMessagesRequest struct {
	// Unique identifier of the quick reply shortcut
	ShortcutID int32
}

// LoadQuickReplyShortcutMessagesRequestTypeID is TL type id of LoadQuickReplyShortcutMessagesRequest.
const LoadQuickReplyShortcutMessagesRequestTypeID = 0xfd40aed4

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (l *LoadQuickReplyShortcutMessagesRequest) Encode(b *bin.Buffer) error {
	if l == nil {
		return fmt.Errorf("can't encode loadQuickReplyShortcutMessages#fd40aed4 as nil")
	}
	b.PutID(LoadQuickReplyShortcutMessagesRequestTypeID)
	return l.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (l *LoadQuickReplyShortcutMessagesRequest) EncodeBare(b *bin.Buffer) error {
	if l == nil {
		return fmt.Errorf("can't encode loadQuickReplyShortcutMessages#fd40aed4 as nil")
	}
	b.PutInt32(l.ShortcutID)
	return nil
}

// Decode implements bin.Decoder.
func (l *LoadQuickReplyShortcutMessagesRequest) Decode(b *bin.Buffer) error {
	if l == nil {
		return fmt.Errorf("can't decode loadQuickReplyShortcutMessages#fd40aed4 to nil")
	}
	if err := b.ConsumeID(LoadQuickReplyShortcutMessagesRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode loadQuickReplyShortcutMessages#fd40aed4: %w", err)
	}
	return l.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (l *LoadQuickReplyShortcutMessagesRequest) DecodeBare(b *bin.Buffer) error {
	if l == nil {
		return fmt.Errorf("can't decode loadQuickReplyShortcutMessages#fd40aed4 to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode loadQuickReplyShortcutMessages#fd40aed4: field shortcut_id: %w", err)
		}
		l.ShortcutID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (l *LoadQuickReplyShortcutMessagesRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if l == nil {
		return fmt.Errorf("can't encode loadQuickReplyShortcutMessages#fd40aed4 as nil")
	}
	b.ObjStart()
	b.PutID("loadQuickReplyShortcutMessages")
	b.Comma()
	b.FieldStart("shortcut_id")
	b.PutInt32(l.ShortcutID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (l *LoadQuickReplyShortcutMessagesRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if l == nil {
		return fmt.Errorf("can't decode loadQuickReplyShortcutMessages#fd40aed4 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("loadQuickReplyShortcutMessages"); err != nil {
				return fmt.Errorf("unable to decode loadQuickReplyShortcutMessages#fd40aed4: %w", err)
			}
		case "shortcut_id":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode loadQuickReplyShortcutMessages#fd40aed4: field shortcut_id: %w", err)
			}
			l.ShortcutID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetShortcutID returns value of ShortcutID field.
func (l *LoadQuickReplyShortcutMessagesRequest) GetShortcutID() (value int32) {
	if l == nil {
		return
	}
	return l.ShortcutID
}

// LoadQuickReplyShortcutMessages invokes method loadQuickReplyShortcutMessages#fd40aed4 returning error if any.
func (c *Client) LoadQuickReplyShortcutMessages(ctx context.Context, shortcutid int32) error {
	var ok Ok

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