selfRegisterByEmail

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

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.

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.

listener

RainbowListener (optional) callback invoked upon completion of the operation. Set to null if not required.

Samples

import com.ale.infra.contact.IRainbowContact
import com.ale.infra.rest.listeners.RainbowError
import com.ale.infra.rest.listeners.RainbowListener
import com.ale.infra.rest.user.SelfRegisterBody
import com.ale.rainbowsdk.RainbowSdk
fun main() { 
   //sampleStart 
   val email = "your_email@domain.com"
val password = "Password"
val code = "123456"

RainbowSdk().user().selfRegisterByEmail(email, listener = object : RainbowListener<Unit, Unit> {
    override fun onSuccess(data: Unit) {
        val body = SelfRegisterBody.Builder()
            .loginEmail(email)
            .password(password)
            .temporaryToken(code)
            .firstName("FirstName")
            .lastName("LastName")
            .build()

        RainbowSdk().user().selfRegisterUser(body, listener = object : RainbowListener<IRainbowContact, Unit> {
            override fun onSuccess(data: IRainbowContact) {
                // The user is registered and can now connect to the Rainbow environment.
            }

            override fun onError(error: RainbowError<Unit>) {
                // Error handling
            }
        })
    }

    override fun onError(error: RainbowError<Unit>) {
        // Error handling
    }
}) 
   //sampleEnd
}