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

// GetSavedNotificationSoundsRequest represents TL type `getSavedNotificationSounds#c0346fa8`.
type GetSavedNotificationSoundsRequest struct {
}

// GetSavedNotificationSoundsRequestTypeID is TL type id of GetSavedNotificationSoundsRequest.
const GetSavedNotificationSoundsRequestTypeID = 0xc0346fa8

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

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (g *GetSavedNotificationSoundsRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getSavedNotificationSounds#c0346fa8 as nil")
	}
	b.PutID(GetSavedNotificationSoundsRequestTypeID)
	return g.EncodeBare(b)
}

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

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

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

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

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

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

// GetSavedNotificationSounds invokes method getSavedNotificationSounds#c0346fa8 returning error if any.
func (c *Client) GetSavedNotificationSounds(ctx context.Context) (*NotificationSounds, error) {
	var result NotificationSounds

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