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

// CommunitiesToggleCommunityCollapsedInDialogsRequest represents TL type `communities.toggleCommunityCollapsedInDialogs#d766e3ea`.
//
// See https://core.telegram.org/method/communities.toggleCommunityCollapsedInDialogs for reference.
type CommunitiesToggleCommunityCollapsedInDialogsRequest struct {
	// Flags field of CommunitiesToggleCommunityCollapsedInDialogsRequest.
	Flags bin.Fields
	// Collapsed field of CommunitiesToggleCommunityCollapsedInDialogsRequest.
	Collapsed bool
	// Community field of CommunitiesToggleCommunityCollapsedInDialogsRequest.
	Community InputChannelClass
}

// CommunitiesToggleCommunityCollapsedInDialogsRequestTypeID is TL type id of CommunitiesToggleCommunityCollapsedInDialogsRequest.
const CommunitiesToggleCommunityCollapsedInDialogsRequestTypeID = 0xd766e3ea

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

func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Collapsed == false) {
		return false
	}
	if !(.Community == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CommunitiesToggleCommunityCollapsedInDialogsRequest from given interface.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
}) {
	.Collapsed = .()
	.Community = .()
}

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

// TypeName returns name of type in TL schema.
func (*CommunitiesToggleCommunityCollapsedInDialogsRequest) () string {
	return "communities.toggleCommunityCollapsedInDialogs"
}

// TypeInfo returns info about TL type.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "communities.toggleCommunityCollapsedInDialogs",
		ID:   CommunitiesToggleCommunityCollapsedInDialogsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Collapsed",
			SchemaName: "collapsed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Community",
			SchemaName: "community",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () {
	if !(.Collapsed == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.toggleCommunityCollapsedInDialogs#d766e3ea as nil")
	}
	.PutID(CommunitiesToggleCommunityCollapsedInDialogsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.toggleCommunityCollapsedInDialogs#d766e3ea as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.toggleCommunityCollapsedInDialogs#d766e3ea: field flags: %w", )
	}
	if .Community == nil {
		return fmt.Errorf("unable to encode communities.toggleCommunityCollapsedInDialogs#d766e3ea: field community is nil")
	}
	if  := .Community.Encode();  != nil {
		return fmt.Errorf("unable to encode communities.toggleCommunityCollapsedInDialogs#d766e3ea: field community: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.toggleCommunityCollapsedInDialogs#d766e3ea to nil")
	}
	if  := .ConsumeID(CommunitiesToggleCommunityCollapsedInDialogsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode communities.toggleCommunityCollapsedInDialogs#d766e3ea: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.toggleCommunityCollapsedInDialogs#d766e3ea to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode communities.toggleCommunityCollapsedInDialogs#d766e3ea: field flags: %w", )
		}
	}
	.Collapsed = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode communities.toggleCommunityCollapsedInDialogs#d766e3ea: field community: %w", )
		}
		.Community = 
	}
	return nil
}

// SetCollapsed sets value of Collapsed conditional field.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Collapsed = true
	} else {
		.Flags.Unset(0)
		.Collapsed = false
	}
}

// GetCollapsed returns value of Collapsed conditional field.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetCommunity returns value of Community field.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Community
}

// GetCommunityAsNotEmpty returns mapped value of Community field.
func ( *CommunitiesToggleCommunityCollapsedInDialogsRequest) () (NotEmptyInputChannel, bool) {
	return .Community.AsNotEmpty()
}

// CommunitiesToggleCommunityCollapsedInDialogs invokes method communities.toggleCommunityCollapsedInDialogs#d766e3ea returning error if any.
//
// See https://core.telegram.org/method/communities.toggleCommunityCollapsedInDialogs for reference.
func ( *Client) ( context.Context,  *CommunitiesToggleCommunityCollapsedInDialogsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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