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

// AccountSaveThemeRequest represents TL type `account.saveTheme#f257106c`.
// Save a theme
//
// See https://core.telegram.org/method/account.saveTheme for reference.
type AccountSaveThemeRequest struct {
	// Theme to save
	Theme InputThemeClass
	// Unsave
	Unsave bool
}

// AccountSaveThemeRequestTypeID is TL type id of AccountSaveThemeRequest.
const AccountSaveThemeRequestTypeID = 0xf257106c

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

func ( *AccountSaveThemeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Theme == nil) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSaveThemeRequest from given interface.
func ( *AccountSaveThemeRequest) ( interface {
	() ( InputThemeClass)
	() ( bool)
}) {
	.Theme = .()
	.Unsave = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSaveThemeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.saveTheme",
		ID:   AccountSaveThemeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Theme",
			SchemaName: "theme",
		},
		{
			Name:       "Unsave",
			SchemaName: "unsave",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSaveThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveTheme#f257106c as nil")
	}
	.PutID(AccountSaveThemeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSaveThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveTheme#f257106c as nil")
	}
	if .Theme == nil {
		return fmt.Errorf("unable to encode account.saveTheme#f257106c: field theme is nil")
	}
	if  := .Theme.Encode();  != nil {
		return fmt.Errorf("unable to encode account.saveTheme#f257106c: field theme: %w", )
	}
	.PutBool(.Unsave)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSaveThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.saveTheme#f257106c to nil")
	}
	{
		,  := DecodeInputTheme()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveTheme#f257106c: field theme: %w", )
		}
		.Theme = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveTheme#f257106c: field unsave: %w", )
		}
		.Unsave = 
	}
	return nil
}

// GetTheme returns value of Theme field.
func ( *AccountSaveThemeRequest) () ( InputThemeClass) {
	if  == nil {
		return
	}
	return .Theme
}

// GetUnsave returns value of Unsave field.
func ( *AccountSaveThemeRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Unsave
}

// AccountSaveTheme invokes method account.saveTheme#f257106c returning error if any.
// Save a theme
//
// See https://core.telegram.org/method/account.saveTheme for reference.
func ( *Client) ( context.Context,  *AccountSaveThemeRequest) (bool, error) {
	var  BoolBox

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