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

// GetArchiveChatListSettingsRequest represents TL type `getArchiveChatListSettings#838d8e60`.
type GetArchiveChatListSettingsRequest struct {
}

// GetArchiveChatListSettingsRequestTypeID is TL type id of GetArchiveChatListSettingsRequest.
const GetArchiveChatListSettingsRequestTypeID = 0x838d8e60

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

func (g *GetArchiveChatListSettingsRequest) Zero() bool {
	if g == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetArchiveChatListSettingsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getArchiveChatListSettings#838d8e60 as nil")
	}
	b.PutID(GetArchiveChatListSettingsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetArchiveChatListSettingsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getArchiveChatListSettings#838d8e60 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *GetArchiveChatListSettingsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getArchiveChatListSettings#838d8e60 to nil")
	}
	if err := b.ConsumeID(GetArchiveChatListSettingsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode getArchiveChatListSettings#838d8e60: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *GetArchiveChatListSettingsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getArchiveChatListSettings#838d8e60 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetArchiveChatListSettingsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if g == nil {
		return fmt.Errorf("can't encode getArchiveChatListSettings#838d8e60 as nil")
	}
	b.ObjStart()
	b.PutID("getArchiveChatListSettings")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetArchiveChatListSettingsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if g == nil {
		return fmt.Errorf("can't decode getArchiveChatListSettings#838d8e60 to nil")
	}

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

// GetArchiveChatListSettings invokes method getArchiveChatListSettings#838d8e60 returning error if any.
func (c *Client) GetArchiveChatListSettings(ctx context.Context) (*ArchiveChatListSettings, error) {
	var result ArchiveChatListSettings

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