// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"github.com/gotd/td/bin"
	"github.com/gotd/td/tdjson"
	"github.com/gotd/td/tdp"
	"github.com/gotd/td/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{}
)

// AccountDeleteAutoSaveExceptionsRequest represents TL type `account.deleteAutoSaveExceptions#53bc0020`.
// Clear all peer-specific autosave settings.
//
// See https://core.telegram.org/method/account.deleteAutoSaveExceptions for reference.
type AccountDeleteAutoSaveExceptionsRequest struct {
}

// AccountDeleteAutoSaveExceptionsRequestTypeID is TL type id of AccountDeleteAutoSaveExceptionsRequest.
const AccountDeleteAutoSaveExceptionsRequestTypeID = 0x53bc0020

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

func (d *AccountDeleteAutoSaveExceptionsRequest) Zero() bool {
	if d == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (d *AccountDeleteAutoSaveExceptionsRequest) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode account.deleteAutoSaveExceptions#53bc0020 as nil")
	}
	b.PutID(AccountDeleteAutoSaveExceptionsRequestTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *AccountDeleteAutoSaveExceptionsRequest) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode account.deleteAutoSaveExceptions#53bc0020 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *AccountDeleteAutoSaveExceptionsRequest) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode account.deleteAutoSaveExceptions#53bc0020 to nil")
	}
	if err := b.ConsumeID(AccountDeleteAutoSaveExceptionsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode account.deleteAutoSaveExceptions#53bc0020: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *AccountDeleteAutoSaveExceptionsRequest) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode account.deleteAutoSaveExceptions#53bc0020 to nil")
	}
	return nil
}

// AccountDeleteAutoSaveExceptions invokes method account.deleteAutoSaveExceptions#53bc0020 returning error if any.
// Clear all peer-specific autosave settings.
//
// See https://core.telegram.org/method/account.deleteAutoSaveExceptions for reference.
func (c *Client) AccountDeleteAutoSaveExceptions(ctx context.Context) (bool, error) {
	var result BoolBox

	request := &AccountDeleteAutoSaveExceptionsRequest{}
	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return false, err
	}
	_, ok := result.Bool.(*BoolTrue)
	return ok, nil
}
