5e169251fe
- Remove ApiClientWrapper and MockApiClientWrapper - Simplify IApiClient interface - Update dependency injection configuration - Optimize calendar service and AG-UI chat models
29 lines
845 B
Dart
29 lines
845 B
Dart
import 'package:social_app/core/api/i_api_client.dart';
|
|
import 'models/user_response.dart';
|
|
|
|
class UsersApi {
|
|
final IApiClient _client;
|
|
static const _prefix = '/api/v1/users';
|
|
|
|
UsersApi(this._client);
|
|
|
|
Future<UserResponse> getMe() async {
|
|
final response = await _client.get('$_prefix/me');
|
|
return UserResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<UserResponse> updateMe(UserUpdateRequest request) async {
|
|
final response = await _client.patch('$_prefix/me', data: request.toJson());
|
|
return UserResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<List<UserResponse>> searchUsers(String query) async {
|
|
final response = await _client.post(
|
|
'$_prefix/search',
|
|
data: {'query': query},
|
|
);
|
|
final List<dynamic> data = response.data;
|
|
return data.map((json) => UserResponse.fromJson(json)).toList();
|
|
}
|
|
}
|