OpenContacts/lib/apis/friend_api.dart

14 lines
453 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<Iterable<Friend>> getFriendsList(ApiClient client) async {
final response = await client.get("/users/${client.userId}/friends");
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));
}
}