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

// AccountInstallThemeRequest represents TL type `account.installTheme#c727bb3b`.
// Install a theme
//
// See https://core.telegram.org/method/account.installTheme for reference.
type AccountInstallThemeRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to install the dark version
	Dark bool
	// Theme to install
	//
	// Use SetTheme and GetTheme helpers.
	Theme InputThemeClass
	// Theme format, a string that identifies the theming engines supported by the client
	//
	// Use SetFormat and GetFormat helpers.
	Format string
	// Indicates a basic theme provided by all clients
	//
	// Use SetBaseTheme and GetBaseTheme helpers.
	BaseTheme BaseThemeClass
}

// AccountInstallThemeRequestTypeID is TL type id of AccountInstallThemeRequest.
const AccountInstallThemeRequestTypeID = 0xc727bb3b

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

func ( *AccountInstallThemeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Dark == false) {
		return false
	}
	if !(.Theme == nil) {
		return false
	}
	if !(.Format == "") {
		return false
	}
	if !(.BaseTheme == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountInstallThemeRequest from given interface.
func ( *AccountInstallThemeRequest) ( interface {
	() ( bool)
	() ( InputThemeClass,  bool)
	() ( string,  bool)
	() ( BaseThemeClass,  bool)
}) {
	.Dark = .()
	if ,  := .();  {
		.Theme = 
	}

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountInstallThemeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.installTheme",
		ID:   AccountInstallThemeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Dark",
			SchemaName: "dark",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Theme",
			SchemaName: "theme",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Format",
			SchemaName: "format",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "BaseTheme",
			SchemaName: "base_theme",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountInstallThemeRequest) () {
	if !(.Dark == false) {
		.Flags.Set(0)
	}
	if !(.Theme == nil) {
		.Flags.Set(1)
	}
	if !(.Format == "") {
		.Flags.Set(2)
	}
	if !(.BaseTheme == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *AccountInstallThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.installTheme#c727bb3b as nil")
	}
	.PutID(AccountInstallThemeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountInstallThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.installTheme#c727bb3b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field flags: %w", )
	}
	if .Flags.Has(1) {
		if .Theme == nil {
			return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field theme is nil")
		}
		if  := .Theme.Encode();  != nil {
			return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field theme: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutString(.Format)
	}
	if .Flags.Has(3) {
		if .BaseTheme == nil {
			return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field base_theme is nil")
		}
		if  := .BaseTheme.Encode();  != nil {
			return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field base_theme: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountInstallThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.installTheme#c727bb3b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field flags: %w", )
		}
	}
	.Dark = .Flags.Has(0)
	if .Flags.Has(1) {
		,  := DecodeInputTheme()
		if  != nil {
			return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field theme: %w", )
		}
		.Theme = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field format: %w", )
		}
		.Format = 
	}
	if .Flags.Has(3) {
		,  := DecodeBaseTheme()
		if  != nil {
			return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field base_theme: %w", )
		}
		.BaseTheme = 
	}
	return nil
}

// SetDark sets value of Dark conditional field.
func ( *AccountInstallThemeRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Dark = true
	} else {
		.Flags.Unset(0)
		.Dark = false
	}
}

// GetDark returns value of Dark conditional field.
func ( *AccountInstallThemeRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetTheme sets value of Theme conditional field.
func ( *AccountInstallThemeRequest) ( InputThemeClass) {
	.Flags.Set(1)
	.Theme = 
}

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

// SetFormat sets value of Format conditional field.
func ( *AccountInstallThemeRequest) ( string) {
	.Flags.Set(2)
	.Format = 
}

// GetFormat returns value of Format conditional field and
// boolean which is true if field was set.
func ( *AccountInstallThemeRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Format, true
}

// SetBaseTheme sets value of BaseTheme conditional field.
func ( *AccountInstallThemeRequest) ( BaseThemeClass) {
	.Flags.Set(3)
	.BaseTheme = 
}

// GetBaseTheme returns value of BaseTheme conditional field and
// boolean which is true if field was set.
func ( *AccountInstallThemeRequest) () ( BaseThemeClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .BaseTheme, true
}

// AccountInstallTheme invokes method account.installTheme#c727bb3b returning error if any.
// Install a theme
//
// See https://core.telegram.org/method/account.installTheme for reference.
func ( *Client) ( context.Context,  *AccountInstallThemeRequest) (bool, error) {
	var  BoolBox

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