OpenContacts/lib/apis/user_api.dart

13 lines
447 B
Dart
Raw Normal View History

2023-04-30 09:43:59 -04:00
import 'dart:convert';
2023-05-01 13:13:40 -04:00
import 'package:contacts_plus_plus/api_client.dart';
import 'package:contacts_plus_plus/models/user.dart';
2023-04-30 09:43:59 -04:00
class UserApi {
static Future<Iterable<User>> searchUsers(ApiClient client, {required String needle}) async {
final response = await client.get("/users?name=$needle");
ApiClient.checkResponse(response);
final data = jsonDecode(response.body) as List;
return data.map((e) => User.fromMap(e));
}
}