2023-05-29 14:16:23 -04:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2024-07-15 00:23:04 -04:00
|
|
|
import 'package:OpenContacts/clients/api_client.dart';
|
|
|
|
import 'package:OpenContacts/models/session.dart';
|
2023-05-29 14:16:23 -04:00
|
|
|
|
|
|
|
class SessionApi {
|
|
|
|
static Future<Session> getSession(ApiClient client, {required String sessionId}) async {
|
|
|
|
final response = await client.get("/sessions/$sessionId");
|
|
|
|
client.checkResponse(response);
|
|
|
|
final body = jsonDecode(response.body);
|
|
|
|
return Session.fromMap(body);
|
|
|
|
}
|
2023-05-30 09:09:38 -04:00
|
|
|
|
2023-06-04 10:27:18 -04:00
|
|
|
static Future<List<Session>> getSessions(ApiClient client, {SessionFilterSettings? filterSettings}) async {
|
|
|
|
final response = await client.get("/sessions${filterSettings == null ? "" : filterSettings.buildRequestString()}");
|
2023-05-30 09:09:38 -04:00
|
|
|
client.checkResponse(response);
|
|
|
|
final body = jsonDecode(response.body) as List;
|
|
|
|
return body.map((e) => Session.fromMap(e)).toList();
|
|
|
|
}
|
2023-05-29 14:16:23 -04:00
|
|
|
}
|