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

// AccountSaveWallPaperRequest represents TL type `account.saveWallPaper#6c5a5b37`.
// Install/uninstall wallpaper¹
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/method/account.saveWallPaper for reference.
type AccountSaveWallPaperRequest struct {
	// Wallpaper¹ to install or uninstall
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	Wallpaper InputWallPaperClass
	// Uninstall wallpaper?
	Unsave bool
	// Wallpaper settings
	Settings WallPaperSettings
}

// AccountSaveWallPaperRequestTypeID is TL type id of AccountSaveWallPaperRequest.
const AccountSaveWallPaperRequestTypeID = 0x6c5a5b37

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

func ( *AccountSaveWallPaperRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Wallpaper == nil) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSaveWallPaperRequest from given interface.
func ( *AccountSaveWallPaperRequest) ( interface {
	() ( InputWallPaperClass)
	() ( bool)
	() ( WallPaperSettings)
}) {
	.Wallpaper = .()
	.Unsave = .()
	.Settings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSaveWallPaperRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.saveWallPaper",
		ID:   AccountSaveWallPaperRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Wallpaper",
			SchemaName: "wallpaper",
		},
		{
			Name:       "Unsave",
			SchemaName: "unsave",
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSaveWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveWallPaper#6c5a5b37 as nil")
	}
	.PutID(AccountSaveWallPaperRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSaveWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveWallPaper#6c5a5b37 as nil")
	}
	if .Wallpaper == nil {
		return fmt.Errorf("unable to encode account.saveWallPaper#6c5a5b37: field wallpaper is nil")
	}
	if  := .Wallpaper.Encode();  != nil {
		return fmt.Errorf("unable to encode account.saveWallPaper#6c5a5b37: field wallpaper: %w", )
	}
	.PutBool(.Unsave)
	if  := .Settings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.saveWallPaper#6c5a5b37: field settings: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSaveWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.saveWallPaper#6c5a5b37 to nil")
	}
	{
		,  := DecodeInputWallPaper()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveWallPaper#6c5a5b37: field wallpaper: %w", )
		}
		.Wallpaper = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveWallPaper#6c5a5b37: field unsave: %w", )
		}
		.Unsave = 
	}
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.saveWallPaper#6c5a5b37: field settings: %w", )
		}
	}
	return nil
}

// GetWallpaper returns value of Wallpaper field.
func ( *AccountSaveWallPaperRequest) () ( InputWallPaperClass) {
	if  == nil {
		return
	}
	return .Wallpaper
}

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

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

// AccountSaveWallPaper invokes method account.saveWallPaper#6c5a5b37 returning error if any.
// Install/uninstall wallpaper¹
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// Possible errors:
//
//	400 WALLPAPER_INVALID: The specified wallpaper is invalid.
//
// See https://core.telegram.org/method/account.saveWallPaper for reference.
func ( *Client) ( context.Context,  *AccountSaveWallPaperRequest) (bool, error) {
	var  BoolBox

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