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

// AccountSetAuthorizationTTLRequest represents TL type `account.setAuthorizationTTL#bf899aa0`.
// Set time-to-live of current session
//
// See https://core.telegram.org/method/account.setAuthorizationTTL for reference.
type AccountSetAuthorizationTTLRequest struct {
	// Time-to-live of current session in days
	AuthorizationTTLDays int
}

// AccountSetAuthorizationTTLRequestTypeID is TL type id of AccountSetAuthorizationTTLRequest.
const AccountSetAuthorizationTTLRequestTypeID = 0xbf899aa0

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

func ( *AccountSetAuthorizationTTLRequest) () bool {
	if  == nil {
		return true
	}
	if !(.AuthorizationTTLDays == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSetAuthorizationTTLRequest from given interface.
func ( *AccountSetAuthorizationTTLRequest) ( interface {
	() ( int)
}) {
	.AuthorizationTTLDays = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSetAuthorizationTTLRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.setAuthorizationTTL",
		ID:   AccountSetAuthorizationTTLRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AuthorizationTTLDays",
			SchemaName: "authorization_ttl_days",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSetAuthorizationTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.setAuthorizationTTL#bf899aa0 as nil")
	}
	.PutID(AccountSetAuthorizationTTLRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSetAuthorizationTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.setAuthorizationTTL#bf899aa0 as nil")
	}
	.PutInt(.AuthorizationTTLDays)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSetAuthorizationTTLRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.setAuthorizationTTL#bf899aa0 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.setAuthorizationTTL#bf899aa0: field authorization_ttl_days: %w", )
		}
		.AuthorizationTTLDays = 
	}
	return nil
}

// GetAuthorizationTTLDays returns value of AuthorizationTTLDays field.
func ( *AccountSetAuthorizationTTLRequest) () ( int) {
	if  == nil {
		return
	}
	return .AuthorizationTTLDays
}

// AccountSetAuthorizationTTL invokes method account.setAuthorizationTTL#bf899aa0 returning error if any.
// Set time-to-live of current session
//
// Possible errors:
//
//	406 FRESH_RESET_AUTHORISATION_FORBIDDEN: You can't logout other sessions if less than 24 hours have passed since you logged on the current session.
//	400 TTL_DAYS_INVALID: The provided TTL is invalid.
//
// See https://core.telegram.org/method/account.setAuthorizationTTL for reference.
func ( *Client) ( context.Context,  int) (bool, error) {
	var  BoolBox

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