selfRegisterUser

abstract suspend fun selfRegisterUser(body: SelfRegisterBody): RainbowResult<IRainbowContact>

Finalizes a user's registration within the Rainbow environment. This method serves as the concluding step following the user registration initiation via selfRegisterByEmail.

Upon obtaining the 6-digit code via email, use this method to complete the registration process.

You must provide one of the following properties to proceed:

Return

RainbowResult callback invoked upon completion of the operation.

Parameters

body

SelfRegisterBody the user information required for registration, including login email and password. Use the [SelfRegisterBody.Builder] to construct this parameter.

Samples

import com.ale.infra.rest.listeners.onFailure
import com.ale.infra.rest.listeners.onSuccess
import com.ale.infra.rest.user.SelfRegisterBody
import com.ale.rainbowsdk.RainbowSdk
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

fun main() { 
   //sampleStart 
   val email = "your_email@domain.com"
val password = "Password"
val code = "123456"

CoroutineScope(Dispatchers.Main).launch {
    RainbowSdk().user().selfRegisterByEmail(email).onSuccess { data ->
        val body = SelfRegisterBody.Builder()
            .loginEmail(email)
            .password(password)
            .temporaryToken(code)
            .firstName("FirstName")
            .lastName("LastName")
            .build()

        RainbowSdk().user().selfRegisterUser(body).onSuccess {
            // The user is registered and can now connect to the Rainbow environment.
        }.onFailure {
            // Error handling
        }
    }.onFailure {
        // Error handling
    }
} 
   //sampleEnd
}