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

// ReactionsNotifySettings represents TL type `reactionsNotifySettings#71e4ea58`.
// Reaction notification settings, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/reactions#notifications-about-reactions
//
// See https://core.telegram.org/constructor/reactionsNotifySettings for reference.
type ReactionsNotifySettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Message reaction notification settings, if not set completely disables
	// notifications/updates about message reactions.
	//
	// Use SetMessagesNotifyFrom and GetMessagesNotifyFrom helpers.
	MessagesNotifyFrom ReactionNotificationsFromClass
	// Story reaction notification settings, if not set completely disables
	// notifications/updates about reactions to stories.
	//
	// Use SetStoriesNotifyFrom and GetStoriesNotifyFrom helpers.
	StoriesNotifyFrom ReactionNotificationsFromClass
	// PollVotesNotifyFrom field of ReactionsNotifySettings.
	//
	// Use SetPollVotesNotifyFrom and GetPollVotesNotifyFrom helpers.
	PollVotesNotifyFrom ReactionNotificationsFromClass
	// Notification sound for reactions »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/ringtones
	Sound NotificationSoundClass
	// If false, push notifications »¹ about message/story reactions will only be of type
	// REACT_HIDDEN/REACT_STORY_HIDDEN, without any information about the reacted-to story or
	// the reaction itself.
	//
	// Links:
	//  1) https://core.telegram.org/api/push-updates
	ShowPreviews bool
}

// ReactionsNotifySettingsTypeID is TL type id of ReactionsNotifySettings.
const ReactionsNotifySettingsTypeID = 0x71e4ea58

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

func ( *ReactionsNotifySettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MessagesNotifyFrom == nil) {
		return false
	}
	if !(.StoriesNotifyFrom == nil) {
		return false
	}
	if !(.PollVotesNotifyFrom == nil) {
		return false
	}
	if !(.Sound == nil) {
		return false
	}
	if !(.ShowPreviews == false) {
		return false
	}

	return true
}

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

// FillFrom fills ReactionsNotifySettings from given interface.
func ( *ReactionsNotifySettings) ( interface {
	() ( ReactionNotificationsFromClass,  bool)
	() ( ReactionNotificationsFromClass,  bool)
	() ( ReactionNotificationsFromClass,  bool)
	() ( NotificationSoundClass)
	() ( bool)
}) {
	if ,  := .();  {
		.MessagesNotifyFrom = 
	}

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

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

	.Sound = .()
	.ShowPreviews = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ReactionsNotifySettings) () tdp.Type {
	 := tdp.Type{
		Name: "reactionsNotifySettings",
		ID:   ReactionsNotifySettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MessagesNotifyFrom",
			SchemaName: "messages_notify_from",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "StoriesNotifyFrom",
			SchemaName: "stories_notify_from",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PollVotesNotifyFrom",
			SchemaName: "poll_votes_notify_from",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Sound",
			SchemaName: "sound",
		},
		{
			Name:       "ShowPreviews",
			SchemaName: "show_previews",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ReactionsNotifySettings) () {
	if !(.MessagesNotifyFrom == nil) {
		.Flags.Set(0)
	}
	if !(.StoriesNotifyFrom == nil) {
		.Flags.Set(1)
	}
	if !(.PollVotesNotifyFrom == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *ReactionsNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionsNotifySettings#71e4ea58 as nil")
	}
	.PutID(ReactionsNotifySettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReactionsNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionsNotifySettings#71e4ea58 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .MessagesNotifyFrom == nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field messages_notify_from is nil")
		}
		if  := .MessagesNotifyFrom.Encode();  != nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field messages_notify_from: %w", )
		}
	}
	if .Flags.Has(1) {
		if .StoriesNotifyFrom == nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field stories_notify_from is nil")
		}
		if  := .StoriesNotifyFrom.Encode();  != nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field stories_notify_from: %w", )
		}
	}
	if .Flags.Has(2) {
		if .PollVotesNotifyFrom == nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from is nil")
		}
		if  := .PollVotesNotifyFrom.Encode();  != nil {
			return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from: %w", )
		}
	}
	if .Sound == nil {
		return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field sound is nil")
	}
	if  := .Sound.Encode();  != nil {
		return fmt.Errorf("unable to encode reactionsNotifySettings#71e4ea58: field sound: %w", )
	}
	.PutBool(.ShowPreviews)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ReactionsNotifySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionsNotifySettings#71e4ea58 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeReactionNotificationsFrom()
		if  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field messages_notify_from: %w", )
		}
		.MessagesNotifyFrom = 
	}
	if .Flags.Has(1) {
		,  := DecodeReactionNotificationsFrom()
		if  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field stories_notify_from: %w", )
		}
		.StoriesNotifyFrom = 
	}
	if .Flags.Has(2) {
		,  := DecodeReactionNotificationsFrom()
		if  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field poll_votes_notify_from: %w", )
		}
		.PollVotesNotifyFrom = 
	}
	{
		,  := DecodeNotificationSound()
		if  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field sound: %w", )
		}
		.Sound = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode reactionsNotifySettings#71e4ea58: field show_previews: %w", )
		}
		.ShowPreviews = 
	}
	return nil
}

// SetMessagesNotifyFrom sets value of MessagesNotifyFrom conditional field.
func ( *ReactionsNotifySettings) ( ReactionNotificationsFromClass) {
	.Flags.Set(0)
	.MessagesNotifyFrom = 
}

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

// SetStoriesNotifyFrom sets value of StoriesNotifyFrom conditional field.
func ( *ReactionsNotifySettings) ( ReactionNotificationsFromClass) {
	.Flags.Set(1)
	.StoriesNotifyFrom = 
}

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

// SetPollVotesNotifyFrom sets value of PollVotesNotifyFrom conditional field.
func ( *ReactionsNotifySettings) ( ReactionNotificationsFromClass) {
	.Flags.Set(2)
	.PollVotesNotifyFrom = 
}

// GetPollVotesNotifyFrom returns value of PollVotesNotifyFrom conditional field and
// boolean which is true if field was set.
func ( *ReactionsNotifySettings) () ( ReactionNotificationsFromClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .PollVotesNotifyFrom, true
}

// GetSound returns value of Sound field.
func ( *ReactionsNotifySettings) () ( NotificationSoundClass) {
	if  == nil {
		return
	}
	return .Sound
}

// GetShowPreviews returns value of ShowPreviews field.
func ( *ReactionsNotifySettings) () ( bool) {
	if  == nil {
		return
	}
	return .ShowPreviews
}