editAccountDetails method

Future<int> editAccountDetails(
  1. UserModel userModel
)

Implementation

Future<int> editAccountDetails(UserModel userModel) async {
  http.Response response;

  final sharedPreferencesService = await SharedPreferencesService.getInstance();

  try {
    final data = userModel.postData();
    var currentUserId = await sharedPreferencesService.getUserId();
    var token = await sharedPreferencesService.getToken();

    response = await postHttp('/user/$currentUserId', token, data);
    if (response.statusCode == 200) {
      print("User Details Updated ");
    } else {
      print(response.body);
    }
  } catch (e) {
    throw Exception("Couldn't edit user details");
  }

  return response.statusCode;
}