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

// MessagesHideAllChatJoinRequestsRequest represents TL type `messages.hideAllChatJoinRequests#e085f4ea`.
// Dismiss or approve all join requests¹ related to a specific chat or channel.
//
// Links:
//  1. https://core.telegram.org/api/invites#join-requests
//
// See https://core.telegram.org/method/messages.hideAllChatJoinRequests for reference.
type MessagesHideAllChatJoinRequestsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to dismiss or approve all chat join requests »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	Approved bool
	// The chat or channel
	Peer InputPeerClass
	// Only dismiss or approve join requests »¹ initiated using this invite link
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//
	// Use SetLink and GetLink helpers.
	Link string
}

// MessagesHideAllChatJoinRequestsRequestTypeID is TL type id of MessagesHideAllChatJoinRequestsRequest.
const MessagesHideAllChatJoinRequestsRequestTypeID = 0xe085f4ea

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

func ( *MessagesHideAllChatJoinRequestsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Approved == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Link == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesHideAllChatJoinRequestsRequest from given interface.
func ( *MessagesHideAllChatJoinRequestsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( string,  bool)
}) {
	.Approved = .()
	.Peer = .()
	if ,  := .();  {
		.Link = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*MessagesHideAllChatJoinRequestsRequest) () string {
	return "messages.hideAllChatJoinRequests"
}

// TypeInfo returns info about TL type.
func ( *MessagesHideAllChatJoinRequestsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.hideAllChatJoinRequests",
		ID:   MessagesHideAllChatJoinRequestsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Approved",
			SchemaName: "approved",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Link",
			SchemaName: "link",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesHideAllChatJoinRequestsRequest) () {
	if !(.Approved == false) {
		.Flags.Set(0)
	}
	if !(.Link == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesHideAllChatJoinRequestsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.hideAllChatJoinRequests#e085f4ea as nil")
	}
	.PutID(MessagesHideAllChatJoinRequestsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesHideAllChatJoinRequestsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.hideAllChatJoinRequests#e085f4ea as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.hideAllChatJoinRequests#e085f4ea: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.hideAllChatJoinRequests#e085f4ea: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.hideAllChatJoinRequests#e085f4ea: field peer: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.Link)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesHideAllChatJoinRequestsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.hideAllChatJoinRequests#e085f4ea to nil")
	}
	if  := .ConsumeID(MessagesHideAllChatJoinRequestsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.hideAllChatJoinRequests#e085f4ea: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesHideAllChatJoinRequestsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.hideAllChatJoinRequests#e085f4ea to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.hideAllChatJoinRequests#e085f4ea: field flags: %w", )
		}
	}
	.Approved = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.hideAllChatJoinRequests#e085f4ea: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.hideAllChatJoinRequests#e085f4ea: field link: %w", )
		}
		.Link = 
	}
	return nil
}

// SetApproved sets value of Approved conditional field.
func ( *MessagesHideAllChatJoinRequestsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Approved = true
	} else {
		.Flags.Unset(0)
		.Approved = false
	}
}

// GetApproved returns value of Approved conditional field.
func ( *MessagesHideAllChatJoinRequestsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetPeer returns value of Peer field.
func ( *MessagesHideAllChatJoinRequestsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// SetLink sets value of Link conditional field.
func ( *MessagesHideAllChatJoinRequestsRequest) ( string) {
	.Flags.Set(1)
	.Link = 
}

// GetLink returns value of Link conditional field and
// boolean which is true if field was set.
func ( *MessagesHideAllChatJoinRequestsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Link, true
}

// MessagesHideAllChatJoinRequests invokes method messages.hideAllChatJoinRequests#e085f4ea returning error if any.
// Dismiss or approve all join requests¹ related to a specific chat or channel.
//
// Links:
//  1. https://core.telegram.org/api/invites#join-requests
//
// Possible errors:
//
//	400 CHANNELS_TOO_MUCH: You have joined too many channels/supergroups.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 HIDE_REQUESTER_MISSING: The join request was missing or was already handled.
//	400 INVITE_HASH_EXPIRED: The invite link has expired.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_CHANNELS_TOO_MUCH: One of the users you tried to add is already in too many channels/supergroups.
//
// See https://core.telegram.org/method/messages.hideAllChatJoinRequests for reference.
func ( *Client) ( context.Context,  *MessagesHideAllChatJoinRequestsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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