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

// AccountInitPasskeyRegistrationRequest represents TL type `account.initPasskeyRegistration#429547e8`.
//
// See https://core.telegram.org/method/account.initPasskeyRegistration for reference.
type AccountInitPasskeyRegistrationRequest struct {
}

// AccountInitPasskeyRegistrationRequestTypeID is TL type id of AccountInitPasskeyRegistrationRequest.
const AccountInitPasskeyRegistrationRequestTypeID = 0x429547e8

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

func (i *AccountInitPasskeyRegistrationRequest) Zero() bool {
	if i == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *AccountInitPasskeyRegistrationRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "account.initPasskeyRegistration",
		ID:   AccountInitPasskeyRegistrationRequestTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (i *AccountInitPasskeyRegistrationRequest) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode account.initPasskeyRegistration#429547e8 as nil")
	}
	b.PutID(AccountInitPasskeyRegistrationRequestTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *AccountInitPasskeyRegistrationRequest) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode account.initPasskeyRegistration#429547e8 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *AccountInitPasskeyRegistrationRequest) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode account.initPasskeyRegistration#429547e8 to nil")
	}
	if err := b.ConsumeID(AccountInitPasskeyRegistrationRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode account.initPasskeyRegistration#429547e8: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *AccountInitPasskeyRegistrationRequest) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode account.initPasskeyRegistration#429547e8 to nil")
	}
	return nil
}

// AccountInitPasskeyRegistration invokes method account.initPasskeyRegistration#429547e8 returning error if any.
//
// See https://core.telegram.org/method/account.initPasskeyRegistration for reference.
func (c *Client) AccountInitPasskeyRegistration(ctx context.Context) (*AccountPasskeyRegistrationOptions, error) {
	var result AccountPasskeyRegistrationOptions

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