login method

Future<VIAuthResult> login(
  1. String username,
  2. String password
)

Logs in a user with the given Voximplant username and password.

username - Full user name, including Voximplant user, application, and account name in the format user@application.account.voximplant.com.

password - User password.

Throws VIException, if login process failed, otherwise returns VIAuthResult.

Errors:

Implementation

Future<VIAuthResult> login(String username, String password) async {
  _changeClientState(VIClientState.LoggingIn);
  try {
    Map<String, dynamic>? data =
        await _channel.invokeMapMethod<String, dynamic>(
      'Client.login',
      <String, String>{'username': username, 'password': password},
    );
    if (data == null) {
      _VILog._e('VIClient: login: data was null, skipping');
      throw VIException(
        VIClientError.ERROR_INTERNAL,
        'VIClient:login: data was null',
      );
    }
    _saveUsername(username);
    return await _processLoginSuccess(data);
  } on PlatformException catch (e) {
    VIClientState state = await getClientState();
    _changeClientState(state);
    throw VIException(e.code, e.message);
  } catch (e) {
    VIClientState state = await getClientState();
    _changeClientState(state);
    rethrow;
  }
}