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

// MessagesGetChatInviteImportersRequest represents TL type `messages.getChatInviteImporters#df04dd4e`.
// Get info about the users that joined the chat using a specific chat invite
//
// See https://core.telegram.org/method/messages.getChatInviteImporters for reference.
type MessagesGetChatInviteImportersRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, only returns info about users with pending join requests »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	Requested bool
	// Chat
	Peer InputPeerClass
	// Invite link
	//
	// Use SetLink and GetLink helpers.
	Link string
	// Search for a user in the pending join requests »¹ list: only available when the
	// requested flag is set, cannot be used together with a specific link.
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//
	// Use SetQ and GetQ helpers.
	Q string
	// Offsets for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetDate int
	// User ID for pagination¹: if set, offset_date must also be set.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetUser InputUserClass
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// MessagesGetChatInviteImportersRequestTypeID is TL type id of MessagesGetChatInviteImportersRequest.
const MessagesGetChatInviteImportersRequestTypeID = 0xdf04dd4e

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

func ( *MessagesGetChatInviteImportersRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Requested == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Link == "") {
		return false
	}
	if !(.Q == "") {
		return false
	}
	if !(.OffsetDate == 0) {
		return false
	}
	if !(.OffsetUser == nil) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

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

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

	.OffsetDate = .()
	.OffsetUser = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetChatInviteImportersRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getChatInviteImporters",
		ID:   MessagesGetChatInviteImportersRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Requested",
			SchemaName: "requested",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Link",
			SchemaName: "link",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Q",
			SchemaName: "q",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "OffsetDate",
			SchemaName: "offset_date",
		},
		{
			Name:       "OffsetUser",
			SchemaName: "offset_user",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesGetChatInviteImportersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getChatInviteImporters#df04dd4e as nil")
	}
	.PutID(MessagesGetChatInviteImportersRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetChatInviteImportersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getChatInviteImporters#df04dd4e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getChatInviteImporters#df04dd4e: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.getChatInviteImporters#df04dd4e: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getChatInviteImporters#df04dd4e: field peer: %w", )
	}
	if .Flags.Has(1) {
		.PutString(.Link)
	}
	if .Flags.Has(2) {
		.PutString(.Q)
	}
	.PutInt(.OffsetDate)
	if .OffsetUser == nil {
		return fmt.Errorf("unable to encode messages.getChatInviteImporters#df04dd4e: field offset_user is nil")
	}
	if  := .OffsetUser.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.getChatInviteImporters#df04dd4e: field offset_user: %w", )
	}
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetChatInviteImportersRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getChatInviteImporters#df04dd4e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field flags: %w", )
		}
	}
	.Requested = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field link: %w", )
		}
		.Link = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field q: %w", )
		}
		.Q = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field offset_date: %w", )
		}
		.OffsetDate = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field offset_user: %w", )
		}
		.OffsetUser = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getChatInviteImporters#df04dd4e: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetRequested sets value of Requested conditional field.
func ( *MessagesGetChatInviteImportersRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Requested = true
	} else {
		.Flags.Unset(0)
		.Requested = false
	}
}

// GetRequested returns value of Requested conditional field.
func ( *MessagesGetChatInviteImportersRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

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

// SetQ sets value of Q conditional field.
func ( *MessagesGetChatInviteImportersRequest) ( string) {
	.Flags.Set(2)
	.Q = 
}

// GetQ returns value of Q conditional field and
// boolean which is true if field was set.
func ( *MessagesGetChatInviteImportersRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Q, true
}

// GetOffsetDate returns value of OffsetDate field.
func ( *MessagesGetChatInviteImportersRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetDate
}

// GetOffsetUser returns value of OffsetUser field.
func ( *MessagesGetChatInviteImportersRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .OffsetUser
}

// GetLimit returns value of Limit field.
func ( *MessagesGetChatInviteImportersRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// MessagesGetChatInviteImporters invokes method messages.getChatInviteImporters#df04dd4e returning error if any.
// Get info about the users that joined the chat using a specific chat invite
//
// Possible errors:
//
//	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 INVITE_HASH_EXPIRED: The invite link has expired.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SEARCH_WITH_LINK_NOT_SUPPORTED: You cannot provide a search query and an invite link at the same time.
//
// See https://core.telegram.org/method/messages.getChatInviteImporters for reference.
func ( *Client) ( context.Context,  *MessagesGetChatInviteImportersRequest) (*MessagesChatInviteImporters, error) {
	var  MessagesChatInviteImporters

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