loginUser method

Future<void> loginUser({
  1. required String username,
  2. required String email,
})

Handles user login into the sdk

Implementation

Future<void> loginUser(
    {required String username, required String email}) async {
  try {
    var response = await _linkingRepository.loginUser(LoginUserRequest(
      companyName: username,
      email: email,
    ));
    if (response.status == 'success') {
      await _storageService.setString('token', response.data?.apiKey ?? '');
      await _storageService.setString(
          'companyUid', response.data?.companyUid ?? '');
      // ignore: unused_local_variable
      final token = await _storageService.getString('token');

      //log('token: $token');
    } else {
      getConnectionUrlLoadingStatus.value = false;
      linkingError.value = response.message.toString();
      debugPrint(response.message);
    }
  } catch (e) {
    if (e is DioError) {
      getConnectionUrlLoadingStatus.value = false;
      linkingError.value = e.response?.data['message'] ?? '';
    } else {
      getConnectionUrlLoadingStatus.value = false;
      linkingError.value = e.toString();
    }
  }
}