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

// RequestAuthenticationPasswordRecoveryRequest represents TL type `requestAuthenticationPasswordRecovery#53152ab6`.
type RequestAuthenticationPasswordRecoveryRequest struct {
}

// RequestAuthenticationPasswordRecoveryRequestTypeID is TL type id of RequestAuthenticationPasswordRecoveryRequest.
const RequestAuthenticationPasswordRecoveryRequestTypeID = 0x53152ab6

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *RequestAuthenticationPasswordRecoveryRequest) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode requestAuthenticationPasswordRecovery#53152ab6 as nil")
	}
	b.PutID(RequestAuthenticationPasswordRecoveryRequestTypeID)
	return r.EncodeBare(b)
}

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

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

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

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

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

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

// RequestAuthenticationPasswordRecovery invokes method requestAuthenticationPasswordRecovery#53152ab6 returning error if any.
func (c *Client) RequestAuthenticationPasswordRecovery(ctx context.Context) error {
	var ok Ok

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