// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

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

// ChannelsToggleViewForumAsMessagesRequest represents TL type `channels.toggleViewForumAsMessages#9738bb15`.
// Users may also choose to display messages from all topics of a forum¹ as if they were
// sent to a normal group, using a "View as messages" setting in the local client: this
// setting only affects the current account, and is synced to other logged in sessions
// using this method.
// Invoking this method will update the value of the view_forum_as_messages flag of
// channelFull¹ or dialog² and emit an updateChannelViewForumAsMessages³.
//
// Links:
//  1. https://core.telegram.org/api/forum
//  2. https://core.telegram.org/constructor/channelFull
//  3. https://core.telegram.org/constructor/dialog
//  4. https://core.telegram.org/constructor/updateChannelViewForumAsMessages
//
// See https://core.telegram.org/method/channels.toggleViewForumAsMessages for reference.
type ChannelsToggleViewForumAsMessagesRequest struct {
	// The forum
	Channel InputChannelClass
	// The new value of the view_forum_as_messages flag.
	Enabled bool
}

// ChannelsToggleViewForumAsMessagesRequestTypeID is TL type id of ChannelsToggleViewForumAsMessagesRequest.
const ChannelsToggleViewForumAsMessagesRequestTypeID = 0x9738bb15

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

func ( *ChannelsToggleViewForumAsMessagesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsToggleViewForumAsMessagesRequest from given interface.
func ( *ChannelsToggleViewForumAsMessagesRequest) ( interface {
	() ( InputChannelClass)
	() ( bool)
}) {
	.Channel = .()
	.Enabled = .()
}

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

// TypeName returns name of type in TL schema.
func (*ChannelsToggleViewForumAsMessagesRequest) () string {
	return "channels.toggleViewForumAsMessages"
}

// TypeInfo returns info about TL type.
func ( *ChannelsToggleViewForumAsMessagesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.toggleViewForumAsMessages",
		ID:   ChannelsToggleViewForumAsMessagesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsToggleViewForumAsMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleViewForumAsMessages#9738bb15 as nil")
	}
	.PutID(ChannelsToggleViewForumAsMessagesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsToggleViewForumAsMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleViewForumAsMessages#9738bb15 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.toggleViewForumAsMessages#9738bb15: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.toggleViewForumAsMessages#9738bb15: field channel: %w", )
	}
	.PutBool(.Enabled)
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsToggleViewForumAsMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.toggleViewForumAsMessages#9738bb15 to nil")
	}
	if  := .ConsumeID(ChannelsToggleViewForumAsMessagesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.toggleViewForumAsMessages#9738bb15: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsToggleViewForumAsMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.toggleViewForumAsMessages#9738bb15 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.toggleViewForumAsMessages#9738bb15: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.toggleViewForumAsMessages#9738bb15: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

// GetChannel returns value of Channel field.
func ( *ChannelsToggleViewForumAsMessagesRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

// GetEnabled returns value of Enabled field.
func ( *ChannelsToggleViewForumAsMessagesRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Enabled
}

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *ChannelsToggleViewForumAsMessagesRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// ChannelsToggleViewForumAsMessages invokes method channels.toggleViewForumAsMessages#9738bb15 returning error if any.
// Users may also choose to display messages from all topics of a forum¹ as if they were
// sent to a normal group, using a "View as messages" setting in the local client: this
// setting only affects the current account, and is synced to other logged in sessions
// using this method.
// Invoking this method will update the value of the view_forum_as_messages flag of
// channelFull¹ or dialog² and emit an updateChannelViewForumAsMessages³.
//
// Links:
//  1. https://core.telegram.org/api/forum
//  2. https://core.telegram.org/constructor/channelFull
//  3. https://core.telegram.org/constructor/dialog
//  4. https://core.telegram.org/constructor/updateChannelViewForumAsMessages
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.toggleViewForumAsMessages for reference.
func ( *Client) ( context.Context,  *ChannelsToggleViewForumAsMessagesRequest) (UpdatesClass, error) {
	var  UpdatesBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .Updates, nil
}