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

// PeerNotifySettings represents TL type `peerNotifySettings#99622c0c`.
// Notification settings.
//
// See https://core.telegram.org/constructor/peerNotifySettings for reference.
type PeerNotifySettings struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// (Ternary value) If set, indicates whether or not to display previews of messages in
	// notifications; otherwise the default behavior should be used.
	//
	// Use SetShowPreviews and GetShowPreviews helpers.
	ShowPreviews bool
	// (Ternary value) If set, indicates whether to mute or unmute the peer; otherwise the
	// default behavior should be used.
	//
	// Use SetSilent and GetSilent helpers.
	Silent bool
	// Mute all notifications until this date
	//
	// Use SetMuteUntil and GetMuteUntil helpers.
	MuteUntil int
	// Notification sound for the official iOS application
	//
	// Use SetIosSound and GetIosSound helpers.
	IosSound NotificationSoundClass
	// Notification sound for the official android application
	//
	// Use SetAndroidSound and GetAndroidSound helpers.
	AndroidSound NotificationSoundClass
	// Notification sound for other applications
	//
	// Use SetOtherSound and GetOtherSound helpers.
	OtherSound NotificationSoundClass
	// Whether story notifications should be disabled.
	//
	// Use SetStoriesMuted and GetStoriesMuted helpers.
	StoriesMuted bool
	// Whether the sender name should be displayed in story notifications.
	//
	// Use SetStoriesHideSender and GetStoriesHideSender helpers.
	StoriesHideSender bool
	// Sound for story notifications on the official iOS application
	//
	// Use SetStoriesIosSound and GetStoriesIosSound helpers.
	StoriesIosSound NotificationSoundClass
	// Sound for story notifications on the official Android application
	//
	// Use SetStoriesAndroidSound and GetStoriesAndroidSound helpers.
	StoriesAndroidSound NotificationSoundClass
	// Sound for story notifications on other applications
	//
	// Use SetStoriesOtherSound and GetStoriesOtherSound helpers.
	StoriesOtherSound NotificationSoundClass
}

// PeerNotifySettingsTypeID is TL type id of PeerNotifySettings.
const PeerNotifySettingsTypeID = 0x99622c0c

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

func ( *PeerNotifySettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ShowPreviews == false) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.MuteUntil == 0) {
		return false
	}
	if !(.IosSound == nil) {
		return false
	}
	if !(.AndroidSound == nil) {
		return false
	}
	if !(.OtherSound == nil) {
		return false
	}
	if !(.StoriesMuted == false) {
		return false
	}
	if !(.StoriesHideSender == false) {
		return false
	}
	if !(.StoriesIosSound == nil) {
		return false
	}
	if !(.StoriesAndroidSound == nil) {
		return false
	}
	if !(.StoriesOtherSound == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PeerNotifySettings from given interface.
func ( *PeerNotifySettings) ( interface {
	() ( bool,  bool)
	() ( bool,  bool)
	() ( int,  bool)
	() ( NotificationSoundClass,  bool)
	() ( NotificationSoundClass,  bool)
	() ( NotificationSoundClass,  bool)
	() ( bool,  bool)
	() ( bool,  bool)
	() ( NotificationSoundClass,  bool)
	() ( NotificationSoundClass,  bool)
	() ( NotificationSoundClass,  bool)
}) {
	if ,  := .();  {
		.ShowPreviews = 
	}

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

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

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *PeerNotifySettings) () tdp.Type {
	 := tdp.Type{
		Name: "peerNotifySettings",
		ID:   PeerNotifySettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ShowPreviews",
			SchemaName: "show_previews",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "MuteUntil",
			SchemaName: "mute_until",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "IosSound",
			SchemaName: "ios_sound",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "AndroidSound",
			SchemaName: "android_sound",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "OtherSound",
			SchemaName: "other_sound",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "StoriesMuted",
			SchemaName: "stories_muted",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "StoriesHideSender",
			SchemaName: "stories_hide_sender",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "StoriesIosSound",
			SchemaName: "stories_ios_sound",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "StoriesAndroidSound",
			SchemaName: "stories_android_sound",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "StoriesOtherSound",
			SchemaName: "stories_other_sound",
			Null:       !.Flags.Has(10),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PeerNotifySettings) () {
	if !(.ShowPreviews == false) {
		.Flags.Set(0)
	}
	if !(.Silent == false) {
		.Flags.Set(1)
	}
	if !(.MuteUntil == 0) {
		.Flags.Set(2)
	}
	if !(.IosSound == nil) {
		.Flags.Set(3)
	}
	if !(.AndroidSound == nil) {
		.Flags.Set(4)
	}
	if !(.OtherSound == nil) {
		.Flags.Set(5)
	}
	if !(.StoriesMuted == false) {
		.Flags.Set(6)
	}
	if !(.StoriesHideSender == false) {
		.Flags.Set(7)
	}
	if !(.StoriesIosSound == nil) {
		.Flags.Set(8)
	}
	if !(.StoriesAndroidSound == nil) {
		.Flags.Set(9)
	}
	if !(.StoriesOtherSound == nil) {
		.Flags.Set(10)
	}
}

// Encode implements bin.Encoder.
func ( *PeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode peerNotifySettings#99622c0c as nil")
	}
	.PutID(PeerNotifySettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode peerNotifySettings#99622c0c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutBool(.ShowPreviews)
	}
	if .Flags.Has(1) {
		.PutBool(.Silent)
	}
	if .Flags.Has(2) {
		.PutInt(.MuteUntil)
	}
	if .Flags.Has(3) {
		if .IosSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field ios_sound is nil")
		}
		if  := .IosSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field ios_sound: %w", )
		}
	}
	if .Flags.Has(4) {
		if .AndroidSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field android_sound is nil")
		}
		if  := .AndroidSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field android_sound: %w", )
		}
	}
	if .Flags.Has(5) {
		if .OtherSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field other_sound is nil")
		}
		if  := .OtherSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field other_sound: %w", )
		}
	}
	if .Flags.Has(6) {
		.PutBool(.StoriesMuted)
	}
	if .Flags.Has(7) {
		.PutBool(.StoriesHideSender)
	}
	if .Flags.Has(8) {
		if .StoriesIosSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_ios_sound is nil")
		}
		if  := .StoriesIosSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_ios_sound: %w", )
		}
	}
	if .Flags.Has(9) {
		if .StoriesAndroidSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_android_sound is nil")
		}
		if  := .StoriesAndroidSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_android_sound: %w", )
		}
	}
	if .Flags.Has(10) {
		if .StoriesOtherSound == nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_other_sound is nil")
		}
		if  := .StoriesOtherSound.Encode();  != nil {
			return fmt.Errorf("unable to encode peerNotifySettings#99622c0c: field stories_other_sound: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode peerNotifySettings#99622c0c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field show_previews: %w", )
		}
		.ShowPreviews = 
	}
	if .Flags.Has(1) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field silent: %w", )
		}
		.Silent = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field mute_until: %w", )
		}
		.MuteUntil = 
	}
	if .Flags.Has(3) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field ios_sound: %w", )
		}
		.IosSound = 
	}
	if .Flags.Has(4) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field android_sound: %w", )
		}
		.AndroidSound = 
	}
	if .Flags.Has(5) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field other_sound: %w", )
		}
		.OtherSound = 
	}
	if .Flags.Has(6) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field stories_muted: %w", )
		}
		.StoriesMuted = 
	}
	if .Flags.Has(7) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field stories_hide_sender: %w", )
		}
		.StoriesHideSender = 
	}
	if .Flags.Has(8) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field stories_ios_sound: %w", )
		}
		.StoriesIosSound = 
	}
	if .Flags.Has(9) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field stories_android_sound: %w", )
		}
		.StoriesAndroidSound = 
	}
	if .Flags.Has(10) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode peerNotifySettings#99622c0c: field stories_other_sound: %w", )
		}
		.StoriesOtherSound = 
	}
	return nil
}

// SetShowPreviews sets value of ShowPreviews conditional field.
func ( *PeerNotifySettings) ( bool) {
	.Flags.Set(0)
	.ShowPreviews = 
}

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

// SetSilent sets value of Silent conditional field.
func ( *PeerNotifySettings) ( bool) {
	.Flags.Set(1)
	.Silent = 
}

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

// SetMuteUntil sets value of MuteUntil conditional field.
func ( *PeerNotifySettings) ( int) {
	.Flags.Set(2)
	.MuteUntil = 
}

// GetMuteUntil returns value of MuteUntil conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .MuteUntil, true
}

// SetIosSound sets value of IosSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(3)
	.IosSound = 
}

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

// SetAndroidSound sets value of AndroidSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(4)
	.AndroidSound = 
}

// GetAndroidSound returns value of AndroidSound conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( NotificationSoundClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .AndroidSound, true
}

// SetOtherSound sets value of OtherSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(5)
	.OtherSound = 
}

// GetOtherSound returns value of OtherSound conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( NotificationSoundClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .OtherSound, true
}

// SetStoriesMuted sets value of StoriesMuted conditional field.
func ( *PeerNotifySettings) ( bool) {
	.Flags.Set(6)
	.StoriesMuted = 
}

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

// SetStoriesHideSender sets value of StoriesHideSender conditional field.
func ( *PeerNotifySettings) ( bool) {
	.Flags.Set(7)
	.StoriesHideSender = 
}

// GetStoriesHideSender returns value of StoriesHideSender conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .StoriesHideSender, true
}

// SetStoriesIosSound sets value of StoriesIosSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(8)
	.StoriesIosSound = 
}

// GetStoriesIosSound returns value of StoriesIosSound conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( NotificationSoundClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .StoriesIosSound, true
}

// SetStoriesAndroidSound sets value of StoriesAndroidSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(9)
	.StoriesAndroidSound = 
}

// GetStoriesAndroidSound returns value of StoriesAndroidSound conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( NotificationSoundClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .StoriesAndroidSound, true
}

// SetStoriesOtherSound sets value of StoriesOtherSound conditional field.
func ( *PeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(10)
	.StoriesOtherSound = 
}

// GetStoriesOtherSound returns value of StoriesOtherSound conditional field and
// boolean which is true if field was set.
func ( *PeerNotifySettings) () ( NotificationSoundClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .StoriesOtherSound, true
}