Created
November 7, 2022 09:26
-
-
Save sinnoorc/206893e2a408ca5d538926c05586d524 to your computer and use it in GitHub Desktop.
User Api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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