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

// AccountSetAccountTTLRequest represents TL type `account.setAccountTTL#2442485e`.
// Set account self-destruction period
//
// See https://core.telegram.org/method/account.setAccountTTL for reference.
type AccountSetAccountTTLRequest struct {
	// Time to live in days
	TTL AccountDaysTTL
}

// AccountSetAccountTTLRequestTypeID is TL type id of AccountSetAccountTTLRequest.
const AccountSetAccountTTLRequestTypeID = 0x2442485e

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

func ( *AccountSetAccountTTLRequest) () bool {
	if  == nil {
		return true
	}
	if !(.TTL.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSetAccountTTLRequest from given interface.
func ( *AccountSetAccountTTLRequest) ( interface {
	() ( AccountDaysTTL)
}) {
	.TTL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSetAccountTTLRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.setAccountTTL",
		ID:   AccountSetAccountTTLRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "TTL",
			SchemaName: "ttl",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSetAccountTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.setAccountTTL#2442485e as nil")
	}
	.PutID(AccountSetAccountTTLRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSetAccountTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.setAccountTTL#2442485e as nil")
	}
	if  := .TTL.Encode();  != nil {
		return fmt.Errorf("unable to encode account.setAccountTTL#2442485e: field ttl: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSetAccountTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.setAccountTTL#2442485e to nil")
	}
	{
		if  := .TTL.Decode();  != nil {
			return fmt.Errorf("unable to decode account.setAccountTTL#2442485e: field ttl: %w", )
		}
	}
	return nil
}

// GetTTL returns value of TTL field.
func ( *AccountSetAccountTTLRequest) () ( AccountDaysTTL) {
	if  == nil {
		return
	}
	return .TTL
}

// AccountSetAccountTTL invokes method account.setAccountTTL#2442485e returning error if any.
// Set account self-destruction period
//
// Possible errors:
//
//	400 TTL_DAYS_INVALID: The provided TTL is invalid.
//
// See https://core.telegram.org/method/account.setAccountTTL for reference.
func ( *Client) ( context.Context,  AccountDaysTTL) (bool, error) {
	var  BoolBox

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