31 lines
805 B
Dart
31 lines
805 B
Dart
import 'package:term_remote_ctl/core/network/agent_api_client.dart';
|
|
import 'package:term_remote_ctl/features/sessions/session.dart';
|
|
|
|
class SessionRepository {
|
|
SessionRepository(this._client);
|
|
|
|
final AgentApiClient _client;
|
|
|
|
Future<List<Session>> listSessions() async {
|
|
final sessions = await _client.listSessions();
|
|
return sessions.map(Session.fromJson).toList(growable: false);
|
|
}
|
|
|
|
Future<Session> createSession({
|
|
String? name,
|
|
String? projectId,
|
|
String? workingDirectory,
|
|
}) async {
|
|
final session = await _client.createSession(
|
|
name: name,
|
|
projectId: projectId,
|
|
workingDirectory: workingDirectory,
|
|
);
|
|
return Session.fromJson(session);
|
|
}
|
|
|
|
Future<void> deleteSession(String sessionId) {
|
|
return _client.deleteSession(sessionId);
|
|
}
|
|
}
|