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

// GlobalPrivacySettings represents TL type `globalPrivacySettings#fe41b34f`.
// Global privacy settings
//
// See https://core.telegram.org/constructor/globalPrivacySettings for reference.
type GlobalPrivacySettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to archive and mute new chats from non-contacts
	ArchiveAndMuteNewNoncontactPeers bool
	// Whether unmuted chats will be kept in the Archive chat list when they get a new
	// message.
	KeepArchivedUnmuted bool
	// Whether unmuted chats that are always included or pinned in a folder¹, will be kept
	// in the Archive chat list when they get a new message. Ignored if keep_archived_unmuted
	// is set.
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	KeepArchivedFolders bool
	// If this flag is set, the inputPrivacyKeyStatusTimestamp¹ key will also apply to the
	// ability to use messages.getOutboxReadDate² on messages sent to us. Meaning, users
	// that cannot see our exact last online date due to the current value of the
	// inputPrivacyKeyStatusTimestamp³ key will receive a 403 USER_PRIVACY_RESTRICTED error
	// when invoking messages.getOutboxReadDate⁴ to fetch the exact read date of a message
	// they sent to us. The userFull⁵.read_dates_private flag will be set for users that
	// have this flag enabled.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPrivacyKeyStatusTimestamp
	//  2) https://core.telegram.org/method/messages.getOutboxReadDate
	//  3) https://core.telegram.org/constructor/inputPrivacyKeyStatusTimestamp
	//  4) https://core.telegram.org/method/messages.getOutboxReadDate
	//  5) https://core.telegram.org/constructor/userFull
	HideReadMarks bool
	// See here for more info on this flag »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/privacy#require-premium-for-new-non-contact-users
	NewNoncontactPeersRequirePremium bool
	// Enables or disables our userFull¹.display_gifts_button flag: if the userFull²
	// display_gifts_button flag of both us and another user is set, a gift button should
	// always be displayed in the text field in private chats with the other user: once
	// clicked, the gift UI should be displayed, offering the user options to gift Telegram
	// Premium »³ subscriptions or Telegram Gifts »⁴.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/userFull
	//  2) https://core.telegram.org/constructor/userFull
	//  3) https://core.telegram.org/api/premium#gifting-telegram-premium
	//  4) https://core.telegram.org/api/gifts
	DisplayGiftsButton bool
	// If configured, specifies the number of stars¹ users must pay us to send us a message,
	// see here »² for more info on paid messages.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	//  2) https://core.telegram.org/api/paid-messages
	//
	// Use SetNoncontactPeersPaidStars and GetNoncontactPeersPaidStars helpers.
	NoncontactPeersPaidStars int64
	// Disallows the reception of specific gift types.
	//
	// Use SetDisallowedGifts and GetDisallowedGifts helpers.
	DisallowedGifts DisallowedGiftsSettings
}

// GlobalPrivacySettingsTypeID is TL type id of GlobalPrivacySettings.
const GlobalPrivacySettingsTypeID = 0xfe41b34f

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

func ( *GlobalPrivacySettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ArchiveAndMuteNewNoncontactPeers == false) {
		return false
	}
	if !(.KeepArchivedUnmuted == false) {
		return false
	}
	if !(.KeepArchivedFolders == false) {
		return false
	}
	if !(.HideReadMarks == false) {
		return false
	}
	if !(.NewNoncontactPeersRequirePremium == false) {
		return false
	}
	if !(.DisplayGiftsButton == false) {
		return false
	}
	if !(.NoncontactPeersPaidStars == 0) {
		return false
	}
	if !(.DisallowedGifts.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills GlobalPrivacySettings from given interface.
func ( *GlobalPrivacySettings) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64,  bool)
	() ( DisallowedGiftsSettings,  bool)
}) {
	.ArchiveAndMuteNewNoncontactPeers = .()
	.KeepArchivedUnmuted = .()
	.KeepArchivedFolders = .()
	.HideReadMarks = .()
	.NewNoncontactPeersRequirePremium = .()
	.DisplayGiftsButton = .()
	if ,  := .();  {
		.NoncontactPeersPaidStars = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *GlobalPrivacySettings) () tdp.Type {
	 := tdp.Type{
		Name: "globalPrivacySettings",
		ID:   GlobalPrivacySettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ArchiveAndMuteNewNoncontactPeers",
			SchemaName: "archive_and_mute_new_noncontact_peers",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "KeepArchivedUnmuted",
			SchemaName: "keep_archived_unmuted",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "KeepArchivedFolders",
			SchemaName: "keep_archived_folders",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "HideReadMarks",
			SchemaName: "hide_read_marks",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "NewNoncontactPeersRequirePremium",
			SchemaName: "new_noncontact_peers_require_premium",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "DisplayGiftsButton",
			SchemaName: "display_gifts_button",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "NoncontactPeersPaidStars",
			SchemaName: "noncontact_peers_paid_stars",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "DisallowedGifts",
			SchemaName: "disallowed_gifts",
			Null:       !.Flags.Has(6),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *GlobalPrivacySettings) () {
	if !(.ArchiveAndMuteNewNoncontactPeers == false) {
		.Flags.Set(0)
	}
	if !(.KeepArchivedUnmuted == false) {
		.Flags.Set(1)
	}
	if !(.KeepArchivedFolders == false) {
		.Flags.Set(2)
	}
	if !(.HideReadMarks == false) {
		.Flags.Set(3)
	}
	if !(.NewNoncontactPeersRequirePremium == false) {
		.Flags.Set(4)
	}
	if !(.DisplayGiftsButton == false) {
		.Flags.Set(7)
	}
	if !(.NoncontactPeersPaidStars == 0) {
		.Flags.Set(5)
	}
	if !(.DisallowedGifts.Zero()) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode globalPrivacySettings#fe41b34f as nil")
	}
	.PutID(GlobalPrivacySettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode globalPrivacySettings#fe41b34f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode globalPrivacySettings#fe41b34f: field flags: %w", )
	}
	if .Flags.Has(5) {
		.PutLong(.NoncontactPeersPaidStars)
	}
	if .Flags.Has(6) {
		if  := .DisallowedGifts.Encode();  != nil {
			return fmt.Errorf("unable to encode globalPrivacySettings#fe41b34f: field disallowed_gifts: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode globalPrivacySettings#fe41b34f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode globalPrivacySettings#fe41b34f: field flags: %w", )
		}
	}
	.ArchiveAndMuteNewNoncontactPeers = .Flags.Has(0)
	.KeepArchivedUnmuted = .Flags.Has(1)
	.KeepArchivedFolders = .Flags.Has(2)
	.HideReadMarks = .Flags.Has(3)
	.NewNoncontactPeersRequirePremium = .Flags.Has(4)
	.DisplayGiftsButton = .Flags.Has(7)
	if .Flags.Has(5) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode globalPrivacySettings#fe41b34f: field noncontact_peers_paid_stars: %w", )
		}
		.NoncontactPeersPaidStars = 
	}
	if .Flags.Has(6) {
		if  := .DisallowedGifts.Decode();  != nil {
			return fmt.Errorf("unable to decode globalPrivacySettings#fe41b34f: field disallowed_gifts: %w", )
		}
	}
	return nil
}

// SetArchiveAndMuteNewNoncontactPeers sets value of ArchiveAndMuteNewNoncontactPeers conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(0)
		.ArchiveAndMuteNewNoncontactPeers = true
	} else {
		.Flags.Unset(0)
		.ArchiveAndMuteNewNoncontactPeers = false
	}
}

// GetArchiveAndMuteNewNoncontactPeers returns value of ArchiveAndMuteNewNoncontactPeers conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetKeepArchivedUnmuted sets value of KeepArchivedUnmuted conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(1)
		.KeepArchivedUnmuted = true
	} else {
		.Flags.Unset(1)
		.KeepArchivedUnmuted = false
	}
}

// GetKeepArchivedUnmuted returns value of KeepArchivedUnmuted conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetKeepArchivedFolders sets value of KeepArchivedFolders conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(2)
		.KeepArchivedFolders = true
	} else {
		.Flags.Unset(2)
		.KeepArchivedFolders = false
	}
}

// GetKeepArchivedFolders returns value of KeepArchivedFolders conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetHideReadMarks sets value of HideReadMarks conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(3)
		.HideReadMarks = true
	} else {
		.Flags.Unset(3)
		.HideReadMarks = false
	}
}

// GetHideReadMarks returns value of HideReadMarks conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetNewNoncontactPeersRequirePremium sets value of NewNoncontactPeersRequirePremium conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(4)
		.NewNoncontactPeersRequirePremium = true
	} else {
		.Flags.Unset(4)
		.NewNoncontactPeersRequirePremium = false
	}
}

// GetNewNoncontactPeersRequirePremium returns value of NewNoncontactPeersRequirePremium conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetDisplayGiftsButton sets value of DisplayGiftsButton conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(7)
		.DisplayGiftsButton = true
	} else {
		.Flags.Unset(7)
		.DisplayGiftsButton = false
	}
}

// GetDisplayGiftsButton returns value of DisplayGiftsButton conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetNoncontactPeersPaidStars sets value of NoncontactPeersPaidStars conditional field.
func ( *GlobalPrivacySettings) ( int64) {
	.Flags.Set(5)
	.NoncontactPeersPaidStars = 
}

// GetNoncontactPeersPaidStars returns value of NoncontactPeersPaidStars conditional field and
// boolean which is true if field was set.
func ( *GlobalPrivacySettings) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .NoncontactPeersPaidStars, true
}

// SetDisallowedGifts sets value of DisallowedGifts conditional field.
func ( *GlobalPrivacySettings) ( DisallowedGiftsSettings) {
	.Flags.Set(6)
	.DisallowedGifts = 
}

// GetDisallowedGifts returns value of DisallowedGifts conditional field and
// boolean which is true if field was set.
func ( *GlobalPrivacySettings) () ( DisallowedGiftsSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .DisallowedGifts, true
}