createUser method
Creates a new user using the provided user
object.
Returns the created user object if the API call is successful.
Implementation
Future<User> createUser(User user) async {
final response =
await callApi(endpoint: 'users', method: 'post', body: user.toJson());
if (response.statusCode == 201) {
final responseData = json.decode(response.body);
final createdUser = User.fromJson(responseData);
return createdUser;
} else {
throw Exception(response);
}
}