verifyPhoneNumber method

Future<M4eUniqueId> verifyPhoneNumber (M4eAuthPhoneNumberForm m4eAuthPhoneNumberForm)

Takes in M4eAuthPhoneNumberForm parameter to send verification-code (OTP) from m4e to provided phone number

Throws ServerException if call to server fails

Throws ServerException with NO_INTERNET_CONNECTION error code if device is not connected to the internet

Implementation

Future<M4eUniqueId> verifyPhoneNumber(
    M4eAuthPhoneNumberForm m4eAuthPhoneNumberForm) async {
  if ((await _connectionChecker.hasConnection) ?? false) {
    try {
      final _userId =
          await _authApi.verifyPhoneNumber(m4eAuthPhoneNumberForm);

      final _credentials = m4eAuthPhoneNumberForm.copyWith(id: _userId);
      await _authApi.cacheUserCredentials(_credentials);

      return _userId;
    } catch (e) {
      rethrow;
    }
  }

  throw M4eExceptionMessages.kNoInternetConnectionException;
}