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

// AccountSaveAutoDownloadSettingsRequest represents TL type `account.saveAutoDownloadSettings#76f36233`.
// Change media autodownload settings
//
// See https://core.telegram.org/method/account.saveAutoDownloadSettings for reference.
type AccountSaveAutoDownloadSettingsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to save media in the low data usage preset
	Low bool
	// Whether to save media in the high data usage preset
	High bool
	// Media autodownload settings
	Settings AutoDownloadSettings
}

// AccountSaveAutoDownloadSettingsRequestTypeID is TL type id of AccountSaveAutoDownloadSettingsRequest.
const AccountSaveAutoDownloadSettingsRequestTypeID = 0x76f36233

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

func ( *AccountSaveAutoDownloadSettingsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Low == false) {
		return false
	}
	if !(.High == false) {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSaveAutoDownloadSettingsRequest from given interface.
func ( *AccountSaveAutoDownloadSettingsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( AutoDownloadSettings)
}) {
	.Low = .()
	.High = .()
	.Settings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSaveAutoDownloadSettingsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.saveAutoDownloadSettings",
		ID:   AccountSaveAutoDownloadSettingsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Low",
			SchemaName: "low",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "High",
			SchemaName: "high",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountSaveAutoDownloadSettingsRequest) () {
	if !(.Low == false) {
		.Flags.Set(0)
	}
	if !(.High == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AccountSaveAutoDownloadSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveAutoDownloadSettings#76f36233 as nil")
	}
	.PutID(AccountSaveAutoDownloadSettingsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSaveAutoDownloadSettingsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.saveAutoDownloadSettings#76f36233 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.saveAutoDownloadSettings#76f36233: field flags: %w", )
		}
	}
	.Low = .Flags.Has(0)
	.High = .Flags.Has(1)
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.saveAutoDownloadSettings#76f36233: field settings: %w", )
		}
	}
	return nil
}

// SetLow sets value of Low conditional field.
func ( *AccountSaveAutoDownloadSettingsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Low = true
	} else {
		.Flags.Unset(0)
		.Low = false
	}
}

// GetLow returns value of Low conditional field.
func ( *AccountSaveAutoDownloadSettingsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetHigh sets value of High conditional field.
func ( *AccountSaveAutoDownloadSettingsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.High = true
	} else {
		.Flags.Unset(1)
		.High = false
	}
}

// GetHigh returns value of High conditional field.
func ( *AccountSaveAutoDownloadSettingsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetSettings returns value of Settings field.
func ( *AccountSaveAutoDownloadSettingsRequest) () ( AutoDownloadSettings) {
	if  == nil {
		return
	}
	return .Settings
}

// AccountSaveAutoDownloadSettings invokes method account.saveAutoDownloadSettings#76f36233 returning error if any.
// Change media autodownload settings
//
// See https://core.telegram.org/method/account.saveAutoDownloadSettings for reference.
func ( *Client) ( context.Context,  *AccountSaveAutoDownloadSettingsRequest) (bool, error) {
	var  BoolBox

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