[Android] Authentication API

An interface that allows developers to add authentication functionality to their applications. It allows users to log in securely and access protected resources.

Login

/** * Interface for authentication. */ interface Auth { /** * Login as a guest. * * @param firstName The first name of the guest. * @param lastName The last name of the guest. * @param dob The date of birth of the guest. * @return A resource containing the login SSO response. */ suspend fun loginAsGuest(firstName: String, lastName: String, dob: String): Resource<LoginSsoResponse> /** * Login as a patient. * * @param username The username of the patient. * @param password The password of the patient. * @return A resource containing the login response. */ suspend fun loginAsPatient(username: String, password: String): Resource<LoginResponse> /** * Login with a token. * * @param token The token for authentication. * @return A resource containing the login response. */ suspend fun loginWithToken(token: String): Resource<LoginResponse> }

 

Example Usage

/** * Launches a coroutine to login as guest. */ viewModelScope.launch { val res = VseeApi.auth.loginAsGuest(firstName = firstName, lastName = lastName, dob = dob) when (res) { is Resource.Success -> { // Save user data. } is Resource.Error -> Timber.e("Login error: ${res.message}") } }