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

// InputPeerNotifySettings represents TL type `inputPeerNotifySettings#cacb6ae2`.
// Notification settings.
//
// See https://core.telegram.org/constructor/inputPeerNotifySettings for reference.
type InputPeerNotifySettings struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If the text of the message shall be displayed in notification
	//
	// Use SetShowPreviews and GetShowPreviews helpers.
	ShowPreviews bool
	// Peer was muted?
	//
	// Use SetSilent and GetSilent helpers.
	Silent bool
	// Date until which all notifications shall be switched off
	//
	// Use SetMuteUntil and GetMuteUntil helpers.
	MuteUntil int
	// Identifier of an audio file to play for notifications.
	//
	// Use SetSound and GetSound helpers.
	Sound 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
	// Identifier of an audio file to play for story notifications.
	//
	// Use SetStoriesSound and GetStoriesSound helpers.
	StoriesSound NotificationSoundClass
}

// InputPeerNotifySettingsTypeID is TL type id of InputPeerNotifySettings.
const InputPeerNotifySettingsTypeID = 0xcacb6ae2

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

func ( *InputPeerNotifySettings) () 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 !(.Sound == nil) {
		return false
	}
	if !(.StoriesMuted == false) {
		return false
	}
	if !(.StoriesHideSender == false) {
		return false
	}
	if !(.StoriesSound == nil) {
		return false
	}

	return true
}

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *InputPeerNotifySettings) () tdp.Type {
	 := tdp.Type{
		Name: "inputPeerNotifySettings",
		ID:   InputPeerNotifySettingsTypeID,
	}
	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:       "Sound",
			SchemaName: "sound",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "StoriesMuted",
			SchemaName: "stories_muted",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "StoriesHideSender",
			SchemaName: "stories_hide_sender",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "StoriesSound",
			SchemaName: "stories_sound",
			Null:       !.Flags.Has(8),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputPeerNotifySettings) () {
	if !(.ShowPreviews == false) {
		.Flags.Set(0)
	}
	if !(.Silent == false) {
		.Flags.Set(1)
	}
	if !(.MuteUntil == 0) {
		.Flags.Set(2)
	}
	if !(.Sound == nil) {
		.Flags.Set(3)
	}
	if !(.StoriesMuted == false) {
		.Flags.Set(6)
	}
	if !(.StoriesHideSender == false) {
		.Flags.Set(7)
	}
	if !(.StoriesSound == nil) {
		.Flags.Set(8)
	}
}

// Encode implements bin.Encoder.
func ( *InputPeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerNotifySettings#cacb6ae2 as nil")
	}
	.PutID(InputPeerNotifySettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPeerNotifySettings#cacb6ae2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: 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 .Sound == nil {
			return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field sound is nil")
		}
		if  := .Sound.Encode();  != nil {
			return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field sound: %w", )
		}
	}
	if .Flags.Has(6) {
		.PutBool(.StoriesMuted)
	}
	if .Flags.Has(7) {
		.PutBool(.StoriesHideSender)
	}
	if .Flags.Has(8) {
		if .StoriesSound == nil {
			return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field stories_sound is nil")
		}
		if  := .StoriesSound.Encode();  != nil {
			return fmt.Errorf("unable to encode inputPeerNotifySettings#cacb6ae2: field stories_sound: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputPeerNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPeerNotifySettings#cacb6ae2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field show_previews: %w", )
		}
		.ShowPreviews = 
	}
	if .Flags.Has(1) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field silent: %w", )
		}
		.Silent = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field mute_until: %w", )
		}
		.MuteUntil = 
	}
	if .Flags.Has(3) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field sound: %w", )
		}
		.Sound = 
	}
	if .Flags.Has(6) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_muted: %w", )
		}
		.StoriesMuted = 
	}
	if .Flags.Has(7) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_hide_sender: %w", )
		}
		.StoriesHideSender = 
	}
	if .Flags.Has(8) {
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode inputPeerNotifySettings#cacb6ae2: field stories_sound: %w", )
		}
		.StoriesSound = 
	}
	return nil
}

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

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

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

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

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

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

// SetSound sets value of Sound conditional field.
func ( *InputPeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(3)
	.Sound = 
}

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

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

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

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

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

// SetStoriesSound sets value of StoriesSound conditional field.
func ( *InputPeerNotifySettings) ( NotificationSoundClass) {
	.Flags.Set(8)
	.StoriesSound = 
}

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