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

// GetReadDatePrivacySettingsRequest represents TL type `getReadDatePrivacySettings#1ae85bbb`.
type GetReadDatePrivacySettingsRequest struct {
}

// GetReadDatePrivacySettingsRequestTypeID is TL type id of GetReadDatePrivacySettingsRequest.
const GetReadDatePrivacySettingsRequestTypeID = 0x1ae85bbb

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetReadDatePrivacySettingsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getReadDatePrivacySettings#1ae85bbb as nil")
	}
	b.PutID(GetReadDatePrivacySettingsRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetReadDatePrivacySettingsRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getReadDatePrivacySettings#1ae85bbb as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *GetReadDatePrivacySettingsRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getReadDatePrivacySettings#1ae85bbb to nil")
	}
	if err := b.ConsumeID(GetReadDatePrivacySettingsRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode getReadDatePrivacySettings#1ae85bbb: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *GetReadDatePrivacySettingsRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getReadDatePrivacySettings#1ae85bbb to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetReadDatePrivacySettingsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if g == nil {
		return fmt.Errorf("can't decode getReadDatePrivacySettings#1ae85bbb to nil")
	}

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

// GetReadDatePrivacySettings invokes method getReadDatePrivacySettings#1ae85bbb returning error if any.
func (c *Client) GetReadDatePrivacySettings(ctx context.Context) (*ReadDatePrivacySettings, error) {
	var result ReadDatePrivacySettings

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