selfRegisterByEmail

abstract suspend fun selfRegisterByEmail(email: String, lang: String? = null): RainbowResult<Unit>

Facilitates user registration within the Rainbow environment, a two-step process:

  1. First step: Initiate user registration by invoking this API method. Once used, an e-mail is sent to the provided email address.

  2. Second step: To complete registration, use the selfRegisterUser method along with the SelfRegisterBody.Builder. Ensure using these essential properties:

    • SelfRegisterBody.Builder.loginEmail — The user's email address used for login.

    • SelfRegisterBody.Builder.password — Desired password for the user account.

    • SelfRegisterBody.Builder.temporaryToken — A 6-digit numeric code received via email.

Return

RainbowResult callback invoked upon completion of the operation.

Parameters

email

String The email address that will be used for user login.

lang

String (optional) The language used to translate the email text. Should use the format defined by ISO 639-1. The device's local language is used if this parameter is not specified.

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
}