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

// ChatInviteImporter represents TL type `chatInviteImporter#8c5adfd9`.
// When and which user joined the chat using a chat invite
//
// See https://core.telegram.org/constructor/chatInviteImporter for reference.
type ChatInviteImporter struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this user currently has a pending join request »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	Requested bool
	// The participant joined by importing a chat folder deep link »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#chat-folder-links
	ViaChatlist bool
	// The user
	UserID int64
	// When did the user join
	Date int
	// For users with pending requests, contains bio of the user that requested to join
	//
	// Use SetAbout and GetAbout helpers.
	About string
	// The administrator that approved the join request »¹ of the user
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//
	// Use SetApprovedBy and GetApprovedBy helpers.
	ApprovedBy int64
}

// ChatInviteImporterTypeID is TL type id of ChatInviteImporter.
const ChatInviteImporterTypeID = 0x8c5adfd9

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

func ( *ChatInviteImporter) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Requested == false) {
		return false
	}
	if !(.ViaChatlist == false) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.About == "") {
		return false
	}
	if !(.ApprovedBy == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChatInviteImporter from given interface.
func ( *ChatInviteImporter) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int)
	() ( string,  bool)
	() ( int64,  bool)
}) {
	.Requested = .()
	.ViaChatlist = .()
	.UserID = .()
	.Date = .()
	if ,  := .();  {
		.About = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*ChatInviteImporter) () string {
	return "chatInviteImporter"
}

// TypeInfo returns info about TL type.
func ( *ChatInviteImporter) () tdp.Type {
	 := tdp.Type{
		Name: "chatInviteImporter",
		ID:   ChatInviteImporterTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Requested",
			SchemaName: "requested",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ViaChatlist",
			SchemaName: "via_chatlist",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "About",
			SchemaName: "about",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ApprovedBy",
			SchemaName: "approved_by",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChatInviteImporter) () {
	if !(.Requested == false) {
		.Flags.Set(0)
	}
	if !(.ViaChatlist == false) {
		.Flags.Set(3)
	}
	if !(.About == "") {
		.Flags.Set(2)
	}
	if !(.ApprovedBy == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *ChatInviteImporter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatInviteImporter#8c5adfd9 as nil")
	}
	.PutID(ChatInviteImporterTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatInviteImporter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatInviteImporter#8c5adfd9 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode chatInviteImporter#8c5adfd9: field flags: %w", )
	}
	.PutLong(.UserID)
	.PutInt(.Date)
	if .Flags.Has(2) {
		.PutString(.About)
	}
	if .Flags.Has(1) {
		.PutLong(.ApprovedBy)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatInviteImporter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatInviteImporter#8c5adfd9 to nil")
	}
	if  := .ConsumeID(ChatInviteImporterTypeID);  != nil {
		return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatInviteImporter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatInviteImporter#8c5adfd9 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: field flags: %w", )
		}
	}
	.Requested = .Flags.Has(0)
	.ViaChatlist = .Flags.Has(3)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: field date: %w", )
		}
		.Date = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: field about: %w", )
		}
		.About = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatInviteImporter#8c5adfd9: field approved_by: %w", )
		}
		.ApprovedBy = 
	}
	return nil
}

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

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

// SetViaChatlist sets value of ViaChatlist conditional field.
func ( *ChatInviteImporter) ( bool) {
	if  {
		.Flags.Set(3)
		.ViaChatlist = true
	} else {
		.Flags.Unset(3)
		.ViaChatlist = false
	}
}

// GetViaChatlist returns value of ViaChatlist conditional field.
func ( *ChatInviteImporter) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// GetUserID returns value of UserID field.
func ( *ChatInviteImporter) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetDate returns value of Date field.
func ( *ChatInviteImporter) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// SetAbout sets value of About conditional field.
func ( *ChatInviteImporter) ( string) {
	.Flags.Set(2)
	.About = 
}

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

// SetApprovedBy sets value of ApprovedBy conditional field.
func ( *ChatInviteImporter) ( int64) {
	.Flags.Set(1)
	.ApprovedBy = 
}

// GetApprovedBy returns value of ApprovedBy conditional field and
// boolean which is true if field was set.
func ( *ChatInviteImporter) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .ApprovedBy, true
}