2023-04-29 15:26:12 -04:00
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
2023-05-03 15:55:34 -04:00
|
|
|
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 {
|
2023-05-06 10:45:26 -04:00
|
|
|
static Future<List<Friend>> getFriendsList(ApiClient client) async {
|
2023-04-30 07:39:09 -04:00
|
|
|
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;
|
2023-05-06 10:45:26 -04:00
|
|
|
return data.map((e) => Friend.fromMap(e)).toList();
|
2023-04-29 15:26:12 -04:00
|
|
|
}
|
|
|
|
}
|