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

// ToggleVideoChatEnabledStartNotificationRequest represents TL type `toggleVideoChatEnabledStartNotification#6e5b7b3e`.
type ToggleVideoChatEnabledStartNotificationRequest struct {
	// Group call identifier
	GroupCallID int32
	// New value of the enabled_start_notification setting
	EnabledStartNotification bool
}

// ToggleVideoChatEnabledStartNotificationRequestTypeID is TL type id of ToggleVideoChatEnabledStartNotificationRequest.
const ToggleVideoChatEnabledStartNotificationRequestTypeID = 0x6e5b7b3e

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

func (t *ToggleVideoChatEnabledStartNotificationRequest) Zero() bool {
	if t == nil {
		return true
	}
	if !(t.GroupCallID == 0) {
		return false
	}
	if !(t.EnabledStartNotification == false) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (t *ToggleVideoChatEnabledStartNotificationRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "toggleVideoChatEnabledStartNotification",
		ID:   ToggleVideoChatEnabledStartNotificationRequestTypeID,
	}
	if t == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "GroupCallID",
			SchemaName: "group_call_id",
		},
		{
			Name:       "EnabledStartNotification",
			SchemaName: "enabled_start_notification",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) Encode(b *bin.Buffer) error {
	if t == nil {
		return fmt.Errorf("can't encode toggleVideoChatEnabledStartNotification#6e5b7b3e as nil")
	}
	b.PutID(ToggleVideoChatEnabledStartNotificationRequestTypeID)
	return t.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) EncodeBare(b *bin.Buffer) error {
	if t == nil {
		return fmt.Errorf("can't encode toggleVideoChatEnabledStartNotification#6e5b7b3e as nil")
	}
	b.PutInt32(t.GroupCallID)
	b.PutBool(t.EnabledStartNotification)
	return nil
}

// Decode implements bin.Decoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) Decode(b *bin.Buffer) error {
	if t == nil {
		return fmt.Errorf("can't decode toggleVideoChatEnabledStartNotification#6e5b7b3e to nil")
	}
	if err := b.ConsumeID(ToggleVideoChatEnabledStartNotificationRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: %w", err)
	}
	return t.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) DecodeBare(b *bin.Buffer) error {
	if t == nil {
		return fmt.Errorf("can't decode toggleVideoChatEnabledStartNotification#6e5b7b3e to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: field group_call_id: %w", err)
		}
		t.GroupCallID = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: field enabled_start_notification: %w", err)
		}
		t.EnabledStartNotification = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if t == nil {
		return fmt.Errorf("can't encode toggleVideoChatEnabledStartNotification#6e5b7b3e as nil")
	}
	b.ObjStart()
	b.PutID("toggleVideoChatEnabledStartNotification")
	b.Comma()
	b.FieldStart("group_call_id")
	b.PutInt32(t.GroupCallID)
	b.Comma()
	b.FieldStart("enabled_start_notification")
	b.PutBool(t.EnabledStartNotification)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (t *ToggleVideoChatEnabledStartNotificationRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if t == nil {
		return fmt.Errorf("can't decode toggleVideoChatEnabledStartNotification#6e5b7b3e to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("toggleVideoChatEnabledStartNotification"); err != nil {
				return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: %w", err)
			}
		case "group_call_id":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: field group_call_id: %w", err)
			}
			t.GroupCallID = value
		case "enabled_start_notification":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode toggleVideoChatEnabledStartNotification#6e5b7b3e: field enabled_start_notification: %w", err)
			}
			t.EnabledStartNotification = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetGroupCallID returns value of GroupCallID field.
func (t *ToggleVideoChatEnabledStartNotificationRequest) GetGroupCallID() (value int32) {
	if t == nil {
		return
	}
	return t.GroupCallID
}

// GetEnabledStartNotification returns value of EnabledStartNotification field.
func (t *ToggleVideoChatEnabledStartNotificationRequest) GetEnabledStartNotification() (value bool) {
	if t == nil {
		return
	}
	return t.EnabledStartNotification
}

// ToggleVideoChatEnabledStartNotification invokes method toggleVideoChatEnabledStartNotification#6e5b7b3e returning error if any.
func (c *Client) ToggleVideoChatEnabledStartNotification(ctx context.Context, request *ToggleVideoChatEnabledStartNotificationRequest) error {
	var ok Ok

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