deleteSession method

Future<void> deleteSession(
  1. DeleteSessionRequest request
)

Implementation

Future<void> deleteSession(DeleteSessionRequest request) async {
  _ensureInitialised();

  /// Todo: see if this is still required?

  if (_useMockData) {
    await Future.delayed(const Duration(milliseconds: 300));
    return;
  }

  try {
    final client = await _createClientWithAuthHeaders();
    final response = await client.delete(
      url: '$_sessionServiceUrl/Session/DeleteSession',
      requestData: request.toJson(),
      user: _user,
    );

    if (response?.statusCode != 200) {
      throw AuthException(
        AuthenticationErrorCodes.sessionDeletionFailed,
        cause: response?.data,
      );
    }
  } catch (e, s) {
    logger.error(
      this,
      'Exception while deleting session',
      error: e,
      stackTrace: s,
    );
    rethrow;
  }
}