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

// ResetAuthenticationEmailAddressRequest represents TL type `resetAuthenticationEmailAddress#e742722c`.
type ResetAuthenticationEmailAddressRequest struct {
}

// ResetAuthenticationEmailAddressRequestTypeID is TL type id of ResetAuthenticationEmailAddressRequest.
const ResetAuthenticationEmailAddressRequestTypeID = 0xe742722c

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

func (r *ResetAuthenticationEmailAddressRequest) Zero() bool {
	if r == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (r *ResetAuthenticationEmailAddressRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "resetAuthenticationEmailAddress",
		ID:   ResetAuthenticationEmailAddressRequestTypeID,
	}
	if r == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (r *ResetAuthenticationEmailAddressRequest) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode resetAuthenticationEmailAddress#e742722c as nil")
	}
	b.PutID(ResetAuthenticationEmailAddressRequestTypeID)
	return r.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (r *ResetAuthenticationEmailAddressRequest) EncodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode resetAuthenticationEmailAddress#e742722c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (r *ResetAuthenticationEmailAddressRequest) Decode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode resetAuthenticationEmailAddress#e742722c to nil")
	}
	if err := b.ConsumeID(ResetAuthenticationEmailAddressRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode resetAuthenticationEmailAddress#e742722c: %w", err)
	}
	return r.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (r *ResetAuthenticationEmailAddressRequest) DecodeBare(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't decode resetAuthenticationEmailAddress#e742722c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (r *ResetAuthenticationEmailAddressRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if r == nil {
		return fmt.Errorf("can't encode resetAuthenticationEmailAddress#e742722c as nil")
	}
	b.ObjStart()
	b.PutID("resetAuthenticationEmailAddress")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *ResetAuthenticationEmailAddressRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if r == nil {
		return fmt.Errorf("can't decode resetAuthenticationEmailAddress#e742722c to nil")
	}

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

// ResetAuthenticationEmailAddress invokes method resetAuthenticationEmailAddress#e742722c returning error if any.
func (c *Client) ResetAuthenticationEmailAddress(ctx context.Context) error {
	var ok Ok

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