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

// AccountRegisterDeviceRequest represents TL type `account.registerDevice#ec86017a`.
// Register device to receive PUSH notifications¹
//
// Links:
//  1. https://core.telegram.org/api/push-updates
//
// See https://core.telegram.org/method/account.registerDevice for reference.
type AccountRegisterDeviceRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Avoid receiving (silent and invisible background) notifications. Useful to save
	// battery.
	NoMuted bool
	// Device token type, see PUSH updates¹ for the possible values.
	//
	// Links:
	//  1) https://core.telegram.org/api/push-updates#subscribing-to-notifications
	TokenType int
	// Device token, see PUSH updates¹ for the possible values.
	//
	// Links:
	//  1) https://core.telegram.org/api/push-updates#subscribing-to-notifications
	Token string
	// If (boolTrue)¹ is transmitted, a sandbox-certificate will be used during transmission.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/boolTrue
	AppSandbox bool
	// For FCM and APNS VoIP, optional encryption key used to encrypt push notifications
	Secret []byte
	// List of user identifiers of other users currently using the client
	OtherUIDs []int64
}

// AccountRegisterDeviceRequestTypeID is TL type id of AccountRegisterDeviceRequest.
const AccountRegisterDeviceRequestTypeID = 0xec86017a

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

func ( *AccountRegisterDeviceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.NoMuted == false) {
		return false
	}
	if !(.TokenType == 0) {
		return false
	}
	if !(.Token == "") {
		return false
	}
	if !(.AppSandbox == false) {
		return false
	}
	if !(.Secret == nil) {
		return false
	}
	if !(.OtherUIDs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountRegisterDeviceRequest from given interface.
func ( *AccountRegisterDeviceRequest) ( interface {
	() ( bool)
	() ( int)
	() ( string)
	() ( bool)
	() ( []byte)
	() ( []int64)
}) {
	.NoMuted = .()
	.TokenType = .()
	.Token = .()
	.AppSandbox = .()
	.Secret = .()
	.OtherUIDs = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountRegisterDeviceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.registerDevice",
		ID:   AccountRegisterDeviceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NoMuted",
			SchemaName: "no_muted",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "TokenType",
			SchemaName: "token_type",
		},
		{
			Name:       "Token",
			SchemaName: "token",
		},
		{
			Name:       "AppSandbox",
			SchemaName: "app_sandbox",
		},
		{
			Name:       "Secret",
			SchemaName: "secret",
		},
		{
			Name:       "OtherUIDs",
			SchemaName: "other_uids",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountRegisterDeviceRequest) () {
	if !(.NoMuted == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountRegisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.registerDevice#ec86017a as nil")
	}
	.PutID(AccountRegisterDeviceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountRegisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.registerDevice#ec86017a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.registerDevice#ec86017a: field flags: %w", )
	}
	.PutInt(.TokenType)
	.PutString(.Token)
	.PutBool(.AppSandbox)
	.PutBytes(.Secret)
	.PutVectorHeader(len(.OtherUIDs))
	for ,  := range .OtherUIDs {
		.PutLong()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountRegisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.registerDevice#ec86017a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field flags: %w", )
		}
	}
	.NoMuted = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field token_type: %w", )
		}
		.TokenType = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field token: %w", )
		}
		.Token = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field app_sandbox: %w", )
		}
		.AppSandbox = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field secret: %w", )
		}
		.Secret = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field other_uids: %w", )
		}

		if  > 0 {
			.OtherUIDs = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode account.registerDevice#ec86017a: field other_uids: %w", )
			}
			.OtherUIDs = append(.OtherUIDs, )
		}
	}
	return nil
}

// SetNoMuted sets value of NoMuted conditional field.
func ( *AccountRegisterDeviceRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.NoMuted = true
	} else {
		.Flags.Unset(0)
		.NoMuted = false
	}
}

// GetNoMuted returns value of NoMuted conditional field.
func ( *AccountRegisterDeviceRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetTokenType returns value of TokenType field.
func ( *AccountRegisterDeviceRequest) () ( int) {
	if  == nil {
		return
	}
	return .TokenType
}

// GetToken returns value of Token field.
func ( *AccountRegisterDeviceRequest) () ( string) {
	if  == nil {
		return
	}
	return .Token
}

// GetAppSandbox returns value of AppSandbox field.
func ( *AccountRegisterDeviceRequest) () ( bool) {
	if  == nil {
		return
	}
	return .AppSandbox
}

// GetSecret returns value of Secret field.
func ( *AccountRegisterDeviceRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .Secret
}

// GetOtherUIDs returns value of OtherUIDs field.
func ( *AccountRegisterDeviceRequest) () ( []int64) {
	if  == nil {
		return
	}
	return .OtherUIDs
}

// AccountRegisterDevice invokes method account.registerDevice#ec86017a returning error if any.
// Register device to receive PUSH notifications¹
//
// Links:
//  1. https://core.telegram.org/api/push-updates
//
// Possible errors:
//
//	400 TOKEN_EMPTY: The specified token is empty.
//	400 TOKEN_INVALID: The provided token is invalid.
//	400 TOKEN_TYPE_INVALID: The specified token type is invalid.
//	400 WEBPUSH_AUTH_INVALID: The specified web push authentication secret is invalid.
//	400 WEBPUSH_KEY_INVALID: The specified web push elliptic curve Diffie-Hellman public key is invalid.
//	400 WEBPUSH_TOKEN_INVALID: The specified web push token is invalid.
//
// See https://core.telegram.org/method/account.registerDevice for reference.
func ( *Client) ( context.Context,  *AccountRegisterDeviceRequest) (bool, error) {
	var  BoolBox

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