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

// MissingInvitee represents TL type `missingInvitee#628c9224`.
// Info about why a specific user could not be invited »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#direct-invites
//
// See https://core.telegram.org/constructor/missingInvitee for reference.
type MissingInvitee struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, we could not add the user only because the current account needs to purchase a
	// Telegram Premium¹ subscription to complete the operation.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	PremiumWouldAllowInvite bool
	// If set, we could not add the user because of their privacy settings, and additionally,
	// the current account needs to purchase a Telegram Premium¹ subscription to directly
	// share an invite link with the user via a private message.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	PremiumRequiredForPm bool
	// ID of the user. If neither of the flags below are set, we could not add the user
	// because of their privacy settings, and we can create and directly share an invite
	// link¹ with them using a normal message, instead.
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#invite-links
	UserID int64
}

// MissingInviteeTypeID is TL type id of MissingInvitee.
const MissingInviteeTypeID = 0x628c9224

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

func ( *MissingInvitee) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PremiumWouldAllowInvite == false) {
		return false
	}
	if !(.PremiumRequiredForPm == false) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MissingInvitee from given interface.
func ( *MissingInvitee) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
}) {
	.PremiumWouldAllowInvite = .()
	.PremiumRequiredForPm = .()
	.UserID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MissingInvitee) () tdp.Type {
	 := tdp.Type{
		Name: "missingInvitee",
		ID:   MissingInviteeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PremiumWouldAllowInvite",
			SchemaName: "premium_would_allow_invite",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "PremiumRequiredForPm",
			SchemaName: "premium_required_for_pm",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MissingInvitee) () {
	if !(.PremiumWouldAllowInvite == false) {
		.Flags.Set(0)
	}
	if !(.PremiumRequiredForPm == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MissingInvitee) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode missingInvitee#628c9224 as nil")
	}
	.PutID(MissingInviteeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MissingInvitee) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode missingInvitee#628c9224 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode missingInvitee#628c9224: field flags: %w", )
	}
	.PutLong(.UserID)
	return nil
}

// Decode implements bin.Decoder.
func ( *MissingInvitee) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode missingInvitee#628c9224 to nil")
	}
	if  := .ConsumeID(MissingInviteeTypeID);  != nil {
		return fmt.Errorf("unable to decode missingInvitee#628c9224: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MissingInvitee) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode missingInvitee#628c9224 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode missingInvitee#628c9224: field flags: %w", )
		}
	}
	.PremiumWouldAllowInvite = .Flags.Has(0)
	.PremiumRequiredForPm = .Flags.Has(1)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode missingInvitee#628c9224: field user_id: %w", )
		}
		.UserID = 
	}
	return nil
}

// SetPremiumWouldAllowInvite sets value of PremiumWouldAllowInvite conditional field.
func ( *MissingInvitee) ( bool) {
	if  {
		.Flags.Set(0)
		.PremiumWouldAllowInvite = true
	} else {
		.Flags.Unset(0)
		.PremiumWouldAllowInvite = false
	}
}

// GetPremiumWouldAllowInvite returns value of PremiumWouldAllowInvite conditional field.
func ( *MissingInvitee) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetPremiumRequiredForPm sets value of PremiumRequiredForPm conditional field.
func ( *MissingInvitee) ( bool) {
	if  {
		.Flags.Set(1)
		.PremiumRequiredForPm = true
	} else {
		.Flags.Unset(1)
		.PremiumRequiredForPm = false
	}
}

// GetPremiumRequiredForPm returns value of PremiumRequiredForPm conditional field.
func ( *MissingInvitee) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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