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

// ResetAllNotificationSettingsRequest represents TL type `resetAllNotificationSettings#f5a0a8f9`.
type ResetAllNotificationSettingsRequest struct {
}

// ResetAllNotificationSettingsRequestTypeID is TL type id of ResetAllNotificationSettingsRequest.
const ResetAllNotificationSettingsRequestTypeID = 0xf5a0a8f9

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (r *ResetAllNotificationSettingsRequest) Encode(b *bin.Buffer) error {
	if r == nil {
		return fmt.Errorf("can't encode resetAllNotificationSettings#f5a0a8f9 as nil")
	}
	b.PutID(ResetAllNotificationSettingsRequestTypeID)
	return r.EncodeBare(b)
}

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

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

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

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

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

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

// ResetAllNotificationSettings invokes method resetAllNotificationSettings#f5a0a8f9 returning error if any.
func (c *Client) ResetAllNotificationSettings(ctx context.Context) error {
	var ok Ok

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