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

// MessagesEditExportedChatInviteRequest represents TL type `messages.editExportedChatInvite#bdca2f75`.
// Edit an exported chat invite
//
// See https://core.telegram.org/method/messages.editExportedChatInvite for reference.
type MessagesEditExportedChatInviteRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to revoke the chat invite
	Revoked bool
	// Chat
	Peer InputPeerClass
	// Invite link
	Link string
	// New expiration date
	//
	// Use SetExpireDate and GetExpireDate helpers.
	ExpireDate int
	// Maximum number of users that can join using this link
	//
	// Use SetUsageLimit and GetUsageLimit helpers.
	UsageLimit int
	// Whether admin confirmation is required before admitting each separate user into the
	// chat
	//
	// Use SetRequestNeeded and GetRequestNeeded helpers.
	RequestNeeded bool
	// Description of the invite link, visible only to administrators
	//
	// Use SetTitle and GetTitle helpers.
	Title string
}

// MessagesEditExportedChatInviteRequestTypeID is TL type id of MessagesEditExportedChatInviteRequest.
const MessagesEditExportedChatInviteRequestTypeID = 0xbdca2f75

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

func ( *MessagesEditExportedChatInviteRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Revoked == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Link == "") {
		return false
	}
	if !(.ExpireDate == 0) {
		return false
	}
	if !(.UsageLimit == 0) {
		return false
	}
	if !(.RequestNeeded == false) {
		return false
	}
	if !(.Title == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesEditExportedChatInviteRequest from given interface.
func ( *MessagesEditExportedChatInviteRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( string)
	() ( int,  bool)
	() ( int,  bool)
	() ( bool,  bool)
	() ( string,  bool)
}) {
	.Revoked = .()
	.Peer = .()
	.Link = .()
	if ,  := .();  {
		.ExpireDate = 
	}

	if ,  := .();  {
		.UsageLimit = 
	}

	if ,  := .();  {
		.RequestNeeded = 
	}

	if ,  := .();  {
		.Title = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesEditExportedChatInviteRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.editExportedChatInvite",
		ID:   MessagesEditExportedChatInviteRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Revoked",
			SchemaName: "revoked",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Link",
			SchemaName: "link",
		},
		{
			Name:       "ExpireDate",
			SchemaName: "expire_date",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "UsageLimit",
			SchemaName: "usage_limit",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "RequestNeeded",
			SchemaName: "request_needed",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesEditExportedChatInviteRequest) () {
	if !(.Revoked == false) {
		.Flags.Set(2)
	}
	if !(.ExpireDate == 0) {
		.Flags.Set(0)
	}
	if !(.UsageLimit == 0) {
		.Flags.Set(1)
	}
	if !(.RequestNeeded == false) {
		.Flags.Set(3)
	}
	if !(.Title == "") {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesEditExportedChatInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editExportedChatInvite#bdca2f75 as nil")
	}
	.PutID(MessagesEditExportedChatInviteRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesEditExportedChatInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editExportedChatInvite#bdca2f75 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editExportedChatInvite#bdca2f75: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.editExportedChatInvite#bdca2f75: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editExportedChatInvite#bdca2f75: field peer: %w", )
	}
	.PutString(.Link)
	if .Flags.Has(0) {
		.PutInt(.ExpireDate)
	}
	if .Flags.Has(1) {
		.PutInt(.UsageLimit)
	}
	if .Flags.Has(3) {
		.PutBool(.RequestNeeded)
	}
	if .Flags.Has(4) {
		.PutString(.Title)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesEditExportedChatInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editExportedChatInvite#bdca2f75 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field flags: %w", )
		}
	}
	.Revoked = .Flags.Has(2)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field link: %w", )
		}
		.Link = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field expire_date: %w", )
		}
		.ExpireDate = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field usage_limit: %w", )
		}
		.UsageLimit = 
	}
	if .Flags.Has(3) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field request_needed: %w", )
		}
		.RequestNeeded = 
	}
	if .Flags.Has(4) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editExportedChatInvite#bdca2f75: field title: %w", )
		}
		.Title = 
	}
	return nil
}

// SetRevoked sets value of Revoked conditional field.
func ( *MessagesEditExportedChatInviteRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.Revoked = true
	} else {
		.Flags.Unset(2)
		.Revoked = false
	}
}

// GetRevoked returns value of Revoked conditional field.
func ( *MessagesEditExportedChatInviteRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

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

// GetLink returns value of Link field.
func ( *MessagesEditExportedChatInviteRequest) () ( string) {
	if  == nil {
		return
	}
	return .Link
}

// SetExpireDate sets value of ExpireDate conditional field.
func ( *MessagesEditExportedChatInviteRequest) ( int) {
	.Flags.Set(0)
	.ExpireDate = 
}

// GetExpireDate returns value of ExpireDate conditional field and
// boolean which is true if field was set.
func ( *MessagesEditExportedChatInviteRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ExpireDate, true
}

// SetUsageLimit sets value of UsageLimit conditional field.
func ( *MessagesEditExportedChatInviteRequest) ( int) {
	.Flags.Set(1)
	.UsageLimit = 
}

// GetUsageLimit returns value of UsageLimit conditional field and
// boolean which is true if field was set.
func ( *MessagesEditExportedChatInviteRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .UsageLimit, true
}

// SetRequestNeeded sets value of RequestNeeded conditional field.
func ( *MessagesEditExportedChatInviteRequest) ( bool) {
	.Flags.Set(3)
	.RequestNeeded = 
}

// GetRequestNeeded returns value of RequestNeeded conditional field and
// boolean which is true if field was set.
func ( *MessagesEditExportedChatInviteRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .RequestNeeded, true
}

// SetTitle sets value of Title conditional field.
func ( *MessagesEditExportedChatInviteRequest) ( string) {
	.Flags.Set(4)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *MessagesEditExportedChatInviteRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .Title, true
}

// MessagesEditExportedChatInvite invokes method messages.editExportedChatInvite#bdca2f75 returning error if any.
// Edit an exported chat invite
//
// Possible errors:
//
//	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.
//	400 CHAT_INVITE_PERMANENT: You can't set an expiration date on permanent invite links.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	403 EDIT_BOT_INVITE_FORBIDDEN: Normal users can't edit invites that were created by bots.
//	400 INVITE_HASH_EXPIRED: The invite link has expired.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.editExportedChatInvite for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesEditExportedChatInviteRequest) (MessagesExportedChatInviteClass, error) {
	var  MessagesExportedChatInviteBox

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