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

// AccountSetContentSettingsRequest represents TL type `account.setContentSettings#b574b16b`.
// Set sensitive content settings (for viewing or hiding NSFW content)
//
// See https://core.telegram.org/method/account.setContentSettings for reference.
type AccountSetContentSettingsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Enable NSFW content
	SensitiveEnabled bool
}

// AccountSetContentSettingsRequestTypeID is TL type id of AccountSetContentSettingsRequest.
const AccountSetContentSettingsRequestTypeID = 0xb574b16b

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

func ( *AccountSetContentSettingsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.SensitiveEnabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSetContentSettingsRequest from given interface.
func ( *AccountSetContentSettingsRequest) ( interface {
	() ( bool)
}) {
	.SensitiveEnabled = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountSetContentSettingsRequest) () string {
	return "account.setContentSettings"
}

// TypeInfo returns info about TL type.
func ( *AccountSetContentSettingsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.setContentSettings",
		ID:   AccountSetContentSettingsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SensitiveEnabled",
			SchemaName: "sensitive_enabled",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountSetContentSettingsRequest) () {
	if !(.SensitiveEnabled == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountSetContentSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.setContentSettings#b574b16b as nil")
	}
	.PutID(AccountSetContentSettingsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSetContentSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.setContentSettings#b574b16b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.setContentSettings#b574b16b: field flags: %w", )
		}
	}
	.SensitiveEnabled = .Flags.Has(0)
	return nil
}

// SetSensitiveEnabled sets value of SensitiveEnabled conditional field.
func ( *AccountSetContentSettingsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.SensitiveEnabled = true
	} else {
		.Flags.Unset(0)
		.SensitiveEnabled = false
	}
}

// GetSensitiveEnabled returns value of SensitiveEnabled conditional field.
func ( *AccountSetContentSettingsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// AccountSetContentSettings invokes method account.setContentSettings#b574b16b returning error if any.
// Set sensitive content settings (for viewing or hiding NSFW content)
//
// Possible errors:
//
//	403 SENSITIVE_CHANGE_FORBIDDEN: You can't change your sensitive content settings.
//
// See https://core.telegram.org/method/account.setContentSettings for reference.
func ( *Client) ( context.Context,  *AccountSetContentSettingsRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}