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

// AccountGetChannelDefaultEmojiStatusesRequest represents TL type `account.getChannelDefaultEmojiStatuses#7727a7d5`.
// Get a list of default suggested channel emoji statuses¹.
//
// Links:
//  1. https://core.telegram.org/api/emoji-status
//
// See https://core.telegram.org/method/account.getChannelDefaultEmojiStatuses for reference.
type AccountGetChannelDefaultEmojiStatusesRequest struct {
	// Hash used for caching, for more info click here¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
}

// AccountGetChannelDefaultEmojiStatusesRequestTypeID is TL type id of AccountGetChannelDefaultEmojiStatusesRequest.
const AccountGetChannelDefaultEmojiStatusesRequestTypeID = 0x7727a7d5

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

func (g *AccountGetChannelDefaultEmojiStatusesRequest) Zero() bool {
	if g == nil {
		return true
	}
	if !(g.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountGetChannelDefaultEmojiStatusesRequest from given interface.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) FillFrom(from interface {
	GetHash() (value int64)
}) {
	g.Hash = from.GetHash()
}

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

// TypeName returns name of type in TL schema.
func (*AccountGetChannelDefaultEmojiStatusesRequest) TypeName() string {
	return "account.getChannelDefaultEmojiStatuses"
}

// TypeInfo returns info about TL type.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "account.getChannelDefaultEmojiStatuses",
		ID:   AccountGetChannelDefaultEmojiStatusesRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode account.getChannelDefaultEmojiStatuses#7727a7d5 as nil")
	}
	b.PutID(AccountGetChannelDefaultEmojiStatusesRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode account.getChannelDefaultEmojiStatuses#7727a7d5 as nil")
	}
	b.PutLong(g.Hash)
	return nil
}

// Decode implements bin.Decoder.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode account.getChannelDefaultEmojiStatuses#7727a7d5 to nil")
	}
	if err := b.ConsumeID(AccountGetChannelDefaultEmojiStatusesRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode account.getChannelDefaultEmojiStatuses#7727a7d5: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode account.getChannelDefaultEmojiStatuses#7727a7d5 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode account.getChannelDefaultEmojiStatuses#7727a7d5: field hash: %w", err)
		}
		g.Hash = value
	}
	return nil
}

// GetHash returns value of Hash field.
func (g *AccountGetChannelDefaultEmojiStatusesRequest) GetHash() (value int64) {
	if g == nil {
		return
	}
	return g.Hash
}

// AccountGetChannelDefaultEmojiStatuses invokes method account.getChannelDefaultEmojiStatuses#7727a7d5 returning error if any.
// Get a list of default suggested channel emoji statuses¹.
//
// Links:
//  1. https://core.telegram.org/api/emoji-status
//
// See https://core.telegram.org/method/account.getChannelDefaultEmojiStatuses for reference.
func (c *Client) AccountGetChannelDefaultEmojiStatuses(ctx context.Context, hash int64) (AccountEmojiStatusesClass, error) {
	var result AccountEmojiStatusesBox

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