Skip to content

Instantly share code, notes, and snippets.

@sinnoorc
Created November 7, 2022 09:26
Show Gist options
  • Save sinnoorc/206893e2a408ca5d538926c05586d524 to your computer and use it in GitHub Desktop.
Save sinnoorc/206893e2a408ca5d538926c05586d524 to your computer and use it in GitHub Desktop.
User Api
class UserApi {
final ApiService _apiService = ApiService();
Future<Response> getUsers() async {
try {
final Response response = await _apiService.get(AppUrl.users);
return response;
} catch (e) {
rethrow;
}
}
Future<Response> postUser({Map<String, dynamic>? data}) async {
try {
final Response response = await _apiService.post(
AppUrl.users,
data: data,
);
return response;
} catch (e) {
rethrow;
}
}
Future<Response> putUser(String id, {Map<String, dynamic>? data}) async {
try {
final Response response = await _apiService.put(
'${AppUrl.users}/$id',
data: data,
);
return response;
} catch (e) {
rethrow;
}
}
Future<Response> deleteUser(String id) async {
try {
final Response response = await _apiService.delete(
'${AppUrl.users}/$id',
);
return response;
} catch (e) {
rethrow;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment