getSession method

Future<DataleonSession> getSession()

Fetch the current session info from the backend.

Implementation

Future<DataleonSession> getSession() async {
  final url = Uri.parse('${config.baseUrl}/api/v1/sessions/${config.sessionId}');
  final response = await _client.get(url, headers: _headers);

  if (response.statusCode != 200) {
    throw DataleonApiException(
      'Failed to fetch session',
      statusCode: response.statusCode,
    );
  }

  final json = jsonDecode(response.body) as Map<String, dynamic>;
  return DataleonSession.fromJson(json);
}