OpenContacts/lib/apis/friend_api.dart

13 lines
587 B
Dart
Raw Normal View History

2023-04-29 15:26:12 -04:00
import 'dart:convert';
import 'package:contacts_plus_plus/clients/api_client.dart';
2023-05-01 13:13:40 -04:00
import 'package:contacts_plus_plus/models/friend.dart';
2023-04-29 15:26:12 -04:00
2023-04-30 07:39:09 -04:00
class FriendApi {
static Future<List<Friend>> getFriendsList(ApiClient client, {DateTime? lastStatusUpdate}) async {
final response = await client.get("/users/${client.userId}/friends${lastStatusUpdate != null ? "?lastStatusUpdate=${lastStatusUpdate.toUtc().toIso8601String()}" : ""}");
2023-04-29 15:26:12 -04:00
ApiClient.checkResponse(response);
final data = jsonDecode(response.body) as List;
return data.map((e) => Friend.fromMap(e)).toList();
2023-04-29 15:26:12 -04:00
}
}